List of usage examples for com.google.common.net HttpHeaders SET_COOKIE
String SET_COOKIE
To view the source code for com.google.common.net HttpHeaders SET_COOKIE.
Click Source Link
From source file:org.jclouds.abiquo.functions.auth.GetTokenFromApi.java
@VisibleForTesting static Optional<Cookie> readAuthenticationToken(final HttpResponse response) { Collection<String> cookies = response.getHeaders().get(HttpHeaders.SET_COOKIE); return tryFind(transform(cookies, cookie()), new Predicate<Cookie>() { @Override// ww w .j a v a 2s .com public boolean apply(Cookie input) { return input.getName().equals(AUTH_TOKEN_NAME); } }); }
From source file:keywhiz.service.filters.CookieRenewingFilter.java
/** * If the user has a valid session token, set a new session token. The new one should have a later * expiration time./*w w w. j a v a2 s .c o m*/ */ @Override public void filter(ContainerRequestContext request, ContainerResponseContext response) throws IOException { String sessionCookieName = sessionCookieConfig.getName(); // If the response will be setting a session cookie, don't overwrite it; just let it go. if (response.getCookies().containsKey(sessionCookieName)) { return; } // If the request doesn't have a session cookie, we're not going to renew one. if (!request.getCookies().containsKey(sessionCookieName)) { return; } Cookie requestCookie = request.getCookies().get(sessionCookieName); Optional<User> optionalUser = authenticator.authenticate(requestCookie); if (optionalUser.isPresent()) { sessionLoginResource.cookiesForUser(optionalUser.get()) .forEach(c -> response.getHeaders().add(HttpHeaders.SET_COOKIE, c)); } }