Java Code Examples for java.net.HttpCookie#setPortlist()

The following examples show how to use java.net.HttpCookie#setPortlist() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NMBApplication.java    From Nimingban with Apache License 2.0 6 votes vote down vote up
public static void updateCookies(Context context) {
    SimpleCookieStore cookieStore = NMBApplication.getSimpleCookieStore(context);

    URL url = ACSite.getInstance().getSiteUrl();
    HttpCookieWithId hcwi = cookieStore.getCookie(url, "userId");
    if (hcwi != null) {
        HttpCookie oldCookie = hcwi.httpCookie;
        cookieStore.remove(url, oldCookie);

        HttpCookie newCookie = new HttpCookie("userhash", oldCookie.getValue());
        newCookie.setComment(oldCookie.getComment());
        newCookie.setCommentURL(oldCookie.getCommentURL());
        newCookie.setDiscard(oldCookie.getDiscard());
        newCookie.setDomain(oldCookie.getDomain());
        newCookie.setMaxAge(oldCookie.getMaxAge());
        newCookie.setPath(oldCookie.getPath());
        newCookie.setPortlist(oldCookie.getPortlist());
        newCookie.setSecure(oldCookie.getSecure());
        newCookie.setVersion(oldCookie.getVersion());

        cookieStore.add(url, newCookie);
    }
}
 
Example 2
Source File: TransportableHttpCookie.java    From Nimingban with Apache License 2.0 6 votes vote down vote up
@Nullable
public HttpCookie to() {
    if (name == null || value == null) {
        return null;
    }

    HttpCookie cookie = new HttpCookie(name, value);
    cookie.setComment(comment);
    cookie.setCommentURL(commentURL);
    cookie.setDiscard(discard);
    cookie.setDomain(domain);
    cookie.setMaxAge(maxAge);
    cookie.setPath(path);
    cookie.setPortlist(portList);
    cookie.setSecure(secure);
    cookie.setVersion(version);

    return cookie;
}
 
Example 3
Source File: HttpResultCoder.java    From redkale with Apache License 2.0 6 votes vote down vote up
public static List<HttpCookie> getCookieList(ByteBuffer buffer) {
    int len = buffer.getChar();
    if (len == 0) return null;
    final List<HttpCookie> list = new ArrayList<>(len);
    for (int i = 0; i < len; i++) {
        HttpCookie cookie = new HttpCookie(getShortString(buffer), getShortString(buffer));
        cookie.setDomain(getShortString(buffer));
        cookie.setPath(getShortString(buffer));
        cookie.setPortlist(getShortString(buffer));
        cookie.setMaxAge(buffer.getLong());
        cookie.setSecure(buffer.get() == 1);
        cookie.setHttpOnly(buffer.get() == 1);
        list.add(cookie);
    }
    return list;
}
 
Example 4
Source File: CookieEntity.java    From NoHttp with Apache License 2.0 6 votes vote down vote up
/**
 * Into {@link HttpCookie}.
 *
 * @return {@link HttpCookie}.
 */
public HttpCookie toHttpCookie() {
    HttpCookie cookie = new HttpCookie(name, value);
    cookie.setComment(comment);
    cookie.setCommentURL(commentURL);
    cookie.setDiscard(discard);
    cookie.setDomain(domain);
    if (expiry == -1L)
        cookie.setMaxAge(-1L);
    else
        cookie.setMaxAge((expiry - System.currentTimeMillis()) / 1000L);
    cookie.setPath(path);
    cookie.setPortlist(portList);
    cookie.setSecure(secure);
    cookie.setVersion(version);
    return cookie;
}
 
Example 5
Source File: SerializableHttpCookie.java    From DaVinci with Apache License 2.0 6 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException,
        ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    cookie = new HttpCookie(name, value);
    cookie.setComment((String) in.readObject());
    cookie.setCommentURL((String) in.readObject());
    cookie.setDomain((String) in.readObject());
    cookie.setMaxAge(in.readLong());
    cookie.setPath((String) in.readObject());
    cookie.setPortlist((String) in.readObject());
    cookie.setVersion(in.readInt());
    cookie.setSecure(in.readBoolean());
    cookie.setDiscard(in.readBoolean());
    setHttpOnly(in.readBoolean());
}
 
