@Override public void setExpiry(int expiry) { target.setMaxAge(expiry); }
/** * Processes the logout request. * * @param request * The current request. * @param response * The current response. */ protected int logout(final Request request, final Response response) { // Clears the credentials request.setChallengeResponse(null); final CookieSetting credentialsCookie = this.getCredentialsCookie(request, response); credentialsCookie.setMaxAge(0); this.log.debug("calling attemptRedirect after logout"); // Attempt to redirect this.attemptRedirect(request, response, null); return Filter.STOP; }
result.setMaxAge(-1); } else if (pair.getName().equalsIgnoreCase(NAME_SET_EXPIRES)) { Date expires = DateUtils.parse(pair.getValue(), FORMAT_RFC_1036); final Date current = new Date(System.currentTimeMillis()); if (DateUtils.after(current, expires)) { result.setMaxAge((int) ((expires.getTime() - current.getTime()) / 1000)); } else { result.setMaxAge(0); result.setMaxAge(Integer.valueOf(pair.getValue())); } catch (NumberFormatException numberFormatException) { result.setMaxAge(Integer.MAX_VALUE); Context.getCurrentLogger() .warning(
credentialsCookie.setMaxAge(this.getMaxCookieAge());
@Override protected void afterHandle(Request request, Response response) { super.afterHandle(request, response); Cookie cookie = request.getCookies().getFirst("Credentials"); if (request.getClientInfo().isAuthenticated() && (cookie == null)) { String identifier = request.getChallengeResponse().getIdentifier(); String secret = new String(request.getChallengeResponse() .getSecret()); CookieSetting cookieSetting = new CookieSetting("Credentials", identifier + "=" + secret); cookieSetting.setAccessRestricted(true); cookieSetting.setPath("/"); cookieSetting.setComment("Unsecured cookie based authentication"); cookieSetting.setMaxAge(30); response.getCookieSettings().add(cookieSetting); } }
@Override protected void afterHandle(Request request, Response response) { super.afterHandle(request, response); Cookie cookie = request.getCookies().getFirst("Credentials"); if (request.getClientInfo().isAuthenticated() && (cookie == null)) { String identifier = request.getChallengeResponse().getIdentifier(); String secret = new String(request.getChallengeResponse() .getSecret()); CookieSetting cookieSetting = new CookieSetting("Credentials", identifier + "=" + secret); cookieSetting.setAccessRestricted(true); cookieSetting.setPath("/"); cookieSetting.setComment("Unsecured cookie based authentication"); cookieSetting.setMaxAge(30); response.getCookieSettings().add(cookieSetting); } }