/** * Parse cookie domain attribute. */ public void parse(final Cookie cookie, String domain) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (domain == null) { throw new MalformedCookieException( "Missing value for domain attribute"); } if (domain.trim().equals("")) { throw new MalformedCookieException( "Blank value for domain attribute"); } domain = domain.toLowerCase(); if (!domain.startsWith(".")) { // Per RFC 2965 section 3.2.2 // "... If an explicitly specified value does not start with // a dot, the user agent supplies a leading dot ..." // That effectively implies that the domain attribute // MAY NOT be an IP address of a host name domain = "." + domain; } cookie.setDomain(domain); cookie.setDomainAttributeSpecified(true); }
this.setDomain(domain); this.setExpiryDate(expires); this.setSecure(secure);
"Blank value for domain attribute"); cookie.setDomain(paramValue); cookie.setDomainAttributeSpecified(true);
/** * Return a Cookie array * and auto importing domain and path when domain was empty. * * @param uri required Apache Common VFS supported file systems and response JSON format content. * @return Cookie[] */ Cookie[] getCookies(String uri){ if( null == cookies || 0 == cookies.size()) return null; for(Cookie cookie: cookies){ if("".equals(cookie.getDomain())){ String domain = uri.replaceAll("^.*:\\/\\/([^\\/]+)[\\/]?.*$", "$1"); cookie.setDomain(domain); cookie.setPath("/"); cookie.setExpiryDate(null); cookie.setSecure(false); } } return cookies.toArray(new Cookie[cookies.size()]); }
/** * Parse cookie domain attribute. */ public void parse(final Cookie cookie, String domain) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (domain == null) { throw new MalformedCookieException( "Missing value for domain attribute"); } if (domain.trim().equals("")) { throw new MalformedCookieException( "Blank value for domain attribute"); } domain = domain.toLowerCase(); if (!domain.startsWith(".")) { // Per RFC 2965 section 3.2.2 // "... If an explicitly specified value does not start with // a dot, the user agent supplies a leading dot ..." // That effectively implies that the domain attribute // MAY NOT be an IP address of a host name domain = "." + domain; } cookie.setDomain(domain); cookie.setDomainAttributeSpecified(true); }
this.setDomain(domain); this.setExpiryDate(expires); this.setSecure(secure);
/** * Parse cookie domain attribute. */ public void parse(final Cookie cookie, String domain) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (domain == null) { throw new MalformedCookieException( "Missing value for domain attribute"); } if (domain.trim().equals("")) { throw new MalformedCookieException( "Blank value for domain attribute"); } domain = domain.toLowerCase(); if (!domain.startsWith(".")) { // Per RFC 2965 section 3.2.2 // "... If an explicitly specified value does not start with // a dot, the user agent supplies a leading dot ..." // That effectively implies that the domain attribute // MAY NOT be an IP address of a host name domain = "." + domain; } cookie.setDomain(domain); cookie.setDomainAttributeSpecified(true); }
this.setDomain(domain); this.setExpiryDate(expires); this.setSecure(secure);
/** * Parse cookie domain attribute. */ public void parse(final Cookie cookie, String domain) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (domain == null) { throw new MalformedCookieException( "Missing value for domain attribute"); } if (domain.trim().equals("")) { throw new MalformedCookieException( "Blank value for domain attribute"); } domain = domain.toLowerCase(); if (!domain.startsWith(".")) { // Per RFC 2965 section 3.2.2 // "... If an explicitly specified value does not start with // a dot, the user agent supplies a leading dot ..." // That effectively implies that the domain attribute // MAY NOT be an IP address of a host name domain = "." + domain; } cookie.setDomain(domain); cookie.setDomainAttributeSpecified(true); }
this.setDomain(domain); this.setExpiryDate(expires); this.setSecure(secure);
/** * Parse cookie domain attribute. */ public void parse(final Cookie cookie, String domain) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (domain == null) { throw new MalformedCookieException( "Missing value for domain attribute"); } if (domain.trim().equals("")) { throw new MalformedCookieException( "Blank value for domain attribute"); } domain = domain.toLowerCase(); if (!domain.startsWith(".")) { // Per RFC 2965 section 3.2.2 // "... If an explicitly specified value does not start with // a dot, the user agent supplies a leading dot ..." // That effectively implies that the domain attribute // MAY NOT be an IP address of a host name domain = "." + domain; } cookie.setDomain(domain); cookie.setDomainAttributeSpecified(true); }
this.setDomain(domain); this.setExpiryDate(expires); this.setSecure(secure);
"Blank value for domain attribute"); cookie.setDomain(paramValue); cookie.setDomainAttributeSpecified(true);
private org.apache.commons.httpclient.Cookie toHttpClientCookie(Cookie cookie) { org.apache.commons.httpclient.Cookie internal = new org.apache.commons.httpclient.Cookie(); internal.setName(cookie.getName()); internal.setValue(cookie.getValue()); internal.setComment(cookie.getComment()); internal.setDomain(cookie.getDomain()); // internal.setExpiryDate(toExpiry(cookie.getMaxAge())); internal.setPath(cookie.getPath()); internal.setVersion(cookie.getVersion()); return internal; }
"Blank value for domain attribute"); cookie.setDomain(paramValue); cookie.setDomainAttributeSpecified(true);
/** * This method parses the value of an HTTP {@linkplain HttpConstants#HEADER_COOKIE * "Cookie"} header that comes from a client to a server. It returns all the * Cookies present in the header. * * @param headerValue the value of the header from which the cookie will be * parsed. */ public static Cookie[] parseCookiesAsAServer(String headerValue, URI uri) { MimeHeaders mimeHeaders = new MimeHeaders(); mimeHeaders.addValue(HttpConstants.HEADER_COOKIE).setBytes(headerValue.getBytes(), 0, headerValue.length()); Cookies cs = new Cookies(mimeHeaders); Cookie[] cookies = new Cookie[cs.getCookieCount()]; for (int i = 0; i < cs.getCookieCount(); i++) { ServerCookie serverCookie = cs.getCookie(i); cookies[i] = transformServerCookieToClientCookie(serverCookie); if (uri != null) { cookies[i].setSecure(uri.getScheme() != null && uri.getScheme().equalsIgnoreCase("https")); cookies[i].setDomain(uri.getHost()); cookies[i].setPath(uri.getPath()); } } return cookies; }
cookie.setDomain(host);
public Cookie createCookie() throws ParseException { Cookie cookie = new Cookie(); cookie.setName(getName()); cookie.setValue(getValue()); cookie.setDomain(domain); cookie.setPath(path); if(expiryDate != null) { cookie.setExpiryDate(formatExpiryDate(expiryDate)); } if(maxAge != null && expiryDate == null) { cookie.setExpiryDate(new Date(System.currentTimeMillis() + Integer.valueOf(maxAge) * 1000L)); } if(secure != null) { cookie.setSecure(Boolean.valueOf(secure)); } if(version != null) { cookie.setVersion(Integer.valueOf(version)); } return cookie; }
cookie.setName(cookies[i].substring(0, equalPos)); cookie.setValue(cookies[i].substring(equalPos + 1)); cookie.setDomain(serverUri.getHost()); // VERY IMPORTANT
@Override public void applyTo(OwnCloudClient client) { client.getParams().setAuthenticationPreemptive(false); client.getParams().setCredentialCharset(OwnCloudCredentialsFactory.CREDENTIAL_CHARSET); client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); client.setFollowRedirects(false); Uri serverUri = client.getBaseUri(); String[] cookies = mSessionCookie.split(";"); if (cookies.length > 0) { Cookie cookie = null; for (int i=0; i<cookies.length; i++) { int equalPos = cookies[i].indexOf('='); if (equalPos >= 0) { cookie = new Cookie(); cookie.setName(cookies[i].substring(0, equalPos)); cookie.setValue(cookies[i].substring(equalPos + 1)); cookie.setDomain(serverUri.getHost()); // VERY IMPORTANT cookie.setPath(serverUri.getPath()); // VERY IMPORTANT client.getState().addCookie(cookie); } } } }