use of com.adobe.target.edge.client.model.TargetCookie in project target-java-sdk by adobe.
the class TargetTestDeliveryRequestUtils method getTestCookies.
public static List<TargetCookie> getTestCookies() {
int timeNow = (int) (System.currentTimeMillis() / 1000);
Optional<TargetCookie> targetCookie = CookieUtils.createTargetCookie(TEST_SESSION_ID, TEST_TNT_ID);
String visitorValue = "-1330315163%7CMCIDTS%7C18145%7CMCMID%7C" + TargetDeliveryRequestTest.TEST_MCID + "%7CMCAAMLH-1567731426%7C9%7CMCAAMB-1568280923%7CRKhpRz8krg2tLO6pguXWp5olkAcUniQYPHaMWWgdJ3xz" + "PWQmdj0y%7CMCOPTOUT-1567683323s%7CNONE%7CMCAID%7CNONE%7CMCCIDH%7C1806392961";
TargetCookie visitorCookie = null;
try {
visitorCookie = new TargetCookie("AMCV_" + URLEncoder.encode(TEST_ORG_ID, "UTF-8"), visitorValue, timeNow + SESSION_ID_COOKIE_MAX_AGE);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
List<TargetCookie> cookies = new ArrayList<>();
Collections.addAll(cookies, targetCookie.get(), visitorCookie);
return cookies;
}
use of com.adobe.target.edge.client.model.TargetCookie in project target-java-sdk by adobe.
the class CookieUtils method getSessionId.
public static String getSessionId(final Map<String, TargetCookie> parseCookies) {
final TargetCookie cookie = parseCookies.get(SESSION_ID_COOKIE_NAME);
String sessionId;
if (cookie != null && !isEmpty(cookie.getValue())) {
sessionId = cookie.getValue();
} else {
sessionId = UUID.randomUUID().toString().replaceAll("-", "");
}
return sessionId;
}
use of com.adobe.target.edge.client.model.TargetCookie in project target-java-sdk by adobe.
the class CookieUtils method createTargetCookie.
public static Optional<TargetCookie> createTargetCookie(String sessionId, String deviceId) {
final int nowInSeconds = getNowInSeconds();
final StringBuilder targetCookieValue = new StringBuilder();
int expires = 0;
expires = createSessionId(sessionId, nowInSeconds, targetCookieValue, expires);
expires = createDeviceId(deviceId, nowInSeconds, targetCookieValue, expires);
TargetCookie targetCookie = null;
String cookieValue = targetCookieValue.toString();
int maxAge = expires == 0 ? 0 : expires - nowInSeconds;
if (isNotEmpty(cookieValue)) {
targetCookie = new TargetCookie(COOKIE_NAME, cookieValue, maxAge);
}
return Optional.ofNullable(targetCookie);
}
use of com.adobe.target.edge.client.model.TargetCookie in project target-java-sdk by adobe.
the class CookieUtils method getDeviceId.
public static String getDeviceId(final Map<String, TargetCookie> parseCookies) {
String returnValue = null;
final TargetCookie cookie = parseCookies.get(DEVICE_ID_COOKIE_NAME);
if (cookie != null) {
returnValue = cookie.getValue();
}
return returnValue;
}
Aggregations