/** * Adds the specified cookie. * @param cookie the cookie to add */ public synchronized void addCookie(final Cookie cookie) { if (cookie.getValue() == null) { cookie.setValue(""); } cookies_.remove(cookie); cookies_.add(cookie); }
/** * Removes the specified cookie. * @param cookie the cookie to remove */ public synchronized void removeCookie(final Cookie cookie) { if (cookie.getValue() == null) { cookie.setValue(""); } cookies_.remove(cookie); }
/** * Adds the specified cookie. * @param cookie the cookie to add */ public synchronized void addCookie(final Cookie cookie) { if (cookie.getValue() == null) { cookie.setValue(""); } cookies_.remove(cookie); cookies_.add(cookie); }
/** * Removes the specified cookie. * @param cookie the cookie to remove */ public synchronized void removeCookie(final Cookie cookie) { if (cookie.getValue() == null) { cookie.setValue(""); } cookies_.remove(cookie); }
/** * Removes the specified cookie. * @param cookie the cookie to remove */ public synchronized void removeCookie(final Cookie cookie) { if (cookie.getValue() == null) { cookie.setValue(""); } cookies_.remove(cookie); }
/** * Adds the specified cookie. * @param cookie the cookie to add */ public synchronized void addCookie(final Cookie cookie) { if (cookie.getValue() == null) { cookie.setValue(""); } cookies_.remove(cookie); cookies_.add(cookie); }
@Override @SuppressWarnings("unchecked") public Cookie[] asArrayOfCookies(Object cookiesObject) { Map<String, String> cookieMap = (Map<String, String>) cookiesObject; Cookie[] arrayOfCookies = new Cookie[cookieMap.size()]; int i = 0; for (Entry<String, String> cookieEntry : cookieMap.entrySet()) { Cookie cookie = new Cookie(); cookie.setName(cookieEntry.getKey()); cookie.setValue(cookieEntry.getValue()); arrayOfCookies[i++] = cookie; } return arrayOfCookies; }
@Override public Object putAndMergeCookie(Object preExistentCookies, Map<String, String> newCookiesMap) { if (newCookiesMap == null) { return putAndMergeCookie(preExistentCookies, (Cookie[]) null); } else { Cookie[] cookiesArray = new Cookie[newCookiesMap.size()]; int i = 0; for (Entry<String, String> cookieEntry : newCookiesMap.entrySet()) { Cookie cookie = new Cookie(); cookie.setName(cookieEntry.getKey()); cookie.setValue(cookieEntry.getValue()); cookiesArray[i++] = cookie; } return putAndMergeCookie(preExistentCookies, cookiesArray); } }
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; }
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; }
int equalPos = cookies[i].indexOf('='); cookie.setName(cookies[i].substring(0, equalPos)); cookie.setValue(cookies[i].substring(equalPos + 1));
@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); } } } }