public static RequestValidationResult CancelRequestByLocalConfig( string targetUrl, string queueitToken, CancelEventConfig cancelConfig, string customerId, string secretKey) { var debugEntries = new Dictionary <string, string>(); var connectorDiagnostics = ConnectorDiagnostics.Verify(customerId, secretKey, queueitToken); if (connectorDiagnostics.HasError) { return(connectorDiagnostics.ValidationResult); } try { return(CancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey, debugEntries, connectorDiagnostics.IsEnabled)); } catch (Exception e) { if (connectorDiagnostics.IsEnabled) { debugEntries["Exception"] = e.Message; } throw; } finally { SetDebugCookie(debugEntries); } }
private static RequestValidationResult CancelRequestByLocalConfig( string targetUrl, string queueitToken, CancelEventConfig cancelConfig, string customerId, string secretKey, Dictionary <string, string> debugEntries, bool isDebug) { targetUrl = GenerateTargetUrl(targetUrl); if (isDebug) { debugEntries["SdkVersion"] = UserInQueueService.SDK_VERSION; debugEntries["Runtime"] = GetRuntime(); debugEntries["TargetUrl"] = targetUrl; debugEntries["QueueitToken"] = queueitToken; debugEntries["CancelConfig"] = cancelConfig != null?cancelConfig.ToString() : "NULL"; debugEntries["OriginalUrl"] = GetHttpContextProvider().HttpRequest.Url.AbsoluteUri; LogExtraRequestDetails(debugEntries); } if (string.IsNullOrEmpty(targetUrl)) { throw new ArgumentException("targeturl can not be null or empty."); } if (string.IsNullOrEmpty(customerId)) { throw new ArgumentException("customerId can not be null or empty."); } if (string.IsNullOrEmpty(secretKey)) { throw new ArgumentException("secretKey can not be null or empty."); } if (cancelConfig == null) { throw new ArgumentException("cancelEventConfig can not be null."); } if (string.IsNullOrEmpty(cancelConfig.EventId)) { throw new ArgumentException("EventId from cancelEventConfig can not be null or empty."); } if (string.IsNullOrEmpty(cancelConfig.QueueDomain)) { throw new ArgumentException("QueueDomain from cancelEventConfig can not be null or empty."); } var userInQueueService = GetUserInQueueService(); var result = userInQueueService.ValidateCancelRequest(targetUrl, cancelConfig, customerId, secretKey); result.IsAjaxResult = IsQueueAjaxCall(); return(result); }
public static RequestValidationResult CancelRequestByLocalConfig( string targetUrl, string queueitToken, CancelEventConfig cancelConfig, string customerId, string secretKey) { var debugEntries = new Dictionary <string, string>(); try { targetUrl = GenerateTargetUrl(targetUrl); return(CancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey, debugEntries)); } finally { SetDebugCookie(debugEntries); } }
private static RequestValidationResult HandleCancelAction( string currentUrlWithoutQueueITToken, string queueitToken, CustomerIntegration customerIntegrationInfo, string customerId, string secretKey, Dictionary <string, string> debugEntries, IntegrationConfigModel matchedConfig) { var cancelEventConfig = new CancelEventConfig() { QueueDomain = matchedConfig.QueueDomain, EventId = matchedConfig.EventId, Version = customerIntegrationInfo.Version, CookieDomain = matchedConfig.CookieDomain }; var targetUrl = GenerateTargetUrl(currentUrlWithoutQueueITToken); return(CancelRequestByLocalConfig(targetUrl, queueitToken, cancelEventConfig, customerId, secretKey, debugEntries)); }
private static RequestValidationResult HandleCancelAction( string currentUrlWithoutQueueITToken, string queueitToken, CustomerIntegration customerIntegrationInfo, string customerId, string secretKey, Dictionary <string, string> debugEntries, IntegrationConfigModel matchedConfig, bool isDebug) { var cancelEventConfig = new CancelEventConfig { QueueDomain = matchedConfig.QueueDomain, EventId = matchedConfig.EventId, Version = customerIntegrationInfo.Version, CookieDomain = matchedConfig.CookieDomain, IsCookieHttpOnly = matchedConfig.IsCookieHttpOnly ?? false, IsCookieSecure = matchedConfig.IsCookieSecure ?? false, ActionName = matchedConfig.Name }; return(CancelRequestByLocalConfig(currentUrlWithoutQueueITToken, queueitToken, cancelEventConfig, customerId, secretKey, debugEntries, isDebug)); }
public RequestValidationResult ValidateCancelRequest( string targetUrl, CancelEventConfig config, string customerId, string secretKey) { //we do not care how long cookie is valid while canceling cookie var state = _userInQueueStateRepository.GetState(config.EventId, -1, secretKey, false); if (state.IsValid) { this._userInQueueStateRepository.CancelQueueCookie(config.EventId, config.CookieDomain); var query = GetQueryString(customerId, config.EventId, config.Version) + (!string.IsNullOrEmpty(targetUrl) ? $"&r={HttpUtility.UrlEncode(targetUrl)}" : ""); var domainAlias = config.QueueDomain; if (!domainAlias.EndsWith("/")) { domainAlias = domainAlias + "/"; } var redirectUrl = "https://" + domainAlias + "cancel/" + customerId + "/" + config.EventId + "/?" + query; return(new RequestValidationResult(ActionType.CancelAction) { RedirectUrl = redirectUrl, EventId = config.EventId, QueueId = state.QueueId, RedirectType = state.RedirectType }); } else { return(new RequestValidationResult(ActionType.CancelAction) { RedirectUrl = null, EventId = config.EventId, QueueId = null, RedirectType = null }); } }
public RequestValidationResult ValidateCancelRequest( string targetUrl, CancelEventConfig config, string customerId, string secretKey) { //we do not care how long cookie is valid while canceling cookie var state = _userInQueueStateRepository.GetState(config.EventId, -1, secretKey, false); if (state.IsValid) { _userInQueueStateRepository.CancelQueueCookie(config.EventId, config.CookieDomain, config.IsCookieHttpOnly, config.IsCookieSecure); var query = GetQueryString(customerId, config.EventId, config.Version, config.ActionName) + (!string.IsNullOrEmpty(targetUrl) ? $"&r={Uri.EscapeDataString(targetUrl)}" : ""); var uriPath = $"cancel/{customerId}/{config.EventId}"; if (!string.IsNullOrEmpty(state.QueueId)) { uriPath += $"/{state.QueueId}"; } var redirectUrl = GenerateRedirectUrl(config.QueueDomain, uriPath, query); return(new RequestValidationResult(ActionType.CancelAction, redirectUrl: redirectUrl, eventId: config.EventId, queueId: state.QueueId, redirectType: state.RedirectType, actionName: config.ActionName)); } else { return(new RequestValidationResult(ActionType.CancelAction, eventId: config.EventId, actionName: config.ActionName)); } }