public static void addFlash(Response response, String message, Kind kind) { dropboxes.put(nextdrop,new Flash(message, kind)); Series<CookieSetting> cookies = response.getCookieSettings(); CookieSetting flashdrop = null; for(CookieSetting cs : cookies) { if(cs.getName().equals("flashdrop")) { flashdrop = cs; } } if(flashdrop == null) { cookies.add(new CookieSetting("flashdrop",Long.toString(nextdrop))); } else { flashdrop.setValue(flashdrop.getValue()+","+Long.toString(nextdrop)); } nextdrop++; }
@Override public CookieSetting createEntry(String name, String value) { return new CookieSetting(name, value); }
public CookieAdapter(String name, String value) { target = new CookieSetting(name, value); }
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; }
public static void addFlash(Response response, String message, Kind kind) { dropboxes.put(nextdrop,new Flash(message, kind)); Series<CookieSetting> cookies = response.getCookieSettings(); CookieSetting flashdrop = null; for(CookieSetting cs : cookies) { if(cs.getName().equals("flashdrop")) { flashdrop = cs; } } if(flashdrop == null) { cookies.add(new CookieSetting("flashdrop",Long.toString(nextdrop))); } else { flashdrop.setValue(flashdrop.getValue()+","+Long.toString(nextdrop)); } nextdrop++; }
public CookieAdapter(org.restlet.data.Cookie target) { this.target = new CookieSetting( target.getVersion(), target.getName(), target.getValue(), target.getPath(), target.getDomain() ); }
public CookieAdapter(Cookie cookie) { target = new CookieSetting( cookie.getVersion(), cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getDomain(), null, cookie.getExpiry(), cookie.getSecure(), false ); }
/** * Sets up a new authorization session. * * @param redirectUri * The redirection URI. */ protected static AuthSession setupAuthSession(RedirectionURI redirectUri) { getLogger().fine("Base ref = " + getReference().getParentRef()); AuthSession session = AuthSession.newAuthSession(); session.setRedirectionURI(redirectUri); CookieSetting cs = new CookieSetting(ClientCookieID, session.getId()); // TODO create a secure mode setting, update all cookies // cs.setAccessRestricted(true); // cs.setSecure(true); getResourceCookieSettings().add(cs); getLogger().fine("Setting cookie in SetupSession - " + session.getId()); getResourceContext().getAttributes().put(session.getId(), session); return session; }
/** * Sets up a new authorization session. * * @param redirectUri * The redirection URI. */ protected AuthSession setupAuthSession(RedirectionURI redirectUri) { getLogger().fine("Base ref = " + getReference().getParentRef()); AuthSession session = AuthSession.newAuthSession(); session.setRedirectionURI(redirectUri); CookieSetting cs = new CookieSetting(ClientCookieID, session.getId()); // TODO create a secure mode setting, update all cookies // cs.setAccessRestricted(true); // cs.setSecure(true); getCookieSettings().add(cs); getLogger().fine("Setting cookie in SetupSession - " + session.getId()); getContext().getAttributes().put(session.getId(), session); return session; }
/** * Converts the Restlet JAX-RS NewCookie to a CookieSettings. * * @param newCookie * @return the converted CookieSetting * @throws IllegalArgumentException */ public static CookieSetting toRestletCookieSetting(NewCookie newCookie) throws IllegalArgumentException { if (newCookie == null) { return null; } return new CookieSetting(newCookie.getVersion(), newCookie.getName(), newCookie.getValue(), newCookie.getPath(), newCookie.getDomain(), newCookie.getComment(), newCookie.getMaxAge(), newCookie.isSecure()); }
/** * Converts the Restlet JAX-RS NewCookie to a CookieSettings. * * @param newCookie * @return the converted CookieSetting * @throws IllegalArgumentException */ public static CookieSetting toRestletCookieSetting(NewCookie newCookie) throws IllegalArgumentException { if (newCookie == null) { return null; } return new CookieSetting(newCookie.getVersion(), newCookie.getName(), newCookie.getValue(), newCookie.getPath(), newCookie.getDomain(), newCookie.getComment(), newCookie.getMaxAge(), newCookie.isSecure()); }
CookieSetting result = new CookieSetting(pair.getName(), pair.getValue());
@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); } }
credentialsCookie = new CookieSetting(this.getCookieName(), null); credentialsCookie.setAccessRestricted(true);