/** * Returns the cookie settings provided by the server. * * @return The cookie settings provided by the server. */ @Override public Series<CookieSetting> getCookieSettings() { return getWrappedResponse().getCookieSettings(); }
/** * Sets the modifiable series of cookie settings provided by the server. * Note that when used with HTTP connectors, this property maps to the * "Set-Cookie" and "Set-Cookie2" headers. This method clears the current * series and adds all entries in the parameter series. * * @param cookieSettings * A series of cookie settings provided by the server. */ public void setCookieSettings(Series<CookieSetting> cookieSettings) { synchronized (getCookieSettings()) { if (cookieSettings != getCookieSettings()) { getCookieSettings().clear(); if (cookieSettings != null) { getCookieSettings().addAll(cookieSettings); } } } }
/** * Returns the modifiable series of cookie settings provided by the server. * Creates a new instance if no one has been set. * * @return The cookie settings provided by the server. * @see Response#getCookieSettings() */ public Series<CookieSetting> getCookieSettings() { return getResponse() == null ? null : getResponse().getCookieSettings(); }
/** * Returns the modifiable series of cookie settings provided by the server. * Creates a new instance if no one has been set. * * @return The cookie settings provided by the server. * @see Response#getCookieSettings() */ public static Series<CookieSetting> getResourceCookieSettings() { return getResourceResponse() == null ? null : getResourceResponse().getCookieSettings(); }
private String setupState(Response response) { String sessionId = UUID.randomUUID().toString(); byte[] secret = new byte[20]; random.nextBytes(secret); String state = Base64.encode(secret, false); CookieSetting cs = new CookieSetting("_state", sessionId); response.getCookieSettings().add(cs); getContext().getAttributes().put(sessionId, state); return state; }
@Override public void addNewCookie(NewCookie cookie) { getResponse().getCookieSettings().add(toRestletCookieSetting(cookie)); }
public Representation login( String name, String password ) { context( Login.class ).login( name, password ); EmptyRepresentation rep = new EmptyRepresentation(); Response.getCurrent().getCookieSettings().add( "user", name ); return rep; } }
CookieSetting credentialsCookie = response.getCookieSettings().getFirst(this.getCookieName()); response.getCookieSettings().add(credentialsCookie);
/** * Restores credentials from the cookie named {@link #getCookieName()} if available. The usual * processing is the followed. */ @Override protected boolean authenticate(final Request request, final Response response) { // Restore credentials from the cookie final Cookie credentialsCookie = request.getCookies().getFirst(this.getCookieName()); if(credentialsCookie != null) { ChallengeResponse credentials = this.parseCredentials(credentialsCookie.getValue()); if(credentials == null) { response.getCookieSettings().removeAll(this.getCookieName()); } else { request.setChallengeResponse(credentials); } } this.log.debug("Calling super.authenticate"); return super.authenticate(request, response); }
try { CookieSettingReader cr = new CookieSettingReader(header.getValue()); response.getCookieSettings().add(cr.readValue()); } catch (Exception e) { Context.getCurrentLogger().log(
@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); } }
for (CookieSetting cookieSetting : response.getCookieSettings()) { addHeader(HEADER_SET_COOKIE, CookieSettingWriter.write(cookieSetting), headers);