Java 类org.apache.http.cookie.SetCookie2 实例源码

项目:lams    文件:BestMatchSpec.java   
public void validate(
        final Cookie cookie,
        final CookieOrigin origin) throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (origin == null) {
        throw new IllegalArgumentException("Cookie origin may not be null");
    }
    if (cookie.getVersion() > 0) {
        if (cookie instanceof SetCookie2) {
            getStrict().validate(cookie, origin);
        } else {
            getObsoleteStrict().validate(cookie, origin);
        }
    } else {
        getCompat().validate(cookie, origin);
    }
}
项目:lams    文件:BestMatchSpec.java   
public boolean match(final Cookie cookie, final CookieOrigin origin) {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (origin == null) {
        throw new IllegalArgumentException("Cookie origin may not be null");
    }
    if (cookie.getVersion() > 0) {
        if (cookie instanceof SetCookie2) {
            return getStrict().match(cookie, origin);
        } else {
            return getObsoleteStrict().match(cookie, origin);
        }
    } else {
        return getCompat().match(cookie, origin);
    }
}
项目:lams    文件:BestMatchSpec.java   
public List<Header> formatCookies(final List<Cookie> cookies) {
    if (cookies == null) {
        throw new IllegalArgumentException("List of cookies may not be null");
    }
    int version = Integer.MAX_VALUE;
    boolean isSetCookie2 = true;
    for (Cookie cookie: cookies) {
        if (!(cookie instanceof SetCookie2)) {
            isSetCookie2 = false;
        }
        if (cookie.getVersion() < version) {
            version = cookie.getVersion();
        }
    }
    if (version > 0) {
        if (isSetCookie2) {
            return getStrict().formatCookies(cookies);
        } else {
            return getObsoleteStrict().formatCookies(cookies);
        }
    } else {
        return getCompat().formatCookies(cookies);
    }
}
项目:remote-files-sync    文件:BestMatchSpecHC4.java   
public List<Header> formatCookies(final List<Cookie> cookies) {
    Args.notNull(cookies, "List of cookies");
    int version = Integer.MAX_VALUE;
    boolean isSetCookie2 = true;
    for (final Cookie cookie: cookies) {
        if (!(cookie instanceof SetCookie2)) {
            isSetCookie2 = false;
        }
        if (cookie.getVersion() < version) {
            version = cookie.getVersion();
        }
    }
    if (version > 0) {
        if (isSetCookie2) {
            return getStrict().formatCookies(cookies);
        } else {
            return getObsoleteStrict().formatCookies(cookies);
        }
    } else {
        return getCompat().formatCookies(cookies);
    }
}
项目:purecloud-iot    文件:DefaultCookieSpec.java   
@Override
public void validate(
        final Cookie cookie,
        final CookieOrigin origin) throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    Args.notNull(origin, "Cookie origin");
    if (cookie.getVersion() > 0) {
        if (cookie instanceof SetCookie2) {
            strict.validate(cookie, origin);
        } else {
            obsoleteStrict.validate(cookie, origin);
        }
    } else {
        netscapeDraft.validate(cookie, origin);
    }
}
项目:purecloud-iot    文件:DefaultCookieSpec.java   
@Override
public List<Header> formatCookies(final List<Cookie> cookies) {
    Args.notNull(cookies, "List of cookies");
    int version = Integer.MAX_VALUE;
    boolean isSetCookie2 = true;
    for (final Cookie cookie: cookies) {
        if (!(cookie instanceof SetCookie2)) {
            isSetCookie2 = false;
        }
        if (cookie.getVersion() < version) {
            version = cookie.getVersion();
        }
    }
    if (version > 0) {
        if (isSetCookie2) {
            return strict.formatCookies(cookies);
        } else {
            return obsoleteStrict.formatCookies(cookies);
        }
    } else {
        return netscapeDraft.formatCookies(cookies);
    }
}
项目:Visit    文件:BestMatchSpecHC4.java   
public List<Header> formatCookies(final List<Cookie> cookies) {
    Args.notNull(cookies, "List of cookies");
    int version = Integer.MAX_VALUE;
    boolean isSetCookie2 = true;
    for (final Cookie cookie: cookies) {
        if (!(cookie instanceof SetCookie2)) {
            isSetCookie2 = false;
        }
        if (cookie.getVersion() < version) {
            version = cookie.getVersion();
        }
    }
    if (version > 0) {
        if (isSetCookie2) {
            return getStrict().formatCookies(cookies);
        } else {
            return getObsoleteStrict().formatCookies(cookies);
        }
    } else {
        return getCompat().formatCookies(cookies);
    }
}
项目:cJUnit-mc626    文件:BestMatchSpec.java   
public void validate(
        final Cookie cookie, 
        final CookieOrigin origin) throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (origin == null) {
        throw new IllegalArgumentException("Cookie origin may not be null");
    }
    if (cookie.getVersion() > 0) {
        if (cookie instanceof SetCookie2) {
            getStrict().validate(cookie, origin);
        } else {
            getObsoleteStrict().validate(cookie, origin);
        }
    } else {
        getCompat().validate(cookie, origin);
    }
}
项目:cJUnit-mc626    文件:BestMatchSpec.java   
public boolean match(final Cookie cookie, final CookieOrigin origin) {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (origin == null) {
        throw new IllegalArgumentException("Cookie origin may not be null");
    }
    if (cookie.getVersion() > 0) {
        if (cookie instanceof SetCookie2) {
            return getStrict().match(cookie, origin);
        } else {
            return getObsoleteStrict().match(cookie, origin);
        }
    } else {
        return getCompat().match(cookie, origin);
    }
}
项目:cJUnit-mc626    文件:BestMatchSpec.java   
public List<Header> formatCookies(final List<Cookie> cookies) {
    if (cookies == null) {
        throw new IllegalArgumentException("List of cookie may not be null");
    }
    int version = Integer.MAX_VALUE;
    boolean isSetCookie2 = true; 
    for (Cookie cookie: cookies) {
        if (!(cookie instanceof SetCookie2)) {
            isSetCookie2 = false;
        }
        if (cookie.getVersion() < version) {
            version = cookie.getVersion();
        }
    }
    if (version > 0) {
        if (isSetCookie2) {
            return getStrict().formatCookies(cookies);
        } else {
            return getObsoleteStrict().formatCookies(cookies);
        }
    } else {
        return getCompat().formatCookies(cookies);
    }
}
项目:ZTLib    文件:BestMatchSpecHC4.java   
public List<Header> formatCookies(final List<Cookie> cookies) {
    Args.notNull(cookies, "List of cookies");
    int version = Integer.MAX_VALUE;
    boolean isSetCookie2 = true;
    for (final Cookie cookie: cookies) {
        if (!(cookie instanceof SetCookie2)) {
            isSetCookie2 = false;
        }
        if (cookie.getVersion() < version) {
            version = cookie.getVersion();
        }
    }
    if (version > 0) {
        if (isSetCookie2) {
            return getStrict().formatCookies(cookies);
        } else {
            return getObsoleteStrict().formatCookies(cookies);
        }
    } else {
        return getCompat().formatCookies(cookies);
    }
}
项目:lams    文件:RFC2965VersionAttributeHandler.java   
/**
 * validate cookie version attribute. Version attribute is REQUIRED.
 */
