Skip to content

Commit

Permalink
Release 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
frwiqueueit committed Jan 30, 2018
1 parent e46de06 commit 6ff13d4
Show file tree
Hide file tree
Showing 11 changed files with 481 additions and 283 deletions.
14 changes: 7 additions & 7 deletions SDK/src/queueit/knownuserv3/sdk/CancelEventConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public String getEventId() {
public void setEventId(String eventId) {
this.eventId = eventId;
}

public String getQueueDomain() {
return queueDomain;
}
Expand Down Expand Up @@ -42,12 +42,12 @@ public void setVersion(int version) {
public CancelEventConfig() {
this.version = -1;
}

@Override
public String toString() {
return "EventId:" + eventId +
"&Version:" + version +
"&QueueDomain:" + queueDomain +
"&CookieDomain:" + cookieDomain;
return "EventId:" + eventId
+ "&Version:" + version
+ "&QueueDomain:" + queueDomain
+ "&CookieDomain:" + cookieDomain;
}
}
}
2 changes: 1 addition & 1 deletion SDK/src/queueit/knownuserv3/sdk/Constants.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package queueit.knownuserv3.sdk;

final class ActionType {

public static final String CANCEL_ACTION = "Cancel";
public static final String QUEUE_ACTION = "Queue";
public static final String IGNORE_ACTION = "Ignore";
Expand Down
3 changes: 1 addition & 2 deletions SDK/src/queueit/knownuserv3/sdk/KnownUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static RequestValidationResult validateRequestByIntegrationConfig(String
}

if (matchedConfig == null) {
return new RequestValidationResult(null, null, null, null);
return new RequestValidationResult(null, null, null, null, null);
}

// unspecified or 'Queue' specified
Expand Down Expand Up @@ -343,7 +343,6 @@ public void setCookie(String cookieName, String cookieValue, Integer expiration,
cookie.setDomain(cookieDomain);
}

cookie.setHttpOnly(true);
response.addCookie(cookie);
}

