Example usage for org.apache.http.impl.cookie BasicClientCookie2 setCommentURL

List of usage examples for org.apache.http.impl.cookie BasicClientCookie2 setCommentURL

Introduction

In this page you can find the example usage for org.apache.http.impl.cookie BasicClientCookie2 setCommentURL.

Prototype

public void setCommentURL(final String commentURL) 

Source Link

Usage

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;//from   ww  w. j  ava  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.google.corp.productivity.specialprojects.android.comm.SerializableCookieStore.java

public SerializableCookieStore(SharedPreferences preferences) {
    String cookiesString = preferences.getString(UserPreferences.COOKIE_PREFERENCE_KEY, null);
    if (cookiesString != null) {
        try {//from w ww  . j  a  va2s .  co m
            JSONArray cookies = new JSONArray(cookiesString);
            int n = cookies.length();
            for (int i = 0; i < n; i++) {
                JSONObject json = cookies.optJSONObject(i);
                if (!JSONObject.NULL.equals(json)) {
                    BasicClientCookie2 cookie = new BasicClientCookie2(json.optString(ATTR_NAME),
                            json.optString(ATTR_VALUE));
                    if (json.has(ATTR_COMMENT)) {
                        cookie.setComment(json.optString(ATTR_COMMENT));
                    }
                    if (json.has(ATTR_COMMENT_URL)) {
                        cookie.setCommentURL(json.optString(ATTR_COMMENT_URL));
                    }
                    if (json.has(ATTR_DOMAIN)) {
                        cookie.setDomain(json.optString(ATTR_DOMAIN));
                    }
                    if (json.has(ATTR_EXPIRY_DATE)) {
                        cookie.setExpiryDate(new Date(json.optLong(ATTR_EXPIRY_DATE)));
                    }
                    if (json.has(ATTR_PATH)) {
                        cookie.setPath(json.optString(ATTR_PATH));
                    }
                    if (json.has(ATTR_SECURE)) {
                        cookie.setSecure(json.optBoolean(ATTR_SECURE));
                    }
                    if (json.has(ATTR_VERSION)) {
                        cookie.setVersion(json.optInt(ATTR_VERSION));
                    }
                    if (json.has(ATTR_PORTS)) {
                        JSONArray arr = json.optJSONArray(ATTR_PORTS);
                        if (arr != null) {
                            int m = arr.length();
                            int[] ports = new int[m];
                            for (int j = 0; j < m; j++) {
                                ports[j] = arr.optInt(j);
                            }
                            cookie.setPorts(ports);
                        }
                    }
                    super.addCookie(cookie);
                }
            }
        } catch (JSONException x) {
            // Invalid string format, no cookies can be read.
        }
    }
    dirty = false;
}

From source file:org.apache.manifoldcf.crawler.connectors.webcrawler.CookieManager.java

/** Read cookies from database, uncached.
*@param sessionKey is the session key.//w w  w  .  j  a  v  a2 s.c  o m
*@return the login cookies object.
*/
protected LoginCookies readCookiesUncached(String sessionKey) throws ManifoldCFException {
    ArrayList list = new ArrayList();
    list.add(sessionKey);
    IResultSet result = performQuery(
            "SELECT * FROM " + getTableName() + " WHERE " + keyField + "=? ORDER BY " + ordinalField + " ASC",
            list, null, null);
    DynamicCookieSet dcs = new DynamicCookieSet();
    int i = 0;
    while (i < result.getRowCount()) {
        IResultRow row = result.getRow(i++);
        String name = (String) row.getValue(nameField);
        String value = (String) row.getValue(valueField);
        BasicClientCookie2 c = new BasicClientCookie2(name, value);
        String domain = (String) row.getValue(domainField);
        if (domain != null && domain.length() > 0)
            c.setDomain(domain);
        //c.setDomainAttributeSpecified(stringToBoolean((String)row.getValue(domainSpecifiedField)));
        String path = (String) row.getValue(pathField);
        if (path != null && path.length() > 0)
            c.setPath(path);
        //c.setPathAttributeSpecified(stringToBoolean((String)row.getValue(pathSpecifiedField)));
        Long version = (Long) row.getValue(versionField);
        if (version != null)
            c.setVersion((int) version.longValue());
        //c.setVersionAttributeSpecified(stringToBoolean((String)row.getValue(versionSpecifiedField)));
        String comment = (String) row.getValue(commentField);
        if (comment != null)
            c.setComment(comment);
        c.setSecure(stringToBoolean((String) row.getValue(secureField)));
        Long expirationDate = (Long) row.getValue(expirationDateField);
        if (expirationDate != null)
            c.setExpiryDate(new Date(expirationDate.longValue()));
        c.setDiscard(stringToBoolean((String) row.getValue(discardField)));
        String commentURL = (String) row.getValue(commentURLField);
        if (commentURL != null && commentURL.length() > 0)
            c.setCommentURL(commentURL);
        String ports = (String) row.getValue(portField);
        // Ports are comma-separated
        if (ports != null && ports.length() > 0)
            c.setPorts(stringToPorts(ports));
        //c.setPortAttributeBlank(stringToBoolean((String)row.getValue(portBlankField)));
        //c.setPortAttributeSpecified(stringToBoolean((String)row.getValue(portSpecifiedField)));

        dcs.addCookie(c);
    }
    return dcs;
}