public void validate(final Cookie cookie, final CookieOrigin origin)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (cookie instanceof SetCookie2) {
        if (cookie instanceof ClientCookie
                && !((ClientCookie) cookie).containsAttribute(ClientCookie.VERSION_ATTR)) {
            throw new CookieRestrictionViolationException(
                    "Violates RFC 2965. Version attribute is required.");
        }
    }
}
项目:lams    文件:RFC2965PortAttributeHandler.java   
/**
 * Parse cookie port attribute.
 */
public void parse(final SetCookie cookie, final String portValue)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (cookie instanceof SetCookie2) {
        SetCookie2 cookie2 = (SetCookie2) cookie;
        if (portValue != null && portValue.trim().length() > 0) {
            int[] ports = parsePortAttribute(portValue);
            cookie2.setPorts(ports);
        }
    }
}
项目:lams    文件:RFC2965CommentUrlAttributeHandler.java   
public void parse(final SetCookie cookie, final String commenturl)
        throws MalformedCookieException {
    if (cookie instanceof SetCookie2) {
        SetCookie2 cookie2 = (SetCookie2) cookie;
        cookie2.setCommentURL(commenturl);
    }
}
项目:lams    文件:RFC2965DiscardAttributeHandler.java   
public void parse(final SetCookie cookie, final String commenturl)
        throws MalformedCookieException {
    if (cookie instanceof SetCookie2) {
        SetCookie2 cookie2 = (SetCookie2) cookie;
        cookie2.setDiscard(true);
    }
}
项目:remote-files-sync    文件:RFC2965PortAttributeHandlerHC4.java   
/**
 * Parse cookie port attribute.
 */
