@@ -51,26 +51,6 @@ def self.logMoreRequestDetails(debugEntries, request)
5151 end
5252 private_class_method :logMoreRequestDetails
5353
54- def self . getIsDebug ( queueitToken , secretKey )
55- qParams = QueueUrlParams . extractQueueParams ( queueitToken )
56- if ( qParams == nil )
57- return false
58- end
59-
60- redirectType = qParams . redirectType
61- if ( redirectType == nil )
62- return false
63- end
64-
65- if ( redirectType . upcase . eql? ( "DEBUG" ) )
66- calculatedHash = OpenSSL ::HMAC . hexdigest ( 'sha256' , secretKey , qParams . queueITTokenWithoutHash )
67- valid = qParams . hashCode . eql? ( calculatedHash )
68- return valid
69- end
70- return false
71- end
72- private_class_method :getIsDebug
73-
7454 def self . setDebugCookie ( debugEntries , cookieJar )
7555 if ( debugEntries == nil || debugEntries . length == 0 )
7656 return
@@ -86,9 +66,11 @@ def self.setDebugCookie(debugEntries, cookieJar)
8666 end
8767 private_class_method :setDebugCookie
8868
89- def self . _resolveQueueRequestByLocalConfig ( targetUrl , queueitToken , queueConfig , customerId , secretKey , request , debugEntries )
90- isDebug = getIsDebug ( queueitToken , secretKey )
69+ def self . _resolveQueueRequestByLocalConfig ( targetUrl , queueitToken , queueConfig , customerId , secretKey , request , debugEntries , isDebug )
70+
9171 if ( isDebug )
72+ debugEntries [ "SdkVersion" ] = UserInQueueService ::SDK_VERSION
73+ debugEntries [ "Runtime" ] = getRuntime ( )
9274 debugEntries [ "TargetUrl" ] = targetUrl
9375 debugEntries [ "QueueitToken" ] = queueitToken
9476 debugEntries [ "OriginalUrl" ] = getRealOriginalUrl ( request )
@@ -137,10 +119,12 @@ def self._resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig,
137119 end
138120 private_class_method :_resolveQueueRequestByLocalConfig
139121
140- def self . _cancelRequestByLocalConfig ( targetUrl , queueitToken , cancelConfig , customerId , secretKey , request , debugEntries )
141- targetUrl = generateTargetUrl ( targetUrl , request )
142- isDebug = getIsDebug ( queueitToken , secretKey )
122+ def self . _cancelRequestByLocalConfig ( targetUrl , queueitToken , cancelConfig , customerId , secretKey , request , debugEntries , isDebug )
123+ targetUrl = generateTargetUrl ( targetUrl , request )
124+
143125 if ( isDebug )
126+ debugEntries [ "SdkVersion" ] = UserInQueueService ::SDK_VERSION
127+ debugEntries [ "Runtime" ] = getRuntime ( )
144128 debugEntries [ "TargetUrl" ] = targetUrl
145129 debugEntries [ "QueueitToken" ] = queueitToken
146130 debugEntries [ "OriginalUrl" ] = getRealOriginalUrl ( request )
@@ -204,40 +188,64 @@ def self.extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, secretKe
204188
205189 def self . resolveQueueRequestByLocalConfig ( targetUrl , queueitToken , queueConfig , customerId , secretKey , request )
206190 debugEntries = Hash . new
191+ connectorDiagnostics = ConnectorDiagnostics . verify ( customerId , secretKey , queueitToken )
192+
193+ if ( connectorDiagnostics . hasError )
194+ return connectorDiagnostics . validationResult
195+ end
207196 begin
208197 targetUrl = generateTargetUrl ( targetUrl , request )
209- return _resolveQueueRequestByLocalConfig ( targetUrl , queueitToken , queueConfig , customerId , secretKey , request , debugEntries )
198+ return _resolveQueueRequestByLocalConfig ( targetUrl , queueitToken , queueConfig , customerId , secretKey , request , debugEntries , connectorDiagnostics . isEnabled )
199+ rescue Exception => e
200+ if ( connectorDiagnostics . isEnabled )
201+ debugEntries [ "Exception" ] = e . message
202+ end
203+ raise e
210204 ensure
211205 setDebugCookie ( debugEntries , request . cookie_jar )
212206 end
213207 end
214208
215- def self . validateRequestByIntegrationConfig ( currentUrlWithoutQueueITToken , queueitToken , integrationsConfigString , customerId , secretKey , request )
216- if ( Utils . isNilOrEmpty ( currentUrlWithoutQueueITToken ) )
217- raise KnownUserError , "currentUrlWithoutQueueITToken can not be nil or empty."
218- end
219-
220- if ( Utils . isNilOrEmpty ( integrationsConfigString ) )
221- raise KnownUserError , "integrationsConfigString can not be nil or empty."
209+ def self . validateRequestByIntegrationConfig ( currentUrlWithoutQueueITToken , queueitToken , integrationConfigJson , customerId , secretKey , request )
210+ debugEntries = Hash . new
211+ customerIntegration = Hash . new
212+ connectorDiagnostics = ConnectorDiagnostics . verify ( customerId , secretKey , queueitToken )
213+
214+ if ( connectorDiagnostics . hasError )
215+ return connectorDiagnostics . validationResult
222216 end
223-
224- debugEntries = Hash . new
225217 begin
226- customerIntegration = JSON . parse ( integrationsConfigString )
227-
228- isDebug = getIsDebug ( queueitToken , secretKey )
229- if ( isDebug )
230- debugEntries [ "ConfigVersion" ] = customerIntegration [ "Version" ]
218+ if ( connectorDiagnostics . isEnabled )
219+ debugEntries [ "SdkVersion" ] = UserInQueueService ::SDK_VERSION
220+ debugEntries [ "Runtime" ] = getRuntime ( )
231221 debugEntries [ "PureUrl" ] = currentUrlWithoutQueueITToken
232222 debugEntries [ "QueueitToken" ] = queueitToken
233223 debugEntries [ "OriginalUrl" ] = getRealOriginalUrl ( request )
234224 logMoreRequestDetails ( debugEntries , request )
235225 end
236-
226+
227+ customerIntegration = JSON . parse ( integrationConfigJson )
228+
229+ if ( connectorDiagnostics . isEnabled )
230+ if ( customerIntegration . length != 0 and customerIntegration [ "Version" ] != nil )
231+ debugEntries [ "ConfigVersion" ] = customerIntegration [ "Version" ]
232+ else
233+ debugEntries [ "ConfigVersion" ] = "NULL"
234+ end
235+ end
236+
237+ if ( Utils . isNilOrEmpty ( currentUrlWithoutQueueITToken ) )
238+ raise KnownUserError , "currentUrlWithoutQueueITToken can not be nil or empty."
239+ end
240+
241+ if ( customerIntegration . length == 0 || customerIntegration [ "Version" ] == nil )
242+ raise KnownUserError , "integrationConfigJson is not valid json."
243+ end
244+
237245 integrationEvaluator = IntegrationEvaluator . new
238246 matchedConfig = integrationEvaluator . getMatchedIntegrationConfig ( customerIntegration , currentUrlWithoutQueueITToken , request )
239247
240- if ( isDebug )
248+ if ( connectorDiagnostics . isEnabled )
241249 if ( matchedConfig == nil )
242250 debugEntries [ "MatchedConfig" ] = "NULL"
243251 else
@@ -246,33 +254,37 @@ def self.validateRequestByIntegrationConfig(currentUrlWithoutQueueITToken, queue
246254 end
247255
248256 if ( matchedConfig == nil )
249- return RequestValidationResult . new ( nil , nil , nil , nil , nil )
257+ return RequestValidationResult . new ( nil , nil , nil , nil , nil , nil )
250258 end
251259
252260 # unspecified or 'Queue' specified
253261 if ( !matchedConfig . key? ( "ActionType" ) || Utils . isNilOrEmpty ( matchedConfig [ "ActionType" ] ) || matchedConfig [ "ActionType" ] . eql? ( ActionTypes ::QUEUE ) )
254- return handleQueueAction ( currentUrlWithoutQueueITToken , queueitToken , customerIntegration , customerId , secretKey , matchedConfig , request , debugEntries )
262+ return handleQueueAction ( currentUrlWithoutQueueITToken , queueitToken , customerIntegration ,
263+ customerId , secretKey , matchedConfig , request , debugEntries , connectorDiagnostics . isEnabled )
255264
256265 elsif ( matchedConfig [ "ActionType" ] . eql? ( ActionTypes ::CANCEL ) )
257- return handleCancelAction ( currentUrlWithoutQueueITToken , queueitToken , customerIntegration , customerId , secretKey , matchedConfig , request , debugEntries )
266+ return handleCancelAction ( currentUrlWithoutQueueITToken , queueitToken , customerIntegration ,
267+ customerId , secretKey , matchedConfig , request , debugEntries , connectorDiagnostics . isEnabled )
258268
259269 # for all unknown types default to 'Ignore'
260270 else
261271 userInQueueService = getUserInQueueService ( request . cookie_jar )
262- result = userInQueueService . getIgnoreActionResult ( )
272+ result = userInQueueService . getIgnoreActionResult ( matchedConfig [ "Name" ] )
263273 result . isAjaxResult = isQueueAjaxCall ( request )
264274
265275 return result
266276 end
267-
268- rescue StandardError => stdErr
269- raise KnownUserError , "integrationConfiguration text was not valid: " + stdErr . message
277+ rescue Exception => e
278+ if ( connectorDiagnostics . isEnabled )
279+ debugEntries [ "Exception" ] = e . message
280+ end
281+ raise e
270282 ensure
271283 setDebugCookie ( debugEntries , request . cookie_jar )
272284 end
273285 end
274286
275- def self . handleQueueAction ( currentUrlWithoutQueueITToken , queueitToken , customerIntegration , customerId , secretKey , matchedConfig , request , debugEntries )
287+ def self . handleQueueAction ( currentUrlWithoutQueueITToken , queueitToken , customerIntegration , customerId , secretKey , matchedConfig , request , debugEntries , isDebug )
276288 queueConfig = QueueEventConfig . new
277289 queueConfig . eventId = matchedConfig [ "EventId" ]
278290 queueConfig . queueDomain = matchedConfig [ "QueueDomain" ]
@@ -282,7 +294,8 @@ def self.handleQueueAction(currentUrlWithoutQueueITToken, queueitToken, customer
282294 queueConfig . extendCookieValidity = matchedConfig [ "ExtendCookieValidity" ]
283295 queueConfig . cookieValidityMinute = matchedConfig [ "CookieValidityMinute" ]
284296 queueConfig . version = customerIntegration [ "Version" ]
285-
297+ queueConfig . actionName = matchedConfig [ "Name" ]
298+
286299 case matchedConfig [ "RedirectLogic" ]
287300 when "ForcedTargetUrl"
288301 targetUrl = matchedConfig [ "ForcedTargetUrl" ]
@@ -292,23 +305,34 @@ def self.handleQueueAction(currentUrlWithoutQueueITToken, queueitToken, customer
292305 targetUrl = generateTargetUrl ( currentUrlWithoutQueueITToken , request )
293306 end
294307
295- return _resolveQueueRequestByLocalConfig ( targetUrl , queueitToken , queueConfig , customerId , secretKey , request , debugEntries )
308+ return _resolveQueueRequestByLocalConfig ( targetUrl , queueitToken , queueConfig , customerId , secretKey , request , debugEntries , isDebug )
296309 end
297310
298- def self . handleCancelAction ( currentUrlWithoutQueueITToken , queueitToken , customerIntegration , customerId , secretKey , matchedConfig , request , debugEntries )
311+ def self . handleCancelAction ( currentUrlWithoutQueueITToken , queueitToken , customerIntegration , customerId , secretKey , matchedConfig , request , debugEntries , isDebug )
299312 cancelConfig = CancelEventConfig . new
300313 cancelConfig . eventId = matchedConfig [ "EventId" ]
301314 cancelConfig . queueDomain = matchedConfig [ "QueueDomain" ]
302315 cancelConfig . cookieDomain = matchedConfig [ "CookieDomain" ]
303316 cancelConfig . version = customerIntegration [ "Version" ]
304-
305- return _cancelRequestByLocalConfig ( currentUrlWithoutQueueITToken , queueitToken , cancelConfig , customerId , secretKey , request , debugEntries )
317+ cancelConfig . actionName = matchedConfig [ "Name" ]
318+
319+ return _cancelRequestByLocalConfig ( currentUrlWithoutQueueITToken , queueitToken , cancelConfig , customerId , secretKey , request , debugEntries , isDebug )
306320 end
307321
308322 def self . cancelRequestByLocalConfig ( targetUrl , queueitToken , cancelConfig , customerId , secretKey , request )
309323 debugEntries = Hash . new
324+ connectorDiagnostics = ConnectorDiagnostics . verify ( customerId , secretKey , queueitToken )
325+
326+ if ( connectorDiagnostics . hasError )
327+ return connectorDiagnostics . validationResult
328+ end
310329 begin
311- return _cancelRequestByLocalConfig ( targetUrl , queueitToken , cancelConfig , customerId , secretKey , request , debugEntries )
330+ return _cancelRequestByLocalConfig ( targetUrl , queueitToken , cancelConfig , customerId , secretKey , request , debugEntries , connectorDiagnostics . isEnabled )
331+ rescue Exception => e
332+ if ( connectorDiagnostics . isEnabled )
333+ debugEntries [ "Exception" ] = e . message
334+ end
335+ raise e
312336 ensure
313337 setDebugCookie ( debugEntries , request . cookie_jar )
314338 end
@@ -319,6 +343,10 @@ def self.getRealOriginalUrl(request)
319343 # Therefore we need this method to be able to access the 'real' original url.
320344 return request . env [ "rack.url_scheme" ] + "://" + request . env [ "HTTP_HOST" ] + request . original_fullpath
321345 end
346+
347+ def self . getRuntime ( )
348+ return RUBY_VERSION . to_s
349+ end
322350 end
323351
324352 class CookieManager
0 commit comments