Expand Down
18 changes: 9 additions & 9 deletions SDK/src/queueit/knownuserv3/sdk/QueueEventConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ public void setVersion(int version) {
public QueueEventConfig() {
this.version = -1;
}

@Override
public String toString() {
return "EventId:" + eventId +
"&Version:" + version +
"&QueueDomain:" + queueDomain +
"&CookieDomain:" + cookieDomain +
"&ExtendCookieValidity:" + extendCookieValidity +
"&CookieValidityMinute:" + cookieValidityMinute +
"&LayoutName:" + layoutName +
"&Culture:" + culture;
return "EventId:" + eventId
+ "&Version:" + version
+ "&QueueDomain:" + queueDomain
+ "&CookieDomain:" + cookieDomain
+ "&ExtendCookieValidity:" + extendCookieValidity
+ "&CookieValidityMinute:" + cookieValidityMinute
+ "&LayoutName:" + layoutName
+ "&Culture:" + culture;
}
}
34 changes: 17 additions & 17 deletions SDK/src/queueit/knownuserv3/sdk/QueueITHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class QueueParameterHelper {

public static final String TimeStampKey = "ts";
public static final String ExtendableCookieKey = "ce";
public static final String CookieValidityMinuteKey = "cv";
public static final String CookieValidityMinutesKey = "cv";
public static final String HashKey = "h";
public static final String QueueIdKey = "q";
public static final String RedirectTypeKey = "rt";
public static final String EventIdKey = "e";
public static final String EventIdKey = "e";
public static final String KeyValueSeparatorChar = "_";
public static final String KeyValueSeparatorGroupChar = "~";

Expand All @@ -61,11 +61,11 @@ public static QueueUrlParams extractQueueParams(String queueitToken) {
result.setTimeStamp(0);
}
break;
case CookieValidityMinuteKey: {
case CookieValidityMinutesKey: {
if (Utils.isInteger(keyValueArr[1])) {
result.setCookieValidityMinute(Integer.parseInt(keyValueArr[1]));
result.setCookieValidityMinutes(Integer.parseInt(keyValueArr[1]));
} else {
result.setCookieValidityMinute(null);
result.setCookieValidityMinutes(null);
}
break;
}
Expand All @@ -78,7 +78,7 @@ public static QueueUrlParams extractQueueParams(String queueitToken) {
break;
case ExtendableCookieKey:
result.setExtendableCookie(Boolean.parseBoolean(keyValueArr[1]));
break;
break;
case HashKey:
result.setHashCode(keyValueArr[1]);
break;
Expand Down Expand Up @@ -121,22 +121,22 @@ class QueueUrlParams {
private boolean extendableCookie;
private String queueITToken;
private String queueITTokenWithoutHash;
private Integer cookieValidityMinute;
private Integer cookieValidityMinutes;
private long timeStamp;
private String queueId;
private String redirectType;

public QueueUrlParams(){
public QueueUrlParams() {
this.eventId = "";
this.hashCode = "";
this.extendableCookie = false;
this.queueITToken = "";
this.queueITTokenWithoutHash = "";
this.cookieValidityMinute = null;
this.cookieValidityMinutes = null;
this.timeStamp = 0;
this.queueId = "";
}

public String getEventId() {
return this.eventId;
}
Expand All @@ -161,12 +161,12 @@ public void setExtendableCookie(boolean extendableCookie) {
this.extendableCookie = extendableCookie;
}

public Integer getCookieValidityMinute() {
return this.cookieValidityMinute;
public Integer getCookieValidityMinutes() {
return this.cookieValidityMinutes;
}

public void setCookieValidityMinute(Integer cookieValidityMinute) {
this.cookieValidityMinute = cookieValidityMinute;
public void setCookieValidityMinutes(Integer cookieValidityMinute) {
this.cookieValidityMinutes = cookieValidityMinute;
}

public String getQueueITToken() {
Expand Down Expand Up @@ -200,11 +200,11 @@ public void setQueueId(String queueId) {
public String getQueueId() {
return this.queueId;
}
public void setRedirectType(String redirectType) {

public void setRedirectType(String redirectType) {
this.redirectType = redirectType;
}

public String getRedirectType() {
return this.redirectType;
}
Expand Down
10 changes: 8 additions & 2 deletions SDK/src/queueit/knownuserv3/sdk/RequestValidationResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ public class RequestValidationResult {
private String eventId;
private String redirectUrl;
private String queueId;
private String redirectType;

public RequestValidationResult(String actionType, String eventId, String queueId, String redirectUrl) {
public RequestValidationResult(String actionType, String eventId, String queueId, String redirectUrl, String redirectType) {
this.actionType = actionType;
this.eventId = eventId;
this.queueId = queueId;
this.redirectUrl = redirectUrl;
this.redirectType = redirectType;
}

public String getActionType() {
return actionType;
}

public String getEventId() {
return eventId;
}
Expand All @@ -33,6 +35,10 @@ public boolean doRedirect() {
public String getQueueId() {
return this.queueId;
}

public String getRedirectType() {
return this.redirectType;
}
}

class KnowUserException extends Exception {
Expand Down
72 changes: 36 additions & 36 deletions SDK/src/queueit/knownuserv3/sdk/UserInQueueService.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ RequestValidationResult validateCancelRequest(
CancelEventConfig config,
String customerId,
String secretKey) throws Exception;

void extendQueueCookie(
String eventId,
int cookieValidityMinute,
int cookieValidityMinutes,
String cookieDomain,
String secretKey
);

RequestValidationResult getIgnoreActionResult();
}

class UserInQueueService implements IUserInQueueService {

public static final String SDK_VERSION = "3.4.0";
public static final String SDK_VERSION = "3.5.0";
private final IUserInQueueStateRepository _userInQueueStateRepository;

public UserInQueueService(
Expand All @@ -47,17 +47,18 @@ public RequestValidationResult validateQueueRequest(
String customerId,
String secretKey
) throws Exception {
StateInfo stateInfo = this._userInQueueStateRepository.getState(config.getEventId(), secretKey);
StateInfo stateInfo = this._userInQueueStateRepository.getState(config.getEventId(), config.getCookieValidityMinute(), secretKey, true);
if (stateInfo.isValid()) {
if (stateInfo.isStateExtendable() && config.getExtendCookieValidity()) {
this._userInQueueStateRepository.store(config.getEventId(),
this._userInQueueStateRepository.store(
config.getEventId(),
stateInfo.getQueueId(),
true,
null,
config.getCookieDomain(),
config.getCookieValidityMinute(),
stateInfo.getRedirectType(),
secretKey);
}
return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), stateInfo.getQueueId(), null);
return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), stateInfo.getQueueId(), null, stateInfo.getRedirectType());
}

QueueUrlParams queueParmas = QueueParameterHelper.extractQueueParams(queueitToken);
Expand Down Expand Up @@ -92,12 +93,12 @@ private RequestValidationResult getQueueITTokenValidationResult(
this._userInQueueStateRepository.store(
config.getEventId(),
queueParams.getQueueId(),
queueParams.getExtendableCookie(),
queueParams.getCookieValidityMinutes(),
config.getCookieDomain(),
queueParams.getCookieValidityMinute() != null ? queueParams.getCookieValidityMinute() : config.getCookieValidityMinute(),
queueParams.getRedirectType(),
secretKey);

return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), queueParams.getQueueId(), null);
return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), queueParams.getQueueId(), null, queueParams.getRedirectType());
}

private RequestValidationResult getVaidationErrorResult(
Expand All @@ -110,16 +111,15 @@ private RequestValidationResult getVaidationErrorResult(
String query = getQueryString(customerId, config.getEventId(), config.getVersion(), config.getCulture(), config.getLayoutName())
+ "&queueittoken=" + qParams.getQueueITToken()
+ "&ts=" + System.currentTimeMillis() / 1000L;
if(!Utils.isNullOrWhiteSpace(targetUrl))
{
if (!Utils.isNullOrWhiteSpace(targetUrl)) {
query += "&t=" + URLEncoder.encode(targetUrl, "UTF-8");
}
String domainAlias = config.getQueueDomain();
if (!domainAlias.endsWith("/")) {
domainAlias = domainAlias + "/";
}
String redirectUrl = "https://" + domainAlias + "error/" + errorCode + "/?" + query;
return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), null, redirectUrl);
return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), null, redirectUrl, null);
}

private RequestValidationResult getInQueueRedirectResult(
Expand All @@ -129,11 +129,11 @@ private RequestValidationResult getInQueueRedirectResult(

String redirectUrl = "https://" + config.getQueueDomain() + "?"
+ getQueryString(customerId, config.getEventId(), config.getVersion(), config.getCulture(), config.getLayoutName());
if(!Utils.isNullOrWhiteSpace(targetUrl)) {
if (!Utils.isNullOrWhiteSpace(targetUrl)) {
redirectUrl += "&t=" + URLEncoder.encode(targetUrl, "UTF-8");
}
return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), null, redirectUrl);

return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), null, redirectUrl, null);
}

private String getQueryString(
Expand All @@ -158,49 +158,49 @@ private String getQueryString(

return String.join("&", queryStringList);
}

@Override
public void extendQueueCookie(
String eventId,
int cookieValidityMinute,
String cookieDomain,
String secretKey) {
this._userInQueueStateRepository.extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, secretKey);
this._userInQueueStateRepository.reissueQueueCookie(eventId, cookieValidityMinute, cookieDomain, secretKey);
}

@Override
public RequestValidationResult validateCancelRequest(
String targetUrl,
CancelEventConfig config,
String customerId,
String targetUrl,
CancelEventConfig config,
String customerId,
String secretKey) throws Exception {
StateInfo state = _userInQueueStateRepository.getState(config.getEventId(), secretKey);

StateInfo state = _userInQueueStateRepository.getState(config.getEventId(), -1, secretKey, false);

if (state.isValid()) {
this._userInQueueStateRepository.cancelQueueCookie(config.getEventId(), config.getCookieDomain());

String query = getQueryString(customerId, config.getEventId(), config.getVersion(), null, null);
if(targetUrl != null)

if (targetUrl != null) {
query += "&r=" + URLEncoder.encode(targetUrl, "UTF-8");
}

String domainAlias = config.getQueueDomain();
if (!domainAlias.endsWith("/"))
if (!domainAlias.endsWith("/")) {
domainAlias = domainAlias + "/";
}

String redirectUrl = "https://" + domainAlias + "cancel/" + customerId + "/" + config.getEventId() + "/?" + query;

return new RequestValidationResult(ActionType.CANCEL_ACTION, config.getEventId(), state.getQueueId(), redirectUrl);
}
else
{
return new RequestValidationResult(ActionType.CANCEL_ACTION, config.getEventId(), null, null);
return new RequestValidationResult(ActionType.CANCEL_ACTION, config.getEventId(), state.getQueueId(), redirectUrl, state.getRedirectType());
} else {
return new RequestValidationResult(ActionType.CANCEL_ACTION, config.getEventId(), null, null, null);
}
}

@Override
public RequestValidationResult getIgnoreActionResult() {
return new RequestValidationResult(ActionType.IGNORE_ACTION, null, null, null);
return new RequestValidationResult(ActionType.IGNORE_ACTION, null, null, null, null);
}
}
Loading

0 comments on commit 6ff13d4

Please sign in to comment.