public void parse(final SetCookie cookie, final String portValue)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (cookie instanceof SetCookie2) {
        final SetCookie2 cookie2 = (SetCookie2) cookie;
        if (portValue != null && portValue.trim().length() > 0) {
            final int[] ports = parsePortAttribute(portValue);
            cookie2.setPorts(ports);
        }
    }
}
项目:remote-files-sync    文件:RFC2965VersionAttributeHandlerHC4.java   
/**
 * validate cookie version attribute. Version attribute is REQUIRED.
 */
public void validate(final Cookie cookie, final CookieOrigin origin)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (cookie instanceof SetCookie2) {
        if (cookie instanceof ClientCookie
                && !((ClientCookie) cookie).containsAttribute(ClientCookie.VERSION_ATTR)) {
            throw new CookieRestrictionViolationException(
                    "Violates RFC 2965. Version attribute is required.");
        }
    }
}
项目:remote-files-sync    文件:RFC2965CommentUrlAttributeHandlerHC4.java   
public void parse(final SetCookie cookie, final String commenturl)
        throws MalformedCookieException {
    if (cookie instanceof SetCookie2) {
        final SetCookie2 cookie2 = (SetCookie2) cookie;
        cookie2.setCommentURL(commenturl);
    }
}
项目:remote-files-sync    文件:BestMatchSpecHC4.java   
public void validate(
        final Cookie cookie,
        final CookieOrigin origin) throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    Args.notNull(origin, "Cookie origin");
    if (cookie.getVersion() > 0) {
        if (cookie instanceof SetCookie2) {
            getStrict().validate(cookie, origin);
        } else {
            getObsoleteStrict().validate(cookie, origin);
        }
    } else {
        getCompat().validate(cookie, origin);
    }
}
项目:remote-files-sync    文件:BestMatchSpecHC4.java   
public boolean match(final Cookie cookie, final CookieOrigin origin) {
    Args.notNull(cookie, "Cookie");
    Args.notNull(origin, "Cookie origin");
    if (cookie.getVersion() > 0) {
        if (cookie instanceof SetCookie2) {
            return getStrict().match(cookie, origin);
        } else {
            return getObsoleteStrict().match(cookie, origin);
        }
    } else {
        return getCompat().match(cookie, origin);
    }
}
项目:remote-files-sync    文件:RFC2965DiscardAttributeHandlerHC4.java   
public void parse(final SetCookie cookie, final String commenturl)
        throws MalformedCookieException {
    if (cookie instanceof SetCookie2) {
        final SetCookie2 cookie2 = (SetCookie2) cookie;
        cookie2.setDiscard(true);
    }
}
项目:purecloud-iot    文件:RFC2965VersionAttributeHandler.java   
/**
 * validate cookie version attribute. Version attribute is REQUIRED.
 */
@Override
public void validate(final Cookie cookie, final CookieOrigin origin)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (cookie instanceof SetCookie2) {
        if (cookie instanceof ClientCookie
                && !((ClientCookie) cookie).containsAttribute(ClientCookie.VERSION_ATTR)) {
            throw new CookieRestrictionViolationException(
                    "Violates RFC 2965. Version attribute is required.");
        }
    }
}
项目:purecloud-iot    文件:RFC2965PortAttributeHandler.java   
/**
 * Parse cookie port attribute.
 */
