def __getQueueITTokenValidationResult(self, targetUrl, eventId, config, queueParams, customerId, secretKey): calculatedHash = QueueitHelpers.hmacSha256Encode( queueParams.queueITTokenWithoutHash, secretKey) if (calculatedHash.upper() != queueParams.hashCode.upper()): return self.__getVaidationErrorResult(customerId, targetUrl, config, queueParams, "hash") if (queueParams.eventId.upper() != eventId.upper()): return self.__getVaidationErrorResult( customerId, targetUrl, config, queueParams, "eventid") if (queueParams.timeStamp < QueueitHelpers.getCurrentTime()): return self.__getVaidationErrorResult( customerId, targetUrl, config, queueParams, "timestamp") cookieDomain = "" if (not Utils.isNilOrEmpty(config.cookieDomain)): cookieDomain = config.cookieDomain self.userInQueueStateRepository.store( config.eventId, queueParams.queueId, queueParams.cookieValidityMinutes, cookieDomain, queueParams.redirectType, secretKey) return RequestValidationResult(ActionTypes.QUEUE, config.eventId, queueParams.queueId, None, queueParams.redirectType)
def verify(customer_id, secret_key, queueit_token): diagnostics = ConnectorDiagnostics() q_params = QueueUrlParams.extractQueueParams(queueit_token) if q_params is None: return diagnostics if q_params.redirectType is None: return diagnostics if q_params.redirectType != "debug": return diagnostics if Utils.isNilOrEmpty(customer_id) or Utils.isNilOrEmpty(secret_key): diagnostics.__setStateWithSetupError() return diagnostics expected_hash = QueueitHelpers.hmacSha256Encode( q_params.queueITTokenWithoutHash, secret_key) if q_params.hashCode != expected_hash: diagnostics.__setStateWithTokenError(customer_id, "hash") return diagnostics if q_params.timeStamp < QueueitHelpers.getCurrentTime(): diagnostics.__setStateWithTokenError(customer_id, "timestamp") return diagnostics diagnostics.isEnabled = True return diagnostics
def __validateToken(self, config, queue_params, secret_key): calculated_hash = QueueitHelpers.hmacSha256Encode( queue_params.queueITTokenWithoutHash, secret_key) if calculated_hash.upper() != queue_params.hashCode.upper(): return TokenValidationResult(False, "hash") if queue_params.eventId.upper() != config.eventId.upper(): return TokenValidationResult(False, "eventid") if queue_params.timeStamp < QueueitHelpers.getCurrentTime(): return TokenValidationResult(False, "timestamp") return TokenValidationResult(True, None)
def __getIsDebug(queueitToken, secretKey): qParams = QueueUrlParams.extractQueueParams(queueitToken) if (qParams == None): return False redirectType = qParams.redirectType if (redirectType == None): return False if (redirectType.upper() == "DEBUG"): calculatedHash = QueueitHelpers.hmacSha256Encode( qParams.queueITTokenWithoutHash, secretKey) valid = qParams.hashCode == calculatedHash return valid return False
def __generateHash(event_id, queue_id, fixed_cookie_validity_minutes, redirect_type, issue_time, secret_key): return QueueitHelpers.hmacSha256Encode( event_id + queue_id + fixed_cookie_validity_minutes + redirect_type + issue_time, secret_key)
def __generateHash(eventId, queueId, fixedCookieValidityMinutes, redirectType, issueTime, secretKey): return QueueitHelpers.hmacSha256Encode( eventId + queueId + fixedCookieValidityMinutes + redirectType + issueTime, secretKey)