Example usage for org.apache.http.cookie Cookie getComment

List of usage examples for org.apache.http.cookie Cookie getComment

Introduction

In this page you can find the example usage for org.apache.http.cookie Cookie getComment.

Prototype

String getComment();

Source Link

Document

Returns the comment describing the purpose of this cookie, or null if no such comment has been defined.

Usage

From source file:cn.ttyhuo.common.MyApplication.java

public static void getJavaCookieStore(java.net.CookieStore jCookieStore) {
    if (cookieStore == null)
        return;//  ww  w .j ava  2s .co m

    for (Cookie h : cookieStore.getCookies()) {
        HttpCookie newCookie = new HttpCookie(h.getName(), h.getValue());
        newCookie.setVersion(h.getVersion());
        newCookie.setDomain(h.getDomain());
        newCookie.setPath(h.getPath());
        newCookie.setSecure(h.isSecure());
        newCookie.setComment(h.getComment());
        jCookieStore.add(URI.create("http://" + h.getDomain()), newCookie);
    }
}

From source file:fr.mixit.android.utils.NetworkUtils.java

static Cookie getCookie(DefaultHttpClient httpClient) {
    Cookie c = null;/*from   w w  w  . j  a v  a  2  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:Main.java

@Deprecated
// Deprecated because this uses org.apache.http, which is itself deprecated
public static HttpCookie servletCookieFromApacheCookie(org.apache.http.cookie.Cookie apacheCookie) {
    if (apacheCookie == null) {
        return null;
    }//from   ww w .  j av a 2  s .  co  m

    String name = apacheCookie.getName();
    String value = apacheCookie.getValue();

    HttpCookie cookie = new HttpCookie(name, value);

    value = apacheCookie.getDomain();
    if (value != null) {
        cookie.setDomain(value);
    }
    value = apacheCookie.getPath();
    if (value != null) {
        cookie.setPath(value);
    }
    cookie.setSecure(apacheCookie.isSecure());

    value = apacheCookie.getComment();
    if (value != null) {
        cookie.setComment(value);
    }

    // version
    cookie.setVersion(apacheCookie.getVersion());

    // From the Apache source code, maxAge is converted to expiry date using the following formula
    // if (maxAge >= 0) {
    //     setExpiryDate(new Date(System.currentTimeMillis() + maxAge * 1000L));
    // }
    // Reverse this to get the actual max age

    Date expiryDate = apacheCookie.getExpiryDate();
    if (expiryDate != null) {
        long maxAge = (expiryDate.getTime() - System.currentTimeMillis()) / 1000;
        // we have to lower down, no other option
        cookie.setMaxAge((int) maxAge);
    }

    // return the servlet cookie
    return cookie;
}

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.lillicoder.newsblurry.net.SerializableCookie.java

/**
 *
 * Serialization methods.//from   w w  w. j ava 2  s.c  o m
 * 
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    Cookie cookie = this.getCookie();

    // Write all values that can later be restored.
    // This means excluding comment URL, persistence value,
    // and ports.
    out.writeObject(cookie.getComment());
    out.writeObject(cookie.getDomain());
    out.writeObject(cookie.getExpiryDate());
    out.writeObject(cookie.getName());
    out.writeObject(cookie.getPath());
    out.writeObject(cookie.getValue());
    out.writeInt(cookie.getVersion());
    out.writeBoolean(cookie.isSecure());
}

From source file:org.mobicents.servlet.sip.restcomm.dao.mybatis.MybatisHttpCookiesDao.java

private Map<String, Object> toMap(final Sid sid, final Cookie cookie) {
    final Map<String, Object> map = new HashMap<String, Object>();
    map.put("sid", writeSid(sid));
    map.put("comment", cookie.getComment());
    map.put("domain", cookie.getDomain());
    map.put("expiration_date", cookie.getExpiryDate());
    map.put("name", cookie.getName());
    map.put("path", cookie.getPath());
    map.put("value", cookie.getValue());
    map.put("version", cookie.getVersion());
    return map;/*w w  w. j a v a 2  s . c  o m*/
}

From source file:org.restcomm.connect.dao.mybatis.MybatisHttpCookiesDao.java

private Map<String, Object> toMap(final Sid sid, final Cookie cookie) {
    final Map<String, Object> map = new HashMap<String, Object>();
    map.put("sid", DaoUtils.writeSid(sid));
    map.put("comment", cookie.getComment());
    map.put("domain", cookie.getDomain());
    map.put("expiration_date", cookie.getExpiryDate());
    map.put("name", cookie.getName());
    map.put("path", cookie.getPath());
    map.put("value", cookie.getValue());
    map.put("version", cookie.getVersion());
    return map;//from  w  ww.j a  v a 2 s  .  com
}

From source file:org.tellervo.desktop.wsi.util.WSCookieWrapper.java

public WSCookieWrapper(Cookie cookie) {
    name = cookie.getName();//from   www  . j  ava  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.nextlets.erc.defaults.http.ERCHttpInvokerImpl.java

private HttpCookie toHttpCookie(Cookie cookie) {
    HttpCookie httpCookie = new HttpCookie(cookie.getName(), cookie.getValue());
    httpCookie.setComment(cookie.getComment());
    httpCookie.setDomain(cookie.getDomain());
    if (cookie.getExpiryDate() != null) {
        httpCookie.setMaxAge(cookie.getExpiryDate().getTime() / 1000);
    }/*  w w w . j a va  2  s . c o m*/
    httpCookie.setPath(cookie.getPath());
    httpCookie.setSecure(cookie.isSecure());
    httpCookie.setVersion(cookie.getVersion());
    return httpCookie;
}

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());
        }/*  w  w  w . j a va  2s  .c om*/
    }
    Editor editor = preferences.edit();
    editor.putString(UserPreferences.COOKIE_PREFERENCE_KEY, array.toString());
    editor.commit();
    dirty = false;
}