queueit_knownuserv3 3.6.1 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +4 -4
- data/LICENSE +21 -0
- data/README.md +188 -0
- data/Rakefile +2 -2
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/lib/queueit_knownuserv3/connector_diagnostics.rb +68 -68
- data/lib/queueit_knownuserv3/httpcontext_provider.rb +93 -0
- data/lib/queueit_knownuserv3/integration_config_helpers.rb +297 -272
- data/lib/queueit_knownuserv3/known_user.rb +410 -399
- data/lib/queueit_knownuserv3/models.rb +138 -126
- data/lib/queueit_knownuserv3/queue_url_params.rb +80 -80
- data/lib/queueit_knownuserv3/user_in_queue_service.rb +168 -157
- data/lib/queueit_knownuserv3/user_in_queue_state_cookie_repository.rb +191 -191
- data/lib/queueit_knownuserv3.rb +11 -10
- data/queueit_knownuserv3.gemspec +28 -28
- metadata +10 -16
- data/.devcontainer/Dockerfile +0 -43
- data/.devcontainer/devcontainer.json +0 -30
- data/.gitignore +0 -5
- data/.vscode/launch.json +0 -15
- data/ci-build.yml +0 -17
- data/license.txt +0 -165
@@ -1,399 +1,410 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
module QueueIt
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
debugEntries["
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
debugEntries.
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
cookieManager
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
queueConfig
|
295
|
-
queueConfig.
|
296
|
-
queueConfig.
|
297
|
-
queueConfig.
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
end
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
end
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
1
|
+
require 'cgi'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module QueueIt
|
5
|
+
|
6
|
+
class KnownUser
|
7
|
+
QUEUEIT_TOKEN_KEY = "queueittoken"
|
8
|
+
QUEUEIT_DEBUG_KEY = "queueitdebug"
|
9
|
+
QUEUEIT_AJAX_HEADER_KEY = "x-queueit-ajaxpageurl"
|
10
|
+
|
11
|
+
@@userInQueueService = nil
|
12
|
+
def self.getUserInQueueService()
|
13
|
+
if (@@userInQueueService == nil)
|
14
|
+
return UserInQueueService.new(UserInQueueStateCookieRepository.new(HttpContextProvider.httpContext.cookieManager))
|
15
|
+
end
|
16
|
+
|
17
|
+
return @@userInQueueService
|
18
|
+
end
|
19
|
+
private_class_method :getUserInQueueService
|
20
|
+
|
21
|
+
def self.isQueueAjaxCall
|
22
|
+
headers = HttpContextProvider.httpContext.headers
|
23
|
+
return headers[QUEUEIT_AJAX_HEADER_KEY] != nil
|
24
|
+
end
|
25
|
+
private_class_method :isQueueAjaxCall
|
26
|
+
|
27
|
+
def self.generateTargetUrl(originalTargetUrl)
|
28
|
+
unless isQueueAjaxCall()
|
29
|
+
return originalTargetUrl
|
30
|
+
end
|
31
|
+
headers = HttpContextProvider.httpContext.headers
|
32
|
+
return CGI::unescape(headers[QUEUEIT_AJAX_HEADER_KEY])
|
33
|
+
end
|
34
|
+
private_class_method :generateTargetUrl
|
35
|
+
|
36
|
+
def self.convertToInt(value)
|
37
|
+
begin
|
38
|
+
converted = Integer(value)
|
39
|
+
rescue
|
40
|
+
converted = 0
|
41
|
+
end
|
42
|
+
return converted
|
43
|
+
end
|
44
|
+
private_class_method :convertToInt
|
45
|
+
|
46
|
+
def self.logMoreRequestDetails(debugEntries)
|
47
|
+
httpContext = HttpContextProvider.httpContext
|
48
|
+
headers = httpContext.headers
|
49
|
+
|
50
|
+
debugEntries["ServerUtcTime"] = Time.now.utc.iso8601
|
51
|
+
debugEntries["RequestIP"] = httpContext.userHostAddress
|
52
|
+
debugEntries["RequestHttpHeader_Via"] = headers["via"]
|
53
|
+
debugEntries["RequestHttpHeader_Forwarded"] = headers["forwarded"]
|
54
|
+
debugEntries["RequestHttpHeader_XForwardedFor"] = headers["x-forwarded-for"]
|
55
|
+
debugEntries["RequestHttpHeader_XForwardedHost"] = headers["x-forwarded-host"]
|
56
|
+
debugEntries["RequestHttpHeader_XForwardedProto"] = headers["x-forwarded-proto"]
|
57
|
+
end
|
58
|
+
private_class_method :logMoreRequestDetails
|
59
|
+
|
60
|
+
def self.setDebugCookie(debugEntries)
|
61
|
+
if(debugEntries == nil || debugEntries.length == 0)
|
62
|
+
return
|
63
|
+
end
|
64
|
+
|
65
|
+
cookieManager = HttpContextProvider.httpContext.cookieManager
|
66
|
+
cookieValue = ''
|
67
|
+
debugEntries.each do |entry|
|
68
|
+
cookieValue << (entry[0].to_s + '=' + entry[1].to_s + '|')
|
69
|
+
end
|
70
|
+
cookieValue = cookieValue.chop # remove trailing char
|
71
|
+
cookieManager.setCookie(QUEUEIT_DEBUG_KEY, cookieValue, nil, nil, false, false)
|
72
|
+
end
|
73
|
+
private_class_method :setDebugCookie
|
74
|
+
|
75
|
+
def self._resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey, debugEntries, isDebug)
|
76
|
+
|
77
|
+
if(isDebug)
|
78
|
+
debugEntries["SdkVersion"] = UserInQueueService::SDK_VERSION
|
79
|
+
debugEntries["Runtime"] = getRuntime()
|
80
|
+
debugEntries["TargetUrl"] = targetUrl
|
81
|
+
debugEntries["QueueitToken"] = queueitToken
|
82
|
+
debugEntries["OriginalUrl"] = getRealOriginalUrl()
|
83
|
+
if(queueConfig == nil)
|
84
|
+
debugEntries["QueueConfig"] = "NULL"
|
85
|
+
else
|
86
|
+
debugEntries["QueueConfig"] = queueConfig.toString()
|
87
|
+
end
|
88
|
+
logMoreRequestDetails(debugEntries)
|
89
|
+
end
|
90
|
+
|
91
|
+
if(Utils.isNilOrEmpty(customerId))
|
92
|
+
raise KnownUserError, "customerId can not be nil or empty."
|
93
|
+
end
|
94
|
+
|
95
|
+
if(Utils.isNilOrEmpty(secretKey))
|
96
|
+
raise KnownUserError, "secretKey can not be nil or empty."
|
97
|
+
end
|
98
|
+
|
99
|
+
if(queueConfig == nil)
|
100
|
+
raise KnownUserError, "queueConfig can not be nil."
|
101
|
+
end
|
102
|
+
|
103
|
+
if(Utils.isNilOrEmpty(queueConfig.eventId))
|
104
|
+
raise KnownUserError, "queueConfig.eventId can not be nil or empty."
|
105
|
+
end
|
106
|
+
|
107
|
+
if(Utils.isNilOrEmpty(queueConfig.queueDomain))
|
108
|
+
raise KnownUserError, "queueConfig.queueDomain can not be nil or empty."
|
109
|
+
end
|
110
|
+
|
111
|
+
minutes = convertToInt(queueConfig.cookieValidityMinute)
|
112
|
+
if(minutes <= 0)
|
113
|
+
raise KnownUserError, "queueConfig.cookieValidityMinute should be integer greater than 0."
|
114
|
+
end
|
115
|
+
|
116
|
+
if(![true, false].include? queueConfig.extendCookieValidity)
|
117
|
+
raise KnownUserError, "queueConfig.extendCookieValidity should be valid boolean."
|
118
|
+
end
|
119
|
+
|
120
|
+
userInQueueService = getUserInQueueService()
|
121
|
+
result = userInQueueService.validateQueueRequest(targetUrl, queueitToken, queueConfig, customerId, secretKey)
|
122
|
+
result.isAjaxResult = isQueueAjaxCall()
|
123
|
+
|
124
|
+
return result
|
125
|
+
end
|
126
|
+
private_class_method :_resolveQueueRequestByLocalConfig
|
127
|
+
|
128
|
+
def self._cancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey, debugEntries, isDebug)
|
129
|
+
targetUrl = generateTargetUrl(targetUrl)
|
130
|
+
|
131
|
+
if(isDebug)
|
132
|
+
debugEntries["SdkVersion"] = UserInQueueService::SDK_VERSION
|
133
|
+
debugEntries["Runtime"] = getRuntime()
|
134
|
+
debugEntries["TargetUrl"] = targetUrl
|
135
|
+
debugEntries["QueueitToken"] = queueitToken
|
136
|
+
debugEntries["OriginalUrl"] = getRealOriginalUrl()
|
137
|
+
if(cancelConfig == nil)
|
138
|
+
debugEntries["CancelConfig"] = "NULL"
|
139
|
+
else
|
140
|
+
debugEntries["CancelConfig"] = cancelConfig.toString()
|
141
|
+
end
|
142
|
+
logMoreRequestDetails(debugEntries)
|
143
|
+
end
|
144
|
+
|
145
|
+
if(Utils.isNilOrEmpty(targetUrl))
|
146
|
+
raise KnownUserError, "targetUrl can not be nil or empty."
|
147
|
+
end
|
148
|
+
|
149
|
+
if(Utils.isNilOrEmpty(customerId))
|
150
|
+
raise KnownUserError, "customerId can not be nil or empty."
|
151
|
+
end
|
152
|
+
|
153
|
+
if(Utils.isNilOrEmpty(secretKey))
|
154
|
+
raise KnownUserError, "secretKey can not be nil or empty."
|
155
|
+
end
|
156
|
+
|
157
|
+
if(cancelConfig == nil)
|
158
|
+
raise KnownUserError, "cancelConfig can not be nil."
|
159
|
+
end
|
160
|
+
|
161
|
+
if(Utils.isNilOrEmpty(cancelConfig.eventId))
|
162
|
+
raise KnownUserError, "cancelConfig.eventId can not be nil or empty."
|
163
|
+
end
|
164
|
+
|
165
|
+
if(Utils.isNilOrEmpty(cancelConfig.queueDomain))
|
166
|
+
raise KnownUserError, "cancelConfig.queueDomain can not be nil or empty."
|
167
|
+
end
|
168
|
+
|
169
|
+
userInQueueService = getUserInQueueService()
|
170
|
+
result = userInQueueService.validateCancelRequest(targetUrl, cancelConfig, customerId, secretKey)
|
171
|
+
result.isAjaxResult = isQueueAjaxCall()
|
172
|
+
|
173
|
+
return result
|
174
|
+
end
|
175
|
+
private_class_method :_cancelRequestByLocalConfig
|
176
|
+
|
177
|
+
def self.extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, isCookieHttpOnly, isCookieSecure, secretKey)
|
178
|
+
if(Utils.isNilOrEmpty(eventId))
|
179
|
+
raise KnownUserError, "eventId can not be nil or empty."
|
180
|
+
end
|
181
|
+
|
182
|
+
if(Utils.isNilOrEmpty(secretKey))
|
183
|
+
raise KnownUserError, "secretKey can not be nil or empty."
|
184
|
+
end
|
185
|
+
|
186
|
+
minutes = convertToInt(cookieValidityMinute)
|
187
|
+
if(minutes <= 0)
|
188
|
+
raise KnownUserError, "cookieValidityMinute should be integer greater than 0."
|
189
|
+
end
|
190
|
+
|
191
|
+
userInQueueService = getUserInQueueService()
|
192
|
+
userInQueueService.extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, isCookieHttpOnly, isCookieSecure, secretKey)
|
193
|
+
end
|
194
|
+
|
195
|
+
def self.resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey)
|
196
|
+
debugEntries = Hash.new
|
197
|
+
connectorDiagnostics = ConnectorDiagnostics.verify(customerId, secretKey, queueitToken)
|
198
|
+
|
199
|
+
if(connectorDiagnostics.hasError)
|
200
|
+
return connectorDiagnostics.validationResult
|
201
|
+
end
|
202
|
+
begin
|
203
|
+
targetUrl = generateTargetUrl(targetUrl)
|
204
|
+
return _resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey, debugEntries, connectorDiagnostics.isEnabled)
|
205
|
+
rescue Exception => e
|
206
|
+
if(connectorDiagnostics.isEnabled)
|
207
|
+
debugEntries["Exception"] = e.message
|
208
|
+
end
|
209
|
+
raise e
|
210
|
+
ensure
|
211
|
+
setDebugCookie(debugEntries)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def self.validateRequestByIntegrationConfig(currentUrlWithoutQueueITToken, queueitToken, integrationConfigJson, customerId, secretKey)
|
216
|
+
debugEntries = Hash.new
|
217
|
+
customerIntegration = Hash.new
|
218
|
+
connectorDiagnostics = ConnectorDiagnostics.verify(customerId, secretKey, queueitToken)
|
219
|
+
|
220
|
+
if(connectorDiagnostics.hasError)
|
221
|
+
return connectorDiagnostics.validationResult
|
222
|
+
end
|
223
|
+
begin
|
224
|
+
if(connectorDiagnostics.isEnabled)
|
225
|
+
debugEntries["SdkVersion"] = UserInQueueService::SDK_VERSION
|
226
|
+
debugEntries["Runtime"] = getRuntime()
|
227
|
+
debugEntries["PureUrl"] = currentUrlWithoutQueueITToken
|
228
|
+
debugEntries["QueueitToken"] = queueitToken
|
229
|
+
debugEntries["OriginalUrl"] = getRealOriginalUrl()
|
230
|
+
logMoreRequestDetails(debugEntries)
|
231
|
+
end
|
232
|
+
|
233
|
+
customerIntegration = JSON.parse(integrationConfigJson)
|
234
|
+
|
235
|
+
if(connectorDiagnostics.isEnabled)
|
236
|
+
if(customerIntegration.length != 0 and customerIntegration["Version"] != nil)
|
237
|
+
debugEntries["ConfigVersion"] = customerIntegration["Version"]
|
238
|
+
else
|
239
|
+
debugEntries["ConfigVersion"] = "NULL"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
if(Utils.isNilOrEmpty(currentUrlWithoutQueueITToken))
|
244
|
+
raise KnownUserError, "currentUrlWithoutQueueITToken can not be nil or empty."
|
245
|
+
end
|
246
|
+
|
247
|
+
if(customerIntegration.length == 0 || customerIntegration["Version"] == nil)
|
248
|
+
raise KnownUserError, "integrationConfigJson is not valid json."
|
249
|
+
end
|
250
|
+
|
251
|
+
integrationEvaluator = IntegrationEvaluator.new
|
252
|
+
matchedConfig = integrationEvaluator.getMatchedIntegrationConfig(customerIntegration, currentUrlWithoutQueueITToken, HttpContextProvider.httpContext)
|
253
|
+
|
254
|
+
if(connectorDiagnostics.isEnabled)
|
255
|
+
if(matchedConfig == nil)
|
256
|
+
debugEntries["MatchedConfig"] = "NULL"
|
257
|
+
else
|
258
|
+
debugEntries["MatchedConfig"] = matchedConfig["Name"]
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
if(matchedConfig == nil)
|
263
|
+
return RequestValidationResult.new(nil, nil, nil, nil, nil, nil)
|
264
|
+
end
|
265
|
+
|
266
|
+
# unspecified or 'Queue' specified
|
267
|
+
if(!matchedConfig.key?("ActionType") || Utils.isNilOrEmpty(matchedConfig["ActionType"]) || matchedConfig["ActionType"].eql?(ActionTypes::QUEUE))
|
268
|
+
return handleQueueAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration,
|
269
|
+
customerId, secretKey, matchedConfig, debugEntries, connectorDiagnostics.isEnabled)
|
270
|
+
|
271
|
+
elsif(matchedConfig["ActionType"].eql?(ActionTypes::CANCEL))
|
272
|
+
return handleCancelAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration,
|
273
|
+
customerId, secretKey, matchedConfig, debugEntries, connectorDiagnostics.isEnabled)
|
274
|
+
|
275
|
+
# for all unknown types default to 'Ignore'
|
276
|
+
else
|
277
|
+
userInQueueService = getUserInQueueService()
|
278
|
+
result = userInQueueService.getIgnoreActionResult(matchedConfig["Name"])
|
279
|
+
result.isAjaxResult = isQueueAjaxCall()
|
280
|
+
|
281
|
+
return result
|
282
|
+
end
|
283
|
+
rescue Exception => e
|
284
|
+
if(connectorDiagnostics.isEnabled)
|
285
|
+
debugEntries["Exception"] = e.message
|
286
|
+
end
|
287
|
+
raise e
|
288
|
+
ensure
|
289
|
+
setDebugCookie(debugEntries)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
def self.handleQueueAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration, customerId, secretKey, matchedConfig, debugEntries, isDebug)
|
294
|
+
queueConfig = QueueEventConfig.new
|
295
|
+
queueConfig.eventId = matchedConfig["EventId"]
|
296
|
+
queueConfig.layoutName = matchedConfig["LayoutName"]
|
297
|
+
queueConfig.culture = matchedConfig["Culture"]
|
298
|
+
queueConfig.queueDomain = matchedConfig["QueueDomain"]
|
299
|
+
queueConfig.extendCookieValidity = matchedConfig["ExtendCookieValidity"]
|
300
|
+
queueConfig.cookieValidityMinute = matchedConfig["CookieValidityMinute"]
|
301
|
+
queueConfig.cookieDomain = matchedConfig["CookieDomain"]
|
302
|
+
queueConfig.isCookieHttpOnly = matchedConfig["IsCookieHttpOnly"] || false
|
303
|
+
queueConfig.isCookieSecure = matchedConfig["IsCookieSecure"] || false
|
304
|
+
queueConfig.version = customerIntegration["Version"]
|
305
|
+
queueConfig.actionName = matchedConfig["Name"]
|
306
|
+
|
307
|
+
case matchedConfig["RedirectLogic"]
|
308
|
+
when "ForcedTargetUrl"
|
309
|
+
targetUrl = matchedConfig["ForcedTargetUrl"]
|
310
|
+
when "EventTargetUrl"
|
311
|
+
targetUrl = ''
|
312
|
+
else
|
313
|
+
targetUrl = generateTargetUrl(currentUrlWithoutQueueITToken)
|
314
|
+
end
|
315
|
+
|
316
|
+
return _resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey, debugEntries, isDebug)
|
317
|
+
end
|
318
|
+
|
319
|
+
def self.handleCancelAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration, customerId, secretKey, matchedConfig, debugEntries, isDebug)
|
320
|
+
cancelConfig = CancelEventConfig.new
|
321
|
+
cancelConfig.eventId = matchedConfig["EventId"]
|
322
|
+
cancelConfig.queueDomain = matchedConfig["QueueDomain"]
|
323
|
+
cancelConfig.cookieDomain = matchedConfig["CookieDomain"]
|
324
|
+
cancelConfig.isCookieHttpOnly = matchedConfig["IsCookieHttpOnly"] || false
|
325
|
+
cancelConfig.isCookieSecure = matchedConfig["IsCookieSecure"] || false
|
326
|
+
cancelConfig.version = customerIntegration["Version"]
|
327
|
+
cancelConfig.actionName = matchedConfig["Name"]
|
328
|
+
|
329
|
+
return _cancelRequestByLocalConfig(currentUrlWithoutQueueITToken, queueitToken, cancelConfig, customerId, secretKey, debugEntries, isDebug)
|
330
|
+
end
|
331
|
+
|
332
|
+
def self.cancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey)
|
333
|
+
debugEntries = Hash.new
|
334
|
+
connectorDiagnostics = ConnectorDiagnostics.verify(customerId, secretKey, queueitToken)
|
335
|
+
|
336
|
+
if(connectorDiagnostics.hasError)
|
337
|
+
return connectorDiagnostics.validationResult
|
338
|
+
end
|
339
|
+
begin
|
340
|
+
return _cancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey, debugEntries, connectorDiagnostics.isEnabled)
|
341
|
+
rescue Exception => e
|
342
|
+
if(connectorDiagnostics.isEnabled)
|
343
|
+
debugEntries["Exception"] = e.message
|
344
|
+
end
|
345
|
+
raise e
|
346
|
+
ensure
|
347
|
+
setDebugCookie(debugEntries)
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
def self.getRealOriginalUrl()
|
352
|
+
return HttpContextProvider.httpContext.url
|
353
|
+
# RoR could modify request.original_url if request contains x-forwarded-host/proto http headers.
|
354
|
+
# Therefore we need this method to be able to access the 'real' original url.
|
355
|
+
#return request.env["rack.url_scheme"] + "://" + request.env["HTTP_HOST"] + request.original_fullpath
|
356
|
+
end
|
357
|
+
|
358
|
+
def self.getRuntime()
|
359
|
+
return RUBY_VERSION.to_s
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
class CookieManager
|
364
|
+
@cookies = {}
|
365
|
+
|
366
|
+
def initialize(cookieJar)
|
367
|
+
@cookies = cookieJar
|
368
|
+
end
|
369
|
+
|
370
|
+
def getCookie(name)
|
371
|
+
key = name.to_sym
|
372
|
+
if(!Utils.isNilOrEmpty(@cookies[key]))
|
373
|
+
return @cookies[key]
|
374
|
+
end
|
375
|
+
return nil
|
376
|
+
end
|
377
|
+
|
378
|
+
def setCookie(name, value, expire, domain, isHttpOnly, isSecure)
|
379
|
+
key = name.to_sym
|
380
|
+
noDomain = Utils.isNilOrEmpty(domain)
|
381
|
+
deleteCookie = Utils.isNilOrEmpty(value)
|
382
|
+
noExpire = Utils.isNilOrEmpty(expire)
|
383
|
+
|
384
|
+
if(noDomain)
|
385
|
+
if(deleteCookie)
|
386
|
+
@cookies.delete(key)
|
387
|
+
else
|
388
|
+
if(noExpire)
|
389
|
+
@cookies[key] = { :value => value, :httponly => isHttpOnly, :secure => isSecure }
|
390
|
+
else
|
391
|
+
@cookies[key] = { :value => value, :expires => expire, :httponly => isHttpOnly, :secure => isSecure }
|
392
|
+
end
|
393
|
+
end
|
394
|
+
else
|
395
|
+
if(deleteCookie)
|
396
|
+
@cookies.delete(key, :domain => domain)
|
397
|
+
else
|
398
|
+
if(noExpire)
|
399
|
+
@cookies[key] = { :value => value, :domain => domain, :httponly => isHttpOnly, :secure => isSecure }
|
400
|
+
else
|
401
|
+
@cookies[key] = { :value => value, :expires => expire, :domain => domain, :httponly => isHttpOnly, :secure => isSecure }
|
402
|
+
end
|
403
|
+
end
|
404
|
+
end
|
405
|
+
end
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
|
410
|
+
|