private String normalizePath(final Cookie cookie) { String path = cookie.getPath(); if (path == null) { path = "/"; } if (!path.endsWith("/")) { path = path + '/'; } return path; }
/** * Returns a string that uniquely identifies the cookie, The format The * format of the key is {@code "normalizedDomain;name;path"}. Adapted from * {@link CookieIdentityComparator#compare(Cookie, Cookie)}. */ protected String sortableKey(Cookie cookie) { String normalizedDomain = normalizeHost(cookie.getDomain()); // use ";" as delimiter since it is the delimiter in the cookie header, // so presumably can't appear in any of these values StringBuilder buf = new StringBuilder(normalizedDomain); buf.append(";").append(cookie.getName()); buf.append(";").append(cookie.getPath() != null ? cookie.getPath() : "/"); return buf.toString(); }
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"); } String targetpath = origin.getPath(); String topmostPath = cookie.getPath(); if (topmostPath == null) { topmostPath = "/"; } if (topmostPath.length() > 1 && topmostPath.endsWith("/")) { topmostPath = topmostPath.substring(0, topmostPath.length() - 1); } boolean match = targetpath.startsWith (topmostPath); // if there is a match and these values are not exactly the same we have // to make sure we're not matcing "/foobar" and "/foo" if (match && targetpath.length() != topmostPath.length()) { if (!topmostPath.endsWith("/")) { match = (targetpath.charAt(topmostPath.length()) == '/'); } } return match; }
/** * Don't log the cookie's value; that's potentially sensitive information. */ private String cookieToString(Cookie cookie) { return cookie.getClass().getSimpleName() + "[version=" + cookie.getVersion() + ",name=" + cookie.getName() + ",domain=" + cookie.getDomain() + ",path=" + cookie.getPath() + ",expiry=" + cookie.getExpiryDate() + "]"; } // END android-added
public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { if (!match(cookie, origin)) { throw new MalformedCookieException( "Illegal path attribute \"" + cookie.getPath() + "\". Path of origin: \"" + origin.getPath() + "\""); } }
/** * Return a string suitable for sending in a <tt>"Cookie"</tt> header * as defined in RFC 2109 for backward compatibility with cookie version 0 * @param buffer The char array buffer to use for output * @param cookie The {@link Cookie} to be formatted as string * @param version The version to use. */ protected void formatCookieAsVer(final CharArrayBuffer buffer, final Cookie cookie, int version) { formatParamAsVer(buffer, cookie.getName(), cookie.getValue(), version); if (cookie.getPath() != null) { if (cookie instanceof ClientCookie && ((ClientCookie) cookie).containsAttribute(ClientCookie.PATH_ATTR)) { buffer.append("; "); formatParamAsVer(buffer, "$Path", cookie.getPath(), version); } } if (cookie.getDomain() != null) { if (cookie instanceof ClientCookie && ((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR)) { buffer.append("; "); formatParamAsVer(buffer, "$Domain", cookie.getDomain(), version); } } }
private String normalizePath(final Cookie cookie) { String path = cookie.getPath(); if (path == null) { path = "/"; } if (!path.endsWith("/")) { path = path + '/'; } return path; }
private String normalizePath(final Cookie cookie) { String path = cookie.getPath(); if (path == null) { path = "/"; } if (!path.endsWith("/")) { path = path + '/'; } return path; }
private String normalizePath(final Cookie cookie) { String path = cookie.getPath(); if (path == null) { path = "/"; } if (!path.endsWith("/")) { path = path + '/'; } return path; }
private String normalizePath(final Cookie cookie) { String path = cookie.getPath(); if (path == null) { path = "/"; } if (!path.endsWith("/")) { path = path + '/'; } return path; }
private void printCookie(Cookie cookie) { htmlDocument.add("Name: " + cookie.getName() + "<br/>"); htmlDocument.add("Path: " + cookie.getPath() + "<br/>"); htmlDocument.add("Domain: " + cookie.getDomain() + "<br/>"); htmlDocument.add("Value: " + cookie.getValue() + "<br/>"); }
Key(Cookie c) { Domain = c.getDomain(); Path = c.getPath(); Name = c.getName(); }
private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(cookie.getName()); out.writeObject(cookie.getValue()); out.writeObject(cookie.getComment()); out.writeObject(cookie.getDomain()); out.writeObject(cookie.getExpiryDate()); out.writeObject(cookie.getPath()); out.writeInt(cookie.getVersion()); out.writeBoolean(cookie.isSecure()); }
private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(cookie.getName()); out.writeObject(cookie.getValue()); out.writeObject(cookie.getComment()); out.writeObject(cookie.getDomain()); out.writeObject(cookie.getExpiryDate()); out.writeObject(cookie.getPath()); out.writeInt(cookie.getVersion()); out.writeBoolean(cookie.isSecure()); }
public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { if (!match(cookie, origin)) { throw new MalformedCookieException( "Illegal path attribute \"" + cookie.getPath() + "\". Path of origin: \"" + origin.getPath() + "\""); } }
@Override public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { if (!match(cookie, origin)) { throw new CookieRestrictionViolationException( "Illegal 'path' attribute \"" + cookie.getPath() + "\". Path of origin: \"" + origin.getPath() + "\""); } }
public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { if (!match(cookie, origin)) { throw new CookieRestrictionViolationException( "Illegal path attribute \"" + cookie.getPath() + "\". Path of origin: \"" + origin.getPath() + "\""); } }
@Override public boolean match(final Cookie cookie, final CookieOrigin origin) { Args.notNull(cookie, "Cookie"); Args.notNull(origin, "Cookie origin"); return pathMatch(origin.getPath(), cookie.getPath()); }
@Override public boolean match(final Cookie cookie, final CookieOrigin origin) { Args.notNull(cookie, "Cookie"); Args.notNull(origin, "Cookie origin"); return pathMatch(origin.getPath(), cookie.getPath()); }