@Override
public void parse(final SetCookie cookie, final String portValue)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (cookie instanceof SetCookie2) {
        final SetCookie2 cookie2 = (SetCookie2) cookie;
        if (portValue != null && !portValue.trim().isEmpty()) {
            final int[] ports = parsePortAttribute(portValue);
            cookie2.setPorts(ports);
        }
    }
}
项目:purecloud-iot    文件:DefaultCookieSpec.java   
@Override
public boolean match(final Cookie cookie, final CookieOrigin origin) {
    Args.notNull(cookie, "Cookie");
    Args.notNull(origin, "Cookie origin");
    if (cookie.getVersion() > 0) {
        if (cookie instanceof SetCookie2) {
            return strict.match(cookie, origin);
        } else {
            return obsoleteStrict.match(cookie, origin);
        }
    } else {
        return netscapeDraft.match(cookie, origin);
    }
}
项目:purecloud-iot    文件:RFC2965CommentUrlAttributeHandler.java   
@Override
public void parse(final SetCookie cookie, final String commenturl)
        throws MalformedCookieException {
    if (cookie instanceof SetCookie2) {
        final SetCookie2 cookie2 = (SetCookie2) cookie;
        cookie2.setCommentURL(commenturl);
    }
}
项目:purecloud-iot    文件:RFC2965DiscardAttributeHandler.java   
@Override
public void parse(final SetCookie cookie, final String commenturl)
        throws MalformedCookieException {
    if (cookie instanceof SetCookie2) {
        final SetCookie2 cookie2 = (SetCookie2) cookie;
        cookie2.setDiscard(true);
    }
}
项目:purecloud-iot    文件:TestDefaultCookieSpec.java   
@Test
public void testCookieStandardCompliantParsingLocalHost() throws Exception {
    final CookieSpec cookiespec = new DefaultCookieSpec();
    final CookieOrigin origin = new CookieOrigin("localhost", 80, "/", false);

    final Header header = new BasicHeader("Set-Cookie", "special=\"abcdigh\"; Version=1");

    final List<Cookie> cookies = cookiespec.parse(header, origin);
    for (int i = 0; i < cookies.size(); i++) {
        final Cookie cookie = cookies.get(i);
        cookiespec.validate(cookie, origin);
        Assert.assertEquals("localhost", cookie.getDomain());
        Assert.assertFalse(cookie instanceof SetCookie2);
    }
}
项目:purecloud-iot    文件:TestDefaultCookieSpec.java   
@Test
public void testCookieStandardCompliantParsingLocalHost2() throws Exception {
    final CookieSpec cookiespec = new DefaultCookieSpec();
    final CookieOrigin origin = new CookieOrigin("localhost", 80, "/", false);

    final Header header = new BasicHeader("Set-Cookie2", "special=\"abcdigh\"; Version=1");

    final List<Cookie> cookies = cookiespec.parse(header, origin);
    for (int i = 0; i < cookies.size(); i++) {
        final Cookie cookie = cookies.get(i);
        cookiespec.validate(cookie, origin);
        Assert.assertEquals("localhost.local", cookie.getDomain());
        Assert.assertTrue(cookie instanceof SetCookie2);
    }
}
项目:Visit    文件:RFC2965PortAttributeHandlerHC4.java   
/**
 * Parse cookie port attribute.
 */
public void parse(final SetCookie cookie, final String portValue)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (cookie instanceof SetCookie2) {
        final SetCookie2 cookie2 = (SetCookie2) cookie;
        if (portValue != null && portValue.trim().length() > 0) {
            final int[] ports = parsePortAttribute(portValue);
            cookie2.setPorts(ports);
        }
    }
}
项目:Visit    文件:RFC2965VersionAttributeHandlerHC4.java   
/**
 * validate cookie version attribute. Version attribute is REQUIRED.
 */
