/** * Creates a cookie with the given name, value, domain attribute, * path attribute, maximum age attribute, and secure attribute * * @param name the cookie name * @param value the cookie value * @param domain the domain this cookie can be sent to * @param path the path prefix for which this cookie can be sent * @param maxAge the number of seconds for which this cookie is valid. * maxAge is expected to be a non-negative number. * <tt>-1</tt> signifies that the cookie should never expire. * @param secure if <tt>true</tt> this cookie can only be sent over secure * connections */ public Cookie(String domain, String name, String value, String path, int maxAge, boolean secure) { this(domain, name, value, path, null, secure); if (maxAge < -1) { throw new IllegalArgumentException("Invalid max age: " + Integer.toString(maxAge)); } if (maxAge >= 0) { setExpiryDate(new Date(System.currentTimeMillis() + maxAge * 1000L)); } }
/** * Parse cookie max-age attribute. */ public void parse(final Cookie cookie, final String value) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (value == null) { throw new MalformedCookieException( "Missing value for max-age attribute"); } int age = -1; try { age = Integer.parseInt(value); } catch (NumberFormatException e) { age = -1; } if (age < 0) { throw new MalformedCookieException ("Invalid max-age attribute."); } cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L)); }
this.setExpiryDate(expires); this.setSecure(secure);
"EEE, dd-MMM-yyyy HH:mm:ss z", Locale.US); Date date = expiryFormat.parse(paramValue); cookie.setExpiryDate(date); } catch (ParseException e) { throw new MalformedCookieException("Invalid expires "
+ "attribute: " + e.getMessage()); cookie.setExpiryDate( new Date(System.currentTimeMillis() + age * 1000L)); cookie.setExpiryDate(DateUtil.parseDate(paramValue, this.datepatterns)); } catch (DateParseException dpe) { LOG.debug("Error parsing cookie date", dpe);
/** * Creates a cookie with the given name, value, domain attribute, * path attribute, maximum age attribute, and secure attribute * * @param name the cookie name * @param value the cookie value * @param domain the domain this cookie can be sent to * @param path the path prefix for which this cookie can be sent * @param maxAge the number of seconds for which this cookie is valid. * maxAge is expected to be a non-negative number. * <tt>-1</tt> signifies that the cookie should never expire. * @param secure if <tt>true</tt> this cookie can only be sent over secure * connections */ public Cookie(String domain, String name, String value, String path, int maxAge, boolean secure) { this(domain, name, value, path, null, secure); if (maxAge < -1) { throw new IllegalArgumentException("Invalid max age: " + Integer.toString(maxAge)); } if (maxAge >= 0) { setExpiryDate(new Date(System.currentTimeMillis() + maxAge * 1000L)); } }
/** * Creates a cookie with the given name, value, domain attribute, * path attribute, maximum age attribute, and secure attribute * * @param name the cookie name * @param value the cookie value * @param domain the domain this cookie can be sent to * @param path the path prefix for which this cookie can be sent * @param maxAge the number of seconds for which this cookie is valid. * maxAge is expected to be a non-negative number. * <tt>-1</tt> signifies that the cookie should never expire. * @param secure if <tt>true</tt> this cookie can only be sent over secure * connections */ public Cookie(String domain, String name, String value, String path, int maxAge, boolean secure) { this(domain, name, value, path, null, secure); if (maxAge < -1) { throw new IllegalArgumentException("Invalid max age: " + Integer.toString(maxAge)); } if (maxAge >= 0) { setExpiryDate(new Date(System.currentTimeMillis() + maxAge * 1000L)); } }
/** * Creates a cookie with the given name, value, domain attribute, * path attribute, maximum age attribute, and secure attribute * * @param name the cookie name * @param value the cookie value * @param domain the domain this cookie can be sent to * @param path the path prefix for which this cookie can be sent * @param maxAge the number of seconds for which this cookie is valid. * maxAge is expected to be a non-negative number. * <tt>-1</tt> signifies that the cookie should never expire. * @param secure if <tt>true</tt> this cookie can only be sent over secure * connections */ public Cookie(String domain, String name, String value, String path, int maxAge, boolean secure) { this(domain, name, value, path, null, secure); if (maxAge < -1) { throw new IllegalArgumentException("Invalid max age: " + Integer.toString(maxAge)); } if (maxAge >= 0) { setExpiryDate(new Date(System.currentTimeMillis() + maxAge * 1000L)); } }
/** * Creates a cookie with the given name, value, domain attribute, * path attribute, maximum age attribute, and secure attribute * * @param name the cookie name * @param value the cookie value * @param domain the domain this cookie can be sent to * @param path the path prefix for which this cookie can be sent * @param maxAge the number of seconds for which this cookie is valid. * maxAge is expected to be a non-negative number. * <tt>-1</tt> signifies that the cookie should never expire. * @param secure if <tt>true</tt> this cookie can only be sent over secure * connections */ public Cookie(String domain, String name, String value, String path, int maxAge, boolean secure) { this(domain, name, value, path, null, secure); if (maxAge < -1) { throw new IllegalArgumentException("Invalid max age: " + Integer.toString(maxAge)); } if (maxAge >= 0) { setExpiryDate(new Date(System.currentTimeMillis() + maxAge * 1000L)); } }
/** * Parse cookie max-age attribute. */ public void parse(final Cookie cookie, final String value) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (value == null) { throw new MalformedCookieException( "Missing value for max-age attribute"); } int age = -1; try { age = Integer.parseInt(value); } catch (NumberFormatException e) { age = -1; } if (age < 0) { throw new MalformedCookieException ("Invalid max-age attribute."); } cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L)); }
/** * Parse cookie max-age attribute. */ public void parse(final Cookie cookie, final String value) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (value == null) { throw new MalformedCookieException( "Missing value for max-age attribute"); } int age = -1; try { age = Integer.parseInt(value); } catch (NumberFormatException e) { age = -1; } if (age < 0) { throw new MalformedCookieException ("Invalid max-age attribute."); } cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L)); }
/** * Parse cookie max-age attribute. */ public void parse(final Cookie cookie, final String value) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (value == null) { throw new MalformedCookieException( "Missing value for max-age attribute"); } int age = -1; try { age = Integer.parseInt(value); } catch (NumberFormatException e) { age = -1; } if (age < 0) { throw new MalformedCookieException ("Invalid max-age attribute."); } cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L)); }
/** * Parse cookie max-age attribute. */ public void parse(final Cookie cookie, final String value) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (value == null) { throw new MalformedCookieException( "Missing value for max-age attribute"); } int age = -1; try { age = Integer.parseInt(value); } catch (NumberFormatException e) { age = -1; } if (age < 0) { throw new MalformedCookieException ("Invalid max-age attribute."); } cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L)); }
/** * 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()]); }
this.setExpiryDate(expires); this.setSecure(secure);
this.setExpiryDate(expires); this.setSecure(secure);
this.setExpiryDate(expires); this.setSecure(secure);
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.setExpiryDate(DateUtil.parseDate(partValue));
cookie.setExpiryDate(DateUtil.parseDate(partValue));