Example 6
Source File: SerializableHttpCookie.java    From 4pdaClient-plus with Apache License 2.0 6 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException,
        ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    cookie = new HttpCookie(name, value);
    cookie.setComment((String) in.readObject());
    cookie.setCommentURL((String) in.readObject());
    cookie.setDomain((String) in.readObject());
    cookie.setMaxAge(in.readLong());
    cookie.setPath((String) in.readObject());
    cookie.setPortlist((String) in.readObject());
    cookie.setVersion(in.readInt());
    cookie.setSecure(in.readBoolean());
    cookie.setDiscard(in.readBoolean());
    setHttpOnly(in.readBoolean());
}
 
Example 7
Source File: AbstractCookiesTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * CookieStoreImpl has a strict requirement on HttpCookie.equals() to enable replacement of
 * cookies with the same name.
 */
public void testCookieEquality() throws Exception {
    HttpCookie baseCookie = createCookie("theme", "light", "a.com", "/");

    // None of the attributes immediately below should affect equality otherwise CookieStoreImpl
    // eviction will not work as intended.
    HttpCookie valueCookie = createCookie("theme", "light", "a.com", "/");
    valueCookie.setValue("dark");
    valueCookie.setPortlist("1234");
    valueCookie.setSecure(true);
    valueCookie.setComment("comment");
    valueCookie.setCommentURL("commentURL");
    valueCookie.setDiscard(true);
    valueCookie.setMaxAge(12345L);
    valueCookie.setVersion(1);
    assertEquals(baseCookie, valueCookie);

    // Changing any of the 3 main identity attributes should render cookies unequal.
    assertNotEquals(createCookie("theme2", "light", "a.com", "/"), baseCookie);
    assertNotEquals(createCookie("theme", "light", "b.com", "/"), baseCookie);
    assertNotEquals(createCookie("theme", "light", "a.com", "/path"), baseCookie);
}
 
Example 8
Source File: SerializableHttpCookie.java    From Social with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new HttpCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setCommentURL((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setMaxAge(in.readLong());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setPortlist((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
    clientCookie.setDiscard(in.readBoolean());
}
 
Example 9
Source File: SerializableHttpCookie.java    From mimi-reader with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
        String name = (String) in.readObject();
        String value = (String) in.readObject();
        cookie = new HttpCookie(name, value);
        cookie.setComment((String) in.readObject());
        cookie.setCommentURL((String) in.readObject());
        cookie.setDomain((String) in.readObject());
        cookie.setMaxAge(in.readLong());
        cookie.setPath((String) in.readObject());
        cookie.setPortlist((String) in.readObject());
        cookie.setVersion(in.readInt());
        cookie.setSecure(in.readBoolean());
        cookie.setDiscard(in.readBoolean());
//        setHttpOnly(in.readBoolean());
    }
 
Example 10
Source File: SerializableHttpCookie.java    From NewsMe with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new HttpCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setCommentURL((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setMaxAge(in.readLong());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setPortlist((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
    clientCookie.setDiscard(in.readBoolean());
}
 
Example 11
Source File: SerializableHttpCookie.java    From mattermost-android-classic with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new HttpCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setCommentURL((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setMaxAge(in.readLong());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setPortlist((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
    clientCookie.setDiscard(in.readBoolean());
}
 
Example 12
Source File: SerializableHttpCookie.java    From ratebeer with GNU General Public License v3.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
	String name = (String) in.readObject();
	String value = (String) in.readObject();
	cookie = new HttpCookie(name, value);
	cookie.setComment((String) in.readObject());
	cookie.setCommentURL((String) in.readObject());
	cookie.setDomain((String) in.readObject());
	cookie.setMaxAge(in.readLong());
	cookie.setPath((String) in.readObject());
	cookie.setPortlist((String) in.readObject());
	cookie.setVersion(in.readInt());
	cookie.setSecure(in.readBoolean());
	cookie.setDiscard(in.readBoolean());
	setHttpOnly(in.readBoolean());
}
 
Example 13
Source File: SerializableHttpCookie.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    mClientCookie = new HttpCookie(name, value);
    mClientCookie.setComment((String) in.readObject());
    mClientCookie.setCommentURL((String) in.readObject());
    mClientCookie.setDomain((String) in.readObject());
    mClientCookie.setMaxAge(in.readLong());
    mClientCookie.setPath((String) in.readObject());
    mClientCookie.setPortlist((String) in.readObject());
    mClientCookie.setVersion(in.readInt());
    mClientCookie.setSecure(in.readBoolean());
    mClientCookie.setDiscard(in.readBoolean());
}