/** * Parse cookie path attribute. */ public void parse(final Cookie cookie, final String path) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (path == null) { throw new MalformedCookieException( "Missing value for path attribute"); } if (path.trim().equals("")) { throw new MalformedCookieException( "Blank value for path attribute"); } cookie.setPath(path); cookie.setPathAttributeSpecified(true); }
throw new IllegalArgumentException("Cookie name may not be blank"); this.setPath(path); this.setDomain(domain); this.setExpiryDate(expires);
"Blank value for path attribute"); cookie.setPath(paramValue); cookie.setPathAttributeSpecified(true); } else if (paramName.equals("version")) {
/** * 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()]); }
paramValue = "/"; cookie.setPath(paramValue); cookie.setPathAttributeSpecified(true);
throw new IllegalArgumentException("Cookie name may not be blank"); this.setPath(path); this.setDomain(domain); this.setExpiryDate(expires);
/** * Parse cookie path attribute. */ public void parse(final Cookie cookie, final String path) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (path == null) { throw new MalformedCookieException( "Missing value for path attribute"); } if (path.trim().equals("")) { throw new MalformedCookieException( "Blank value for path attribute"); } cookie.setPath(path); cookie.setPathAttributeSpecified(true); }
throw new IllegalArgumentException("Cookie name may not be blank"); this.setPath(path); this.setDomain(domain); this.setExpiryDate(expires);
/** * Parse cookie path attribute. */ public void parse(final Cookie cookie, final String path) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (path == null) { throw new MalformedCookieException( "Missing value for path attribute"); } if (path.trim().equals("")) { throw new MalformedCookieException( "Blank value for path attribute"); } cookie.setPath(path); cookie.setPathAttributeSpecified(true); }
throw new IllegalArgumentException("Cookie name may not be blank"); this.setPath(path); this.setDomain(domain); this.setExpiryDate(expires);
/** * Parse cookie path attribute. */ public void parse(final Cookie cookie, final String path) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (path == null) { throw new MalformedCookieException( "Missing value for path attribute"); } if (path.trim().equals("")) { throw new MalformedCookieException( "Blank value for path attribute"); } cookie.setPath(path); cookie.setPathAttributeSpecified(true); }
throw new IllegalArgumentException("Cookie name may not be blank"); this.setPath(path); this.setDomain(domain); this.setExpiryDate(expires);
/** * Parse cookie path attribute. */ public void parse(final Cookie cookie, final String path) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (path == null) { throw new MalformedCookieException( "Missing value for path attribute"); } if (path.trim().equals("")) { throw new MalformedCookieException( "Blank value for path attribute"); } cookie.setPath(path); cookie.setPathAttributeSpecified(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; }
/** * 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; }
final String partValue = StringUtils.substringAfter(parts[i], "=").trim(); if ("path".equals(partName)) { cookie.setPath(partValue);
final String partValue = StringUtils.substringAfter(parts[i], "=").trim(); if ("path".equals(partName)) { cookie.setPath(partValue);
final String partValue = StringUtils.substringAfter(parts[i], "=").trim(); if ("path".equals(partName)) { cookie.setPath(partValue);
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; }
@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); } } } }