List of usage examples for org.apache.http.cookie ClientCookie MAX_AGE_ATTR
String MAX_AGE_ATTR
To view the source code for org.apache.http.cookie ClientCookie MAX_AGE_ATTR.
Click Source Link
From source file:com.github.tmyroadctfig.icloud4j.json.SerializableClientCookie.java
public SerializableClientCookie(Cookie cookie) { this.name = cookie.getName(); this.value = cookie.getValue(); this.cookieComment = cookie.getComment(); this.cookieDomain = cookie.getDomain(); this.cookieExpiryDate = cookie.getExpiryDate() != null ? cookie.getExpiryDate().getTime() : null; this.cookiePath = cookie.getPath(); this.isSecure = cookie.isSecure(); this.cookieVersion = cookie.getVersion(); if (cookie instanceof ClientCookie) { ClientCookie c = (ClientCookie) cookie; copyAttribute(ClientCookie.COMMENT_ATTR, c); copyAttribute(ClientCookie.COMMENTURL_ATTR, c); copyAttribute(ClientCookie.DISCARD_ATTR, c); copyAttribute(ClientCookie.DOMAIN_ATTR, c); copyAttribute(ClientCookie.EXPIRES_ATTR, c); copyAttribute(ClientCookie.MAX_AGE_ATTR, c); copyAttribute(ClientCookie.PATH_ATTR, c); copyAttribute(ClientCookie.PORT_ATTR, c); copyAttribute(ClientCookie.SECURE_ATTR, c); copyAttribute(ClientCookie.DOMAIN_ATTR, c); }//from ww w . j av a 2s . c o m }
From source file:org.esxx.js.protocol.CookieJar.java
private Scriptable cookieToScriptable(Context cx, Cookie cookie) { Scriptable js = cx.newObject(jsuri); Scriptable raw = cx.newObject(js);//ww w . jav a 2s . c o m js.put("raw", js, raw); setValue(cx, cookie, js, raw, "name", cookie.getName()); setValue(cx, cookie, js, raw, "value", cookie.getValue()); setValue(cx, cookie, js, raw, ClientCookie.COMMENT_ATTR, cookie.getComment()); setValue(cx, cookie, js, raw, ClientCookie.COMMENTURL_ATTR, cookie.getCommentURL()); setValue(cx, cookie, js, raw, ClientCookie.DISCARD_ATTR, null); setValue(cx, cookie, js, raw, ClientCookie.DOMAIN_ATTR, cookie.getDomain()); setValue(cx, cookie, js, raw, ClientCookie.EXPIRES_ATTR, cookie.getExpiryDate()); setValue(cx, cookie, js, raw, ClientCookie.MAX_AGE_ATTR, null); setValue(cx, cookie, js, raw, ClientCookie.PATH_ATTR, cookie.getPath()); setValue(cx, cookie, js, raw, ClientCookie.PORT_ATTR, cookie.getPorts()); setValue(cx, cookie, js, raw, ClientCookie.SECURE_ATTR, cookie.isSecure()); setValue(cx, cookie, js, raw, ClientCookie.VERSION_ATTR, cookie.getVersion()); return js; }
From source file:de.betterform.agent.web.WebUtil.java
private static Vector<BasicClientCookie> saveAsBasicClientCookie(Iterator iterator, Vector<BasicClientCookie> commonsCookies) { while (iterator.hasNext()) { javax.servlet.http.Cookie c = (Cookie) iterator.next(); BasicClientCookie commonsCookie = new BasicClientCookie(c.getName(), c.getValue()); commonsCookie.setDomain(c.getDomain()); commonsCookie.setPath(c.getPath()); commonsCookie.setAttribute(ClientCookie.MAX_AGE_ATTR, Integer.toString(c.getMaxAge())); commonsCookie.setSecure(c.getSecure()); commonsCookies.add(commonsCookie); if (WebUtil.LOGGER.isDebugEnabled()) { WebUtil.LOGGER.debug("adding cookie >>>>>"); WebUtil.LOGGER.debug("name: " + c.getName()); WebUtil.LOGGER.debug("value: " + c.getValue()); WebUtil.LOGGER.debug("path: " + c.getPath()); WebUtil.LOGGER.debug("maxAge: " + c.getMaxAge()); WebUtil.LOGGER.debug("secure: " + c.getSecure()); WebUtil.LOGGER.debug("adding cookie done <<<<<"); }/*from www. j a v a 2 s.c o m*/ } return commonsCookies; }
From source file:org.esxx.js.protocol.CookieJar.java
private Cookie scriptableToCookie(Context cx, Scriptable js) { String name = Context.toString(js.get("name", js)); String value = Context.toString(js.get("value", js)); Object raw = js.get("raw", js); BasicClientCookie cookie;/*w ww. ja v a 2 s . c o m*/ if (js.has(ClientCookie.COMMENTURL_ATTR, js) || js.has(ClientCookie.DISCARD_ATTR, js) || js.has(ClientCookie.PORT_ATTR, js)) { BasicClientCookie2 cookie2 = new BasicClientCookie2(name, value); cookie2.setCommentURL(stringValue(cx, js, raw, cookie2, ClientCookie.COMMENTURL_ATTR)); cookie2.setDiscard(booleanValue(cx, js, raw, cookie2, ClientCookie.DISCARD_ATTR)); cookie2.setPorts(intArrayValue(cx, js, raw, cookie2, ClientCookie.PORT_ATTR)); cookie = cookie2; } else { cookie = new BasicClientCookie(name, value); } cookie.setComment(stringValue(cx, js, raw, cookie, ClientCookie.COMMENT_ATTR)); cookie.setDomain(stringValue(cx, js, raw, cookie, ClientCookie.DOMAIN_ATTR)); cookie.setExpiryDate(dateValue(cx, js, raw, cookie, ClientCookie.EXPIRES_ATTR)); cookie.setPath(stringValue(cx, js, raw, cookie, ClientCookie.PATH_ATTR)); cookie.setSecure(booleanValue(cx, js, raw, cookie, ClientCookie.SECURE_ATTR)); cookie.setVersion(intValue(cx, js, raw, cookie, ClientCookie.VERSION_ATTR)); setRawValue(raw, cookie, ClientCookie.MAX_AGE_ATTR); return cookie; }
From source file:com.nesscomputing.httpclient.factory.httpclient4.ApacheHttpClient4Factory.java
private <T> void contributeCookies(final DefaultHttpClient httpClient, final HttpClientRequest<T> httpClientRequest) { final List<Cookie> cookies = httpClientRequest.getCookies(); if (CollectionUtils.isNotEmpty(cookies)) { final CookieStore cookieStore = new BasicCookieStore(); for (final Cookie cookie : cookies) { final BasicClientCookie httpCookie = new BasicClientCookie(cookie.getName(), cookie.getValue()); final int maxAge = cookie.getMaxAge(); if (maxAge > 0) { final Date expire = new Date(System.currentTimeMillis() + maxAge * 1000L); httpCookie.setExpiryDate(expire); httpCookie.setAttribute(ClientCookie.MAX_AGE_ATTR, Integer.toString(maxAge)); }//from ww w .j a v a 2 s. c om httpCookie.setVersion(1); httpCookie.setPath(cookie.getPath()); httpCookie.setDomain(cookie.getDomain()); httpCookie.setSecure(cookie.getSecure()); LOG.debug("Adding cookie to the request: '%s'", httpCookie); cookieStore.addCookie(httpCookie); } httpClient.setCookieStore(cookieStore); } else { LOG.debug("No cookies found."); httpClient.setCookieStore(null); } }