use of com.laytonsmith.PureUtilities.Web.CookieJar in project CommandHelper by EngineHub.
the class Web method getCookieJar.
private static CookieJar getCookieJar(CArray cookieJar, Target t) {
CookieJar ret = new CookieJar();
for (String key : cookieJar.stringKeySet()) {
CArray cookie = Static.getArray(cookieJar.get(key, t), t);
String name;
String value;
String domain;
String path;
long expiration = 0;
boolean httpOnly = false;
boolean secureOnly = false;
if (cookie.containsKey("name") && cookie.containsKey("value") && cookie.containsKey("domain") && cookie.containsKey("path")) {
name = cookie.get("name", t).val();
value = cookie.get("value", t).val();
domain = cookie.get("domain", t).val();
path = cookie.get("path", t).val();
} else {
throw new CREFormatException("The name, value, domain, and path keys are required" + " in all cookies.", t);
}
if (cookie.containsKey("expiration")) {
expiration = Static.getInt(cookie.get("expiration", t), t);
}
if (cookie.containsKey("httpOnly")) {
httpOnly = Static.getBoolean(cookie.get("httpOnly", t), t);
}
if (cookie.containsKey("secureOnly")) {
secureOnly = Static.getBoolean(cookie.get("secureOnly", t), t);
}
Cookie c = new Cookie(name, value, domain, path, expiration, httpOnly, secureOnly);
ret.addCookie(c);
}
return ret;
}
Aggregations