@Override public void setDomain( String domain ) { c.setDomain( domain ); }
@Override public RestxResponse addCookie(String cookie, String value, RestxSessionCookieDescriptor cookieDescriptor, Duration expiration) { Cookie c = new Cookie(cookie, value, "/"); c.setExpiry(expiration.getStandardSeconds() > 0 ? (int) expiration.getStandardSeconds() : -1); if(cookieDescriptor.getDomain().isPresent()) { c.setDomain(cookieDescriptor.getDomain().get()); } if(cookieDescriptor.getSecure().isPresent()) { c.setSecure(cookieDescriptor.getSecure().get().booleanValue()); } response.setCookie(c); return this; }
@Override public RestxResponse clearCookie(String cookie, RestxSessionCookieDescriptor cookieDescriptor) { Cookie c = new Cookie(cookie, ""); c.setPath("/"); c.setExpiry(0); if(cookieDescriptor.getDomain().isPresent()) { c.setDomain(cookieDescriptor.getDomain().get()); } if(cookieDescriptor.getSecure().isPresent()) { c.setSecure(cookieDescriptor.getSecure().get().booleanValue()); } response.setCookie(c); return this; }
@Override public RestxResponse clearCookie(String cookie, RestxSessionCookieDescriptor cookieDescriptor) { Cookie c = new Cookie(cookie, ""); c.setPath("/"); c.setExpiry(0); if(cookieDescriptor.getDomain().isPresent()) { c.setDomain(cookieDescriptor.getDomain().get()); } if(cookieDescriptor.getSecure().isPresent()) { c.setSecure(cookieDescriptor.getSecure().get().booleanValue()); } response.setCookie(c); return this; }
@Override public RestxResponse addCookie(String cookie, String value, RestxSessionCookieDescriptor cookieDescriptor, Duration expiration) { Cookie c = new Cookie(cookie, value, "/"); c.setExpiry(expiration.getStandardSeconds() > 0 ? (int) expiration.getStandardSeconds() : -1); if(cookieDescriptor.getDomain().isPresent()) { c.setDomain(cookieDescriptor.getDomain().get()); } if(cookieDescriptor.getSecure().isPresent()) { c.setSecure(cookieDescriptor.getSecure().get().booleanValue()); } response.setCookie(c); return this; }
/** * Creates the <code>Cookie</code> from the token objects. It is * assumed that the <code>Cookie</code> <code>String</code> has * been parsed when this is called. This should only be used after * the <code>parse</code> method has been called. * <p> * If there is no <code>$Domain</code> or <code>$Path</code> * within the <code>Cookie</code> <code>String</code> then the * <code>getDomain</code> and <code>getPath</code> are null. * * @param name the name that the <code>Cookie</code> contains * @param value the value that the <code>Cookie</code> contains * * @return the <code>Cookie</code> that was just parsed */ private Cookie getCookie(String name, String value) { Cookie cookie = new Cookie(name, value, false); if(domain.len > 0) { cookie.setDomain(domain.toString()); } if(path.len > 0) { cookie.setPath(path.toString()); } cookie.setVersion(version); return cookie; }
/** * Creates the <code>Cookie</code> from the token objects. It is * assumed that the <code>Cookie</code> <code>String</code> has * been parsed when this is called. This should only be used after * the <code>parse</code> method has been called. * <p> * If there is no <code>$Domain</code> or <code>$Path</code> * within the <code>Cookie</code> <code>String</code> then the * <code>getDomain</code> and <code>getPath</code> are null. * * @param name the name that the <code>Cookie</code> contains * @param value the value that the <code>Cookie</code> contains * * @return the <code>Cookie</code> that was just parsed */ private Cookie getCookie(String name, String value) { Cookie cookie = new Cookie(name, value, false); if(domain.len > 0) { cookie.setDomain(domain.toString()); } if(path.len > 0) { cookie.setPath(path.toString()); } cookie.setVersion(version); return cookie; }
/** * Creates the <code>Cookie</code> from the token objects. It is * assumed that the <code>Cookie</code> <code>String</code> has * been parsed when this is called. This should only be used after * the <code>parse</code> method has been called. * <p> * If there is no <code>$Domain</code> or <code>$Path</code> * within the <code>Cookie</code> <code>String</code> then the * <code>getDomain</code> and <code>getPath</code> are null. * * @param name the name that the <code>Cookie</code> contains * @param value the value that the <code>Cookie</code> contains * * @return the <code>Cookie</code> that was just parsed */ private Cookie getCookie(String name, String value) { Cookie cookie = new Cookie(name, value, false); if(domain.len > 0) { cookie.setDomain(domain.toString()); } if(path.len > 0) { cookie.setPath(path.toString()); } cookie.setVersion(version); return cookie; }
@Override public Cookie setCookie( Cookie cookie ) { if( cookie instanceof SimpletonCookie) { SimpletonCookie sc = (SimpletonCookie) cookie; baseResponse.setCookie( sc.getWrapped()); return cookie; } else { org.simpleframework.http.Cookie c = new org.simpleframework.http.Cookie( cookie.getName(), cookie.getValue()); c.setDomain( cookie.getDomain()); c.setExpiry( cookie.getExpiry()); c.setPath( cookie.getPath()); c.setSecure( cookie.getSecure()); c.setVersion( cookie.getVersion()); baseResponse.setCookie( c ); return new SimpletonCookie( c ); } }
@Override public void setCookie(Cookie newCookie) { CookieDate cookieDate = new CookieDate(); org.simpleframework.http.Cookie cookie = new org.simpleframework.http.Cookie(newCookie.name(), newCookie.value(), newCookie.path(), newCookie.isNew()) { @Override public String toString() { return getName() + "=" + getValue() + "; version=" + getVersion() + (getPath() == null ? "" : "; path=" + getPath()) + (getDomain() == null ? "" : "; domain=" + getDomain()) + (getExpiry() < 0 ? "" : "; expires=" + cookieDate.format(getExpiry())) + (getExpiry() < 0 ? "" : "; max-age=" + getExpiry()) + (isSecure() ? "; secure" : "") + (isProtected() ? "; httponly" : ""); } }; cookie.setExpiry(newCookie.expiry()); cookie.setVersion(newCookie.version()); cookie.setSecure(newCookie.isSecure()); cookie.setProtected(newCookie.isHttpOnly()); cookie.setDomain(newCookie.domain()); response.setCookie(cookie); }