List of usage examples for org.apache.http.impl.cookie BasicClientCookie setComment
public void setComment(final String comment)
From source file:org.springframework.test.web.servlet.htmlunit.MockWebResponseBuilder.java
static com.gargoylesoftware.htmlunit.util.Cookie createCookie(Cookie cookie) { Date expires = null;/*from w w w . j av a 2 s. c o m*/ if (cookie.getMaxAge() > -1) { expires = new Date(System.currentTimeMillis() + cookie.getMaxAge() * 1000); } BasicClientCookie result = new BasicClientCookie(cookie.getName(), cookie.getValue()); result.setDomain(cookie.getDomain()); result.setComment(cookie.getComment()); result.setExpiryDate(expires); result.setPath(cookie.getPath()); result.setSecure(cookie.getSecure()); if (cookie.isHttpOnly()) { result.setAttribute("httponly", "true"); } return new com.gargoylesoftware.htmlunit.util.Cookie(result); }
From source file:org.springframework.test.web.servlet.htmlunit.MockMvcWebConnection.java
private static com.gargoylesoftware.htmlunit.util.Cookie createCookie(javax.servlet.http.Cookie cookie) { Date expires = null;/*from w w w. j av a2 s . com*/ if (cookie.getMaxAge() > -1) { expires = new Date(System.currentTimeMillis() + cookie.getMaxAge() * 1000); } BasicClientCookie result = new BasicClientCookie(cookie.getName(), cookie.getValue()); result.setDomain(cookie.getDomain()); result.setComment(cookie.getComment()); result.setExpiryDate(expires); result.setPath(cookie.getPath()); result.setSecure(cookie.getSecure()); if (cookie.isHttpOnly()) { result.setAttribute("httponly", "true"); } return new com.gargoylesoftware.htmlunit.util.Cookie(result); }
From source file:cn.ttyhuo.common.MyApplication.java
public static void setUpPersistentCookieStore() { if (context == null) return;/*w w w . j av a 2 s.c om*/ cookieStore = new PersistentCookieStore(context); CookieStore httpCookieStore = HttpRequestUtil.cookieManager.getCookieStore(); for (HttpCookie h : httpCookieStore.getCookies()) { BasicClientCookie newCookie = new BasicClientCookie(h.getName(), h.getValue()); newCookie.setVersion(h.getVersion()); newCookie.setDomain(h.getDomain()); newCookie.setPath(h.getPath()); newCookie.setSecure(h.getSecure()); newCookie.setComment(h.getComment()); cookieStore.addCookie(newCookie); } }
From source file:com.blazeroni.reddit.http.SerializableCookie.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { String name = (String) in.readObject(); String value = (String) in.readObject(); BasicClientCookie c = new BasicClientCookie(name, value); c.setComment((String) in.readObject()); c.setDomain((String) in.readObject()); c.setExpiryDate((Date) in.readObject()); c.setPath((String) in.readObject()); c.setVersion(in.readInt());//from w w w.j av a 2s .c o m c.setSecure(in.readBoolean()); this.cookie = c; }
From source file:com.lillicoder.newsblurry.net.SerializableCookie.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // Read all values from write operation in order. String comment = (String) in.readObject(); String domain = (String) in.readObject(); Date expiryDate = (Date) in.readObject(); String name = (String) in.readObject(); String path = (String) in.readObject(); String value = (String) in.readObject(); int version = in.readInt(); boolean isSecure = in.readBoolean(); // Create a new basic cookie and set this wrapper's cookie instance. BasicClientCookie cookie = new BasicClientCookie(name, value); cookie.setComment(comment); cookie.setDomain(domain);/*w w w . j a va2s . c o m*/ cookie.setExpiryDate(expiryDate); cookie.setPath(path); cookie.setValue(value); cookie.setVersion(version); cookie.setSecure(isSecure); this.setCookie(cookie); }
From source file:com.subgraph.vega.ui.scanner.ScanExecutor.java
private List<Cookie> getCookieList(List<String> cookieStringList, URI uri) { if (cookieStringList.size() != 0) { ArrayList<Cookie> cookieList = new ArrayList<Cookie>(cookieStringList.size()); for (String cookieString : cookieStringList) { List<HttpCookie> parseList = HttpCookie.parse(cookieString); for (HttpCookie cookie : parseList) { BasicClientCookie cp = new BasicClientCookie(cookie.getName(), cookie.getValue()); cp.setComment(cookie.getComment()); if (cookie.getDomain() != null) { cp.setDomain(cookie.getDomain()); } else { // just set it to the target host for now - may need something slightly less specific cp.setDomain(uri.getHost()); }//from w w w. j a v a2 s. c o m long maxAge = cookie.getMaxAge(); if (maxAge > 0) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.SECOND, (int) maxAge); cp.setExpiryDate(calendar.getTime()); } cp.setPath(cookie.getPath()); cp.setSecure(cookie.getSecure()); cp.setVersion(cookie.getVersion()); cookieList.add(cp); } } return cookieList; } return null; }
From source file:org.mobicents.servlet.sip.restcomm.dao.mybatis.MybatisHttpCookiesDao.java
private Cookie toCookie(final Map<String, Object> map) { final String comment = readString(map.get("comment")); final String domain = readString(map.get("domain")); final Date expirationDate = (Date) map.get("expiration_date"); final String name = readString(map.get("name")); final String path = readString(map.get("path")); final String value = readString(map.get("value")); final int version = readInteger(map.get("version")); final BasicClientCookie cookie = new BasicClientCookie(name, value); cookie.setComment(comment); cookie.setDomain(domain);//www .ja v a2s. c om cookie.setExpiryDate(expirationDate); cookie.setPath(path); cookie.setVersion(version); return cookie; }
From source file:org.restcomm.connect.dao.mybatis.MybatisHttpCookiesDao.java
private Cookie toCookie(final Map<String, Object> map) { final String comment = DaoUtils.readString(map.get("comment")); final String domain = DaoUtils.readString(map.get("domain")); final Date expirationDate = (Date) map.get("expiration_date"); final String name = DaoUtils.readString(map.get("name")); final String path = DaoUtils.readString(map.get("path")); final String value = DaoUtils.readString(map.get("value")); final int version = DaoUtils.readInteger(map.get("version")); final BasicClientCookie cookie = new BasicClientCookie(name, value); cookie.setComment(comment); cookie.setDomain(domain);/*from w w w. j ava 2 s. c om*/ cookie.setExpiryDate(expirationDate); cookie.setPath(path); cookie.setVersion(version); return cookie; }
From source file:com.akop.bach.util.SerializableCookie.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { nullMask = in.readInt();//ww w. ja v a 2s . c o m String name = null; String value = null; String comment = null; //String commentURL = null; Date expiryDate = null; //boolean isPersistent = false; String domain = null; String path = null; int[] ports = null; boolean isSecure = false; int version = 0; if ((nullMask & NAME) == 0) name = in.readUTF(); if ((nullMask & VALUE) == 0) value = in.readUTF(); if ((nullMask & COMMENT) == 0) comment = in.readUTF(); if ((nullMask & COMMENT_URL) == 0) //commentURL = in.readUTF(); if ((nullMask & EXPIRY_DATE) == 0) expiryDate = new Date(in.readLong()); //isPersistent = in.readBoolean(); if ((nullMask & DOMAIN) == 0) domain = in.readUTF(); if ((nullMask & PATH) == 0) path = in.readUTF(); if ((nullMask & PORTS) == 0) { final int len = in.readInt(); if (len < 10) { ports = new int[len]; for (int i = 0; i < len; i++) ports[i] = in.readInt(); } } isSecure = in.readBoolean(); version = in.readInt(); final BasicClientCookie bc = new BasicClientCookie(name, value); bc.setComment(comment); bc.setDomain(domain); bc.setExpiryDate(expiryDate); bc.setPath(path); bc.setSecure(isSecure); bc.setVersion(version); this.cookie = bc; }
From source file:ti.modules.titanium.network.TiCookieStore.java
private Cookie decodeCookie(String cookieString) { byte[] cookieBytes = hexStringToByteArray(cookieString); ByteArrayInputStream inputStream = new ByteArrayInputStream(cookieBytes); BasicClientCookie cookie = null; try {//from w w w . j a va 2 s . c o m ObjectInputStream objectInputStream = new ObjectInputStream(inputStream); String name = (String) objectInputStream.readObject(); String value = (String) objectInputStream.readObject(); cookie = new BasicClientCookie(name, value); cookie.setComment((String) objectInputStream.readObject()); cookie.setDomain((String) objectInputStream.readObject()); cookie.setVersion(objectInputStream.readInt()); cookie.setSecure(objectInputStream.readBoolean()); cookie.setExpiryDate((Date) objectInputStream.readObject()); cookie.setPath((String) objectInputStream.readObject()); } catch (Exception e) { Log.w(TAG, "Failed to decode cookie", Log.DEBUG_MODE); return null; } return cookie; }