/** * Validate cookie port attribute. If the Port attribute was specified * in header, the request port must be in cookie's port list. */ 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"); } int port = origin.getPort(); if (cookie instanceof ClientCookie && ((ClientCookie) cookie).containsAttribute(ClientCookie.PORT_ATTR)) { if (!portMatch(port, cookie.getPorts())) { throw new MalformedCookieException( "Port attribute violates RFC 2965: " + "Request port not found in cookie's port list."); } } }
/** * Match cookie port attribute. If the Port attribute is not specified * in header, the cookie can be sent to any port. Otherwise, the request port * must be in the cookie's port list. */ 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"); } int port = origin.getPort(); if (cookie instanceof ClientCookie && ((ClientCookie) cookie).containsAttribute(ClientCookie.PORT_ATTR)) { if (cookie.getPorts() == null) { // Invalid cookie state: port not specified return false; } if (!portMatch(port, cookie.getPorts())) { return false; } } return true; }
return new CookieOrigin( host, origin.getPort(), origin.getPath(), origin.isSecure());
private BasicClientCookie createCookie2( final String name, final String value, final CookieOrigin origin) { BasicClientCookie2 cookie = new BasicClientCookie2(name, value); cookie.setPath(getDefaultPath(origin)); cookie.setDomain(getDefaultDomain(origin)); cookie.setPorts(new int [] { origin.getPort() }); return cookie; }
@Override public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException { try { super.validate(cookie, origin); } catch (MalformedCookieException e) { System.err.println("Cookie rejected for url: " + origin.getHost() + (origin.getPort() != 80 ? ":" + origin.getPort() : "") + origin.getPath() + " the error:" + e.getMessage() + " for cookie:" + cookie.toString()); throw e; } } }
@Override public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException { try { super.validate(cookie, origin); } catch (MalformedCookieException e) { System.err.println("Cookie rejected for url: " + origin.getHost() + (origin.getPort() != 80 ? ":" + origin.getPort() : "") + origin.getPath() + " the error:" + e.getMessage() + " for cookie:" + cookie.toString()); throw e; } } }
@Override public boolean match(final Cookie cookie, final CookieOrigin origin) { CookieOrigin newOrigin = origin; String targetpath = origin.getPath(); if (browserVersion_.hasFeature(HTTP_COOKIE_EXTRACT_PATH_FROM_LOCATION) && !targetpath.isEmpty()) { final int lastSlashPos = targetpath.lastIndexOf('/'); if (lastSlashPos > 1 && lastSlashPos < targetpath.length()) { targetpath = targetpath.substring(0, lastSlashPos); newOrigin = new CookieOrigin(origin.getHost(), origin.getPort(), targetpath, origin.isSecure()); } } return super.match(cookie, newOrigin); } }
public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { if (origin != null && origin.getHost() != null && cookie != null) { String hostPort = origin.getHost() + ":" + origin.getPort(); String domain = cookie.getDomain(); if (hostPort.equals(domain)) { return; } } super.validate(cookie, origin); }
@Override public boolean match(final Cookie cookie, final CookieOrigin origin) { if (origin != null && origin.getHost() != null && cookie != null) { String hostPort = origin.getHost() + ":" + origin.getPort(); String domain = cookie.getDomain(); if (hostPort.equals(domain)) { return true; } } return super.match(cookie, origin); } }
@Override public boolean match(final Cookie cookie, final CookieOrigin origin) { CookieOrigin newOrigin = origin; String targetpath = origin.getPath(); if (browserVersion_.hasFeature(HTTP_COOKIE_EXTRACT_PATH_FROM_LOCATION) && !targetpath.isEmpty()) { final int lastSlashPos = targetpath.lastIndexOf('/'); if (lastSlashPos > 1 && lastSlashPos < targetpath.length()) { targetpath = targetpath.substring(0, lastSlashPos); newOrigin = new CookieOrigin(origin.getHost(), origin.getPort(), targetpath, origin.isSecure()); } } return super.match(cookie, newOrigin); } }
private BasicClientCookie createCookie2( final String name, final String value, final CookieOrigin origin) { BasicClientCookie2 cookie = new BasicClientCookie2(name, value); cookie.setPath(getDefaultPath(origin)); cookie.setDomain(getDefaultDomain(origin)); cookie.setPorts(new int [] { origin.getPort() }); return cookie; }
private BasicClientCookie createCookie2( final String name, final String value, final CookieOrigin origin) { BasicClientCookie2 cookie = new BasicClientCookie2(name, value); cookie.setPath(getDefaultPath(origin)); cookie.setDomain(getDefaultDomain(origin)); cookie.setPorts(new int [] { origin.getPort() }); return cookie; }
private BasicClientCookie createCookie2( final String name, final String value, final CookieOrigin origin) { BasicClientCookie2 cookie = new BasicClientCookie2(name, value); cookie.setPath(getDefaultPath(origin)); cookie.setDomain(getDefaultDomain(origin)); cookie.setPorts(new int [] { origin.getPort() }); return cookie; }
private BasicClientCookie createCookie2( final String name, final String value, final CookieOrigin origin) { BasicClientCookie2 cookie = new BasicClientCookie2(name, value); cookie.setPath(getDefaultPath(origin)); cookie.setDomain(getDefaultDomain(origin)); cookie.setPorts(new int [] { origin.getPort() }); return cookie; }
/** * Validate cookie port attribute. If the Port attribute was specified * in header, the request port must be in cookie's port list. */ @Override public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); Args.notNull(origin, "Cookie origin"); final int port = origin.getPort(); if (cookie instanceof ClientCookie && ((ClientCookie) cookie).containsAttribute(ClientCookie.PORT_ATTR)) { if (!portMatch(port, cookie.getPorts())) { throw new CookieRestrictionViolationException( "Port attribute violates RFC 2965: " + "Request port not found in cookie's port list."); } } }
/** * Validate cookie port attribute. If the Port attribute was specified * in header, the request port must be in cookie's port list. */ public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); Args.notNull(origin, "Cookie origin"); final int port = origin.getPort(); if (cookie instanceof ClientCookie && ((ClientCookie) cookie).containsAttribute(ClientCookie.PORT_ATTR)) { if (!portMatch(port, cookie.getPorts())) { throw new CookieRestrictionViolationException( "Port attribute violates RFC 2965: " + "Request port not found in cookie's port list."); } } }
/** * Validate cookie port attribute. If the Port attribute was specified * in header, the request port must be in cookie's port list. */ public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); Args.notNull(origin, "Cookie origin"); final int port = origin.getPort(); if (cookie instanceof ClientCookie && ((ClientCookie) cookie).containsAttribute(ClientCookie.PORT_ATTR)) { if (!portMatch(port, cookie.getPorts())) { throw new CookieRestrictionViolationException( "Port attribute violates RFC 2965: " + "Request port not found in cookie's port list."); } } }
/** * Validate cookie port attribute. If the Port attribute was specified * in header, the request port must be in cookie's port list. */ @Override public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); Args.notNull(origin, "Cookie origin"); final int port = origin.getPort(); if (cookie instanceof ClientCookie && ((ClientCookie) cookie).containsAttribute(ClientCookie.PORT_ATTR)) { if (!portMatch(port, cookie.getPorts())) { throw new CookieRestrictionViolationException( "Port attribute violates RFC 2965: " + "Request port not found in cookie's port list."); } } }
/** * Match cookie port attribute. If the Port attribute is not specified * in header, the cookie can be sent to any port. Otherwise, the request port * must be in the cookie's port list. */ public boolean match(final Cookie cookie, final CookieOrigin origin) { Args.notNull(cookie, "Cookie"); Args.notNull(origin, "Cookie origin"); final int port = origin.getPort(); if (cookie instanceof ClientCookie && ((ClientCookie) cookie).containsAttribute(ClientCookie.PORT_ATTR)) { if (cookie.getPorts() == null) { // Invalid cookie state: port not specified return false; } if (!portMatch(port, cookie.getPorts())) { return false; } } return true; }
/** * Validate cookie port attribute. If the Port attribute was specified * in header, the request port must be in cookie's port list. */ @Override public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); Args.notNull(origin, "Cookie origin"); final int port = origin.getPort(); if (cookie instanceof ClientCookie && ((ClientCookie) cookie).containsAttribute(ClientCookie.PORT_ATTR)) { if (!portMatch(port, cookie.getPorts())) { throw new CookieRestrictionViolationException( "Port attribute violates RFC 2965: " + "Request port not found in cookie's port list."); } } }