def updateWindowSize(self, tenantId, newSize):
     """Updates windowsize of a specified tenant."""
     self.checkSize(newSize)
     t = self.tenantInfo.objects.get(tenantId__exact=tenantId)
     t.windowsize = newSize
     t.save()
     logger.info("%s windowsize updated to %d", tenantId, newSize)
     return t
 def checkToken(self, admin_token, token, tenant_id, url, auth_api):
     """checks if a token is valid against a url using an admin token."""
     logger.info("Starting Authentication of token %s ", token)
     try:
         if not token:
             raise Unauthorized("Token is empty")
         auth_result = self.get_info_token(url, admin_token, token, auth_api)
         if auth_result:
             if tenant_id == auth_result.tenant["id"]:
                 logger.info('The token is valid')
             else:
                 logger.error("TenantId %s ", tenant_id)
                 logger.error("Token TenantId %s ", auth_result.tenant["id"])
                 raise Unauthorized("Token is not valid for specified tenant %s" % tenant_id)
     except Unauthorized as unauth:
         logger.error(unauth)
         raise unauth
     except InternalServerError as internalError:
         raise AuthorizationFailure("Token could not have enough permissions to access tenant: %s" % tenant_id)
     except Exception as ex:
         raise ex