List of usage examples for org.apache.http.cookie Cookie getCommentURL
String getCommentURL();
From source file:fr.mixit.android.utils.NetworkUtils.java
static Cookie getCookie(DefaultHttpClient httpClient) { Cookie c = null;/*from w w w . ja v a2 s .c o m*/ for (final Cookie cookie : httpClient.getCookieStore().getCookies()) { if (cookie != null) { c = cookie; if (DEBUG_MODE) { Log.i("AppInfosFragment", "cookieInfos : "// + "comment:" + cookie.getComment() + // " commentURL:" + cookie.getCommentURL() + // " domain:" + cookie.getDomain() + // " name:" + cookie.getName() + // " path:" + cookie.getPath() + // " value:" + cookie.getValue() + // " version:" + cookie.getVersion() + // " expiryDate:" + cookie.getExpiryDate()); } } } return c; }
From source file:net.fizzl.redditengine.impl.SerializableCookie.java
public SerializableCookie(Cookie cookie) { this.comment = cookie.getComment(); this.commentURL = cookie.getCommentURL(); this.domain = cookie.getDomain(); this.expiryDate = cookie.getExpiryDate(); this.name = cookie.getName(); this.path = cookie.getPath(); this.ports = cookie.getPorts(); this.value = cookie.getValue(); this.version = cookie.getVersion(); this.secure = cookie.isSecure(); }
From source file:com.google.corp.productivity.specialprojects.android.comm.SerializableCookieStore.java
public synchronized void save(SharedPreferences preferences) { List<Cookie> cookies = getCookies(); int n = cookies.size(); JSONArray array = new JSONArray(); for (int i = 0; i < n; i++) { Cookie cookie = cookies.get(i); putJs(array, i, ATTR_NAME, cookie.getName()); putJs(array, i, ATTR_VALUE, cookie.getValue()); putJs(array, i, ATTR_COMMENT, cookie.getComment()); putJs(array, i, ATTR_COMMENT_URL, cookie.getCommentURL()); putJs(array, i, ATTR_DOMAIN, cookie.getDomain()); putJs(array, i, ATTR_PATH, cookie.getPath()); putJs(array, i, ATTR_VERSION, cookie.getVersion()); putJs(array, i, ATTR_SECURE, cookie.isSecure()); putJs(array, i, ATTR_PORTS, cookie.getPorts()); if (cookie.getExpiryDate() != null) { putJs(array, i, ATTR_EXPIRY_DATE, cookie.getExpiryDate().getTime()); }/*from w ww. ja va 2 s .c om*/ } Editor editor = preferences.edit(); editor.putString(UserPreferences.COOKIE_PREFERENCE_KEY, array.toString()); editor.commit(); dirty = false; }
From source file:org.archive.modules.fetcher.BdbCookieStoreTest.java
protected void assertCookiesIdentical(Cookie c1, Cookie c2) { assertEquals(c1.getComment(), c2.getComment()); assertEquals(c1.getCommentURL(), c2.getCommentURL()); assertEquals(c1.getDomain(), c2.getDomain()); assertEquals(c1.getName(), c2.getName()); String p1 = c1.getPath() != null ? c1.getPath() : "/"; String p2 = c2.getPath() != null ? c2.getPath() : "/"; assertEquals(p1, p2);//from w ww . j a v a2 s .c om assertEquals(c1.getValue(), c2.getValue()); assertEquals(c1.getVersion(), c2.getVersion()); assertEquals(c1.getExpiryDate(), c2.getExpiryDate()); assertTrue(Arrays.equals(c1.getPorts(), c2.getPorts())); }
From source file:com.google.sampling.experiential.android.lib.GoogleAccountLoginHelper.java
/** * Store a new Paco AppEngine server cookie. * This will only be used publicly when the other communications with the Paco server send us * back a new cookie instead of the existing cookie. * /*from w ww .ja v a 2 s.c o m*/ * @param authCookie Cookie from logging into Paco AppEngine instance. */ public synchronized void storePacoAuthCookie(Cookie authCookie) { Editor editor = authTokenPreferences.edit(); editor.putString("comment", authCookie.getComment()); editor.putString("commentURL", authCookie.getCommentURL()); editor.putString("domain", authCookie.getDomain()); editor.putString("name", authCookie.getName()); editor.putString("path", authCookie.getPath()); editor.putString("value", authCookie.getValue()); SimpleDateFormat df = new SimpleDateFormat(Constants.DATE_TIME_FORMAT); editor.putString("expiration", df.format(authCookie.getExpiryDate())); if (authCookie.getPorts() != null) { editor.putString("ports", stringify(authCookie.getPorts())); } editor.putInt("version", authCookie.getVersion()); editor.commit(); }
From source file:org.tellervo.desktop.wsi.util.WSCookieWrapper.java
public WSCookieWrapper(Cookie cookie) { name = cookie.getName();//from w ww. ja v a 2 s .co m value = cookie.getValue(); cookieComment = cookie.getComment(); cookieDomain = cookie.getDomain(); cookieExpiryDate = cookie.getExpiryDate(); cookiePath = cookie.getPath(); isSecure = cookie.isSecure(); cookieVersion = cookie.getVersion(); commentURL = cookie.getCommentURL(); ports = cookie.getPorts(); /* if(cookie instanceof ClientCookie) { isClientCookie = true; // copy over the attributes array (yuck) attribs = new HashMap<String, String>(); for(String attr : ATTR_LIST) { String value; if((value = ((ClientCookie)cookie).getAttribute(attr)) != null) { attribs.put(attr, value); } } } */ }
From source file:org.tellervo.desktop.wsi.util.WSCookieWrapper.java
@Override public boolean equals(Object o) { if (o instanceof WSCookieWrapper) { WSCookieWrapper w = (WSCookieWrapper) o; return (iseq(name, w.name) && iseq(attribs, w.attribs) && iseq(value, w.value) && iseq(cookieComment, w.cookieComment) && iseq(cookieDomain, w.cookieDomain) && iseq(cookiePath, w.cookiePath) && iseq(isSecure, w.isSecure) && iseq(cookieVersion, w.cookieVersion) && iseq(commentURL, w.commentURL) && iseq(ports, w.ports)); }//from ww w .j a v a 2s .c o m if (o instanceof Cookie) { Cookie c = (Cookie) o; boolean match; match = iseq(name, c.getName()) && iseq(value, c.getValue()) && iseq(cookieComment, c.getComment()) && iseq(cookieDomain, c.getDomain()) && iseq(cookiePath, c.getPath()) && iseq(isSecure, c.isSecure()) && iseq(cookieVersion, c.getVersion()) && iseq(commentURL, c.getCommentURL()) && iseq(ports, c.getPorts()); if (!match) return false; /* if(c instanceof ClientCookie) { ClientCookie cc = (ClientCookie) c; for(String attr : ATTR_LIST) { if(!iseq(attribs.get(attr), cc.getAttribute(attr))) return false; } } */ return true; } return false; }
From source file:com.ruuhkis.cookies.CookieSQLSource.java
/** * Updates cookie if it already exists else adds new cookie tot the table * @param cookie/*from w w w .ja va 2 s . com*/ */ public void addCookie(Cookie cookie) { long cookieId = -1; Cursor cursor = db.query(CookieSQLHelper.COOKIE_TABLE_NAME, null, CookieSQLHelper.COLUMN_NAME + "=?", new String[] { cookie.getName() }, null, null, null); ContentValues cookieValues = new ContentValues(); cookieValues.put(CookieSQLHelper.COLUMN_COMMENT, cookie.getComment()); cookieValues.put(CookieSQLHelper.COLUMN_COMMENT_URL, cookie.getCommentURL()); cookieValues.put(CookieSQLHelper.COLUMN_DOMAIN, cookie.getDomain()); Date date = cookie.getExpiryDate(); cookieValues.put(CookieSQLHelper.COLUMN_EXPIRY_DATE, date != null ? date.getTime() : -1); cookieValues.put(CookieSQLHelper.COLUMN_NAME, cookie.getName()); cookieValues.put(CookieSQLHelper.COLUMN_PATH, cookie.getPath()); cookieValues.put(CookieSQLHelper.COLUMN_PERSISTENT, cookie.isPersistent() ? 1 : 0); cookieValues.put(CookieSQLHelper.COLUMN_SECURE, cookie.isSecure() ? 1 : 0); cookieValues.put(CookieSQLHelper.COLUMN_VALUE, cookie.getValue()); cookieValues.put(CookieSQLHelper.COLUMN_VERSION, cookie.getVersion()); if (cursor.moveToFirst()) { cookieId = cursor.getLong(cursor.getColumnIndex(CookieSQLHelper.COLUMN_COOKIE_ID)); db.update(CookieSQLHelper.COOKIE_TABLE_NAME, cookieValues, CookieSQLHelper.COLUMN_ID + "=?", new String[] { Long.toString(cookieId) }); db.delete(CookieSQLHelper.PORT_TABLE_NAME, CookieSQLHelper.COLUMN_COOKIE_ID + "=?", new String[] { Long.toString(cookieId) }); } else { cookieId = db.insert(CookieSQLHelper.COOKIE_TABLE_NAME, null, cookieValues); } if (cookieId != -1) { int[] ports = cookie.getPorts(); if (ports != null) { for (int i = 0; i < ports.length; i++) { ContentValues portValues = new ContentValues(); portValues.put(CookieSQLHelper.COLUMN_COOKIE_ID, cookieId); portValues.put(CookieSQLHelper.COLUMN_PORT, ports[i]); db.insert(CookieSQLHelper.PORT_TABLE_NAME, null, portValues); } } } else { Log.e(TAG, "id = -1"); } cursor.close(); }
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. j ava 2 s.c om 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:org.apache.manifoldcf.crawler.connectors.webcrawler.CookieManager.java
/** Update cookes that are in effect for a given session key. *@param sessionKey is the session key./*ww w.j a v a 2 s .co m*/ *@param cookies are the cookies to write into the database. */ public void updateCookies(String sessionKey, LoginCookies cookies) throws ManifoldCFException { StringSetBuffer ssb = new StringSetBuffer(); ssb.add(getCookiesCacheKey(sessionKey)); StringSet cacheKeys = new StringSet(ssb); ICacheHandle ch = cacheManager.enterCache(null, cacheKeys, getTransactionID()); try { beginTransaction(); try { // Delete any old cookies, and create new ones ArrayList list = new ArrayList(); list.add(sessionKey); performDelete("WHERE " + keyField + "=?", list, null); // Now, insert the new cookies int i = 0; while (i < cookies.getCookieCount()) { Cookie c = cookies.getCookie(i); HashMap map = new HashMap(); map.put(keyField, sessionKey); map.put(ordinalField, new Long(i)); String domain = c.getDomain(); if (domain != null && domain.length() > 0) map.put(domainField, domain); map.put(domainSpecifiedField, booleanToString(domain != null && domain.length() > 0)); String name = c.getName(); if (name != null && name.length() > 0) map.put(nameField, name); String value = c.getValue(); if (value != null && value.length() > 0) map.put(valueField, value); String path = c.getPath(); if (path != null && path.length() > 0) map.put(pathField, path); map.put(pathSpecifiedField, booleanToString(path != null && path.length() > 0)); map.put(versionField, new Long(c.getVersion())); // Make something up. It may not be correct, but there's really no choice. map.put(versionSpecifiedField, booleanToString(true)); String comment = c.getComment(); if (comment != null && comment.length() > 0) map.put(commentField, comment); map.put(secureField, booleanToString(c.isSecure())); Date expirationDate = c.getExpiryDate(); if (expirationDate != null) map.put(expirationDateField, new Long(expirationDate.getTime())); //map.put(discardField,booleanToString(!c.isPersistent())); map.put(discardField, booleanToString(false)); String commentURL = c.getCommentURL(); if (commentURL != null && commentURL.length() > 0) map.put(commentURLField, commentURL); int[] ports = c.getPorts(); if (ports != null && ports.length > 0) map.put(portField, portsToString(ports)); map.put(portBlankField, booleanToString(ports == null || ports.length == 0)); map.put(portSpecifiedField, booleanToString(ports != null && ports.length > 0)); performInsert(map, null); i++; } cacheManager.invalidateKeys(ch); } catch (ManifoldCFException e) { signalRollback(); throw e; } catch (Error e) { signalRollback(); throw e; } finally { endTransaction(); } } finally { cacheManager.leaveCache(ch); } }