def validateCancelRequest(self, targetUrl, cancelConfig, customerId,
                              secretKey):
        state = self.userInQueueStateRepository.getState(
            cancelConfig.eventId, -1, secretKey, False)
        if (state.isValid):
            self.userInQueueStateRepository.cancelQueueCookie(
                cancelConfig.eventId, cancelConfig.cookieDomain)

            targetUrlParam = ""
            if (not Utils.isNilOrEmpty(targetUrl)):
                targetUrlParam = "&r=" + QueueitHelpers.urlEncode(
                    targetUrl)

            query = self.__getQueryString(customerId, cancelConfig.eventId,
                                          cancelConfig.version, None,
                                          None) + targetUrlParam

            domainAlias = cancelConfig.queueDomain
            if (not domainAlias.endswith("/")):
                domainAlias = domainAlias + "/"

            redirectUrl = "https://" + domainAlias + "cancel/" + customerId + "/" + cancelConfig.eventId + "/?" + query
            return RequestValidationResult(ActionTypes.CANCEL,
                                           cancelConfig.eventId, state.queueId,
                                           redirectUrl, state.redirectType)
        else:
            return RequestValidationResult(
                ActionTypes.CANCEL, cancelConfig.eventId, None, None, None)
Beispiel #2
0
    def __getQueueResult(self, target_url, config, customer_id):
        target_url_param = ""
        if not Utils.isNilOrEmpty(target_url):
            target_url_param = "&t={}".format(
                QueueitHelpers.urlEncode(target_url))
        query_string = self.__getQueryString(customer_id, config.eventId,
                                             config.version, config.actionName,
                                             config.culture, config.layoutName)
        query = "{}{}".format(query_string, target_url_param)
        redirect_url = self.__generateRedirectUrl(config.queueDomain, "",
                                                  query)

        return RequestValidationResult(ActionTypes.QUEUE, config.eventId, None,
                                       redirect_url, None, config.actionName)
    def setCookie(self, name, value, expire, domain, is_http_only, is_secure):
        if str(domain) == "":
            domain = None

        if value is not None:
            value = QueueitHelpers.urlEncode(value)

        self.response.set_cookie(name,
                                 value,
                                 max_age=None,
                                 expires=expire,
                                 path='/',
                                 domain=domain,
                                 secure=is_secure,
                                 httponly=is_http_only)
    def setCookie(self, name, value, expire, domain):
        if (str(domain) == ""):
            domain = None

        if (value is not None):
            value = QueueitHelpers.urlEncode(value)

        self.response.set_cookie(name,
                                 value,
                                 max_age=None,
                                 expires=expire,
                                 path='/',
                                 domain=domain,
                                 secure=None,
                                 httponly=False)
    def __getQueryString(self, customerId, eventId, configVersion, culture,
                         layoutName):
        queryStringList = []
        queryStringList.append(
            "c=" + QueueitHelpers.urlEncode(customerId))
        queryStringList.append(
            "e=" + QueueitHelpers.urlEncode(eventId))
        queryStringList.append("ver=v3-py_" +
                               self.httpContextProvider.getProviderName() +
                               "-" + self.SDK_VERSION)

        if (configVersion is None):
            configVersion = "-1"
        queryStringList.append("cver=" + str(configVersion))

        if (not Utils.isNilOrEmpty(culture)):
            queryStringList.append(
                "cid=" + QueueitHelpers.urlEncode(culture))

        if (not Utils.isNilOrEmpty(layoutName)):
            queryStringList.append(
                "l=" + QueueitHelpers.urlEncode(layoutName))

        return "&".join(queryStringList)
    def __getInQueueRedirectResult(self, targetUrl, config, customerId):
        targetUrlParam = ""
        if (not Utils.isNilOrEmpty(targetUrl)):
            targetUrlParam = "&t=" + QueueitHelpers.urlEncode(
                targetUrl)

        domainAlias = config.queueDomain
        if (not domainAlias.endswith("/")):
            domainAlias = domainAlias + "/"

        qs = self.__getQueryString(customerId, config.eventId, config.version,
                                   config.culture, config.layoutName)
        redirectUrl = "https://" + domainAlias + "?" + qs + targetUrlParam

        return RequestValidationResult(ActionTypes.QUEUE, config.eventId, None,
                                       redirectUrl, None)
