@Override public void setExpiry( int expiry ) { c.setExpiry( expiry ); }
@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 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 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); }
@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 ); } }