public void validate(final Cookie cookie, final CookieOrigin origin)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (cookie instanceof SetCookie2) {
        if (cookie instanceof ClientCookie
                && !((ClientCookie) cookie).containsAttribute(ClientCookie.VERSION_ATTR)) {
            throw new CookieRestrictionViolationException(
                    "Violates RFC 2965. Version attribute is required.");
        }
    }
}
项目:Visit    文件:RFC2965CommentUrlAttributeHandlerHC4.java   
public void parse(final SetCookie cookie, final String commenturl)
        throws MalformedCookieException {
    if (cookie instanceof SetCookie2) {
        final SetCookie2 cookie2 = (SetCookie2) cookie;
        cookie2.setCommentURL(commenturl);
    }
}
项目:Visit    文件:BestMatchSpecHC4.java   
public void validate(
        final Cookie cookie,
        final CookieOrigin origin) throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    Args.notNull(origin, "Cookie origin");
    if (cookie.getVersion() > 0) {
        if (cookie instanceof SetCookie2) {
            getStrict().validate(cookie, origin);
        } else {
            getObsoleteStrict().validate(cookie, origin);
        }
    } else {
        getCompat().validate(cookie, origin);
    }
}
项目:Visit    文件:BestMatchSpecHC4.java   
public boolean match(final Cookie cookie, final CookieOrigin origin) {
    Args.notNull(cookie, "Cookie");
    Args.notNull(origin, "Cookie origin");
    if (cookie.getVersion() > 0) {
        if (cookie instanceof SetCookie2) {
            return getStrict().match(cookie, origin);
        } else {
            return getObsoleteStrict().match(cookie, origin);
        }
    } else {
        return getCompat().match(cookie, origin);
    }
}
项目:Visit    文件:RFC2965DiscardAttributeHandlerHC4.java   
public void parse(final SetCookie cookie, final String commenturl)
        throws MalformedCookieException {
    if (cookie instanceof SetCookie2) {
        final SetCookie2 cookie2 = (SetCookie2) cookie;
        cookie2.setDiscard(true);
    }
}
项目:cJUnit-mc626    文件:RFC2965VersionAttributeHandler.java   
/**
 * validate cookie version attribute. Version attribute is REQUIRED.
 */
public void validate(final Cookie cookie, final CookieOrigin origin)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (cookie instanceof SetCookie2) {
        if (cookie instanceof ClientCookie 
                && !((ClientCookie) cookie).containsAttribute(ClientCookie.VERSION_ATTR)) {
            throw new MalformedCookieException(
                    "Violates RFC 2965. Version attribute is required.");
        }
    }
}
项目:cJUnit-mc626    文件:RFC2965PortAttributeHandler.java   
/**
 * Parse cookie port attribute.
 */
public void parse(final SetCookie cookie, final String portValue)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (cookie instanceof SetCookie2) {
        SetCookie2 cookie2 = (SetCookie2) cookie;
        if (portValue != null && portValue.trim().length() > 0) {
            int[] ports = parsePortAttribute(portValue);
            cookie2.setPorts(ports);
        }
    }
}
项目:cJUnit-mc626    文件:RFC2965CommentUrlAttributeHandler.java   
public void parse(final SetCookie cookie, final String commenturl)
        throws MalformedCookieException {
    if (cookie instanceof SetCookie2) {
        SetCookie2 cookie2 = (SetCookie2) cookie;
        cookie2.setCommentURL(commenturl);
    }
}
项目:cJUnit-mc626    文件:RFC2965DiscardAttributeHandler.java   
public void parse(final SetCookie cookie, final String commenturl)
        throws MalformedCookieException {
    if (cookie instanceof SetCookie2) {
        SetCookie2 cookie2 = (SetCookie2) cookie;
        cookie2.setDiscard(true);
    }
}
项目:ZTLib    文件:RFC2965PortAttributeHandlerHC4.java   
/**
 * Parse cookie port attribute.
 */
public void parse(final SetCookie cookie, final String portValue)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (cookie instanceof SetCookie2) {
        final SetCookie2 cookie2 = (SetCookie2) cookie;
        if (portValue != null && portValue.trim().length() > 0) {
            final int[] ports = parsePortAttribute(portValue);
            cookie2.setPorts(ports);
        }
    }
}
项目:ZTLib    文件:RFC2965VersionAttributeHandlerHC4.java   
/**
 * validate cookie version attribute. Version attribute is REQUIRED.
 */
public void validate(final Cookie cookie, final CookieOrigin origin)
        throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (cookie instanceof SetCookie2) {
        if (cookie instanceof ClientCookie
                && !((ClientCookie) cookie).containsAttribute(ClientCookie.VERSION_ATTR)) {
            throw new CookieRestrictionViolationException(
                    "Violates RFC 2965. Version attribute is required.");
        }
    }
}