Beispiel #7
0
    def validateCancelRequest(self, target_url, cancel_config, customer_id,
                              secret_key):

        state = self.userInQueueStateRepository.getState(
            cancel_config.eventId, -1, secret_key, False)

        if state.isValid:
            self.userInQueueStateRepository.cancelQueueCookie(
                cancel_config.eventId, cancel_config.cookieDomain,
                cancel_config.isCookieHttpOnly, cancel_config.isCookieSecure)

            target_url_param = ""
            if not Utils.isNilOrEmpty(target_url):
                target_url_param = "&r={}".format(
                    QueueitHelpers.urlEncode(target_url))

            query_string = self.__getQueryString(customer_id,
                                                 cancel_config.eventId,
                                                 cancel_config.version,
                                                 cancel_config.actionName,
                                                 None, None)

            query = "{}{}".format(query_string, target_url_param)

            uri_path = "cancel/{}/{}".format(customer_id,
                                             cancel_config.eventId)

            if state.queueId:
                uri_path = "{}/{}".format(uri_path, state.queueId)

            redirect_url = self.__generateRedirectUrl(
                cancel_config.queueDomain, uri_path, query)

            return RequestValidationResult(ActionTypes.CANCEL,
                                           cancel_config.eventId,
                                           state.queueId, redirect_url,
                                           state.redirectType,
                                           cancel_config.actionName)
        else:
            return RequestValidationResult(ActionTypes.CANCEL,
                                           cancel_config.eventId, None, None,
                                           None, cancel_config.actionName)
Beispiel #8
0
    def __getErrorResult(self, customer_id, target_url, config, q_params,
                         error_code):
        time_stamp = str(QueueitHelpers.getCurrentTime())
        target_url_param = ""
        if not Utils.isNilOrEmpty(target_url):
            target_url_param = "&t={}".format(
                QueueitHelpers.urlEncode(target_url))

        query_string = self.__getQueryString(customer_id, config.eventId,
                                             config.version, config.actionName,
                                             config.culture, config.layoutName)
        query = "{}&queueittoken={}&ts={}{}".format(query_string,
                                                    q_params.queueITToken,
                                                    time_stamp,
                                                    target_url_param)
        redirect_url = self.__generateRedirectUrl(
            config.queueDomain, "error/{}/".format(error_code), query)

        return RequestValidationResult(ActionTypes.QUEUE, config.eventId, None,
                                       redirect_url, None, config.actionName)
    def __getVaidationErrorResult(self, customerId, targetUrl, config, qParams,
                                  errorCode):
        targetUrlParam = ""
        if (not Utils.isNilOrEmpty(targetUrl)):
            targetUrlParam = "&t=" + QueueitHelpers.urlEncode(
                targetUrl)

        query = self.__getQueryString(
            customerId, config.eventId, config.version, config.culture,
            config.layoutName
        ) + "&queueittoken=" + qParams.queueITToken + "&ts=" + str(
            QueueitHelpers.getCurrentTime()) + targetUrlParam

        domainAlias = config.queueDomain
        if (not domainAlias.endswith("/")):
            domainAlias = domainAlias + "/"

        redirectUrl = "https://" + domainAlias + "error/" + errorCode + "/?" + query
        return RequestValidationResult(ActionTypes.QUEUE, config.eventId, None,
                                       redirectUrl, None)
Beispiel #10
0
    def __getQueryString(self, customer_id, event_id, config_version,
                         action_name, culture, layout_name):
        query_string_list = [
            "c=" + QueueitHelpers.urlEncode(customer_id),
            "e=" + QueueitHelpers.urlEncode(event_id),
            "ver=" + self.SDK_VERSION, "kupver=" + QueueitHelpers.urlEncode(
                self.httpContextProvider.getProviderName())
        ]
        if config_version is None:
            config_version = "-1"
        query_string_list.append("cver=" + str(config_version))
        query_string_list.append("man=" +
                                 QueueitHelpers.urlEncode(action_name))

        if not Utils.isNilOrEmpty(culture):
            query_string_list.append("cid=" +
                                     QueueitHelpers.urlEncode(culture))

        if not Utils.isNilOrEmpty(layout_name):
            query_string_list.append("l=" +
                                     QueueitHelpers.urlEncode(layout_name))

        return "&".join(query_string_list)
Beispiel #11
0
 def getAjaxRedirectUrl(self):
     if (not Utils.isNilOrEmpty(self.redirectUrl)):
         return QueueitHelpers.urlEncode(self.redirectUrl)
     return ""