use of org.restlet.data.Cookie in project camel by apache.
the class RestletProducer method loadCookies.
private void loadCookies(Exchange exchange, URI uri, Request request) throws IOException {
RestletEndpoint endpoint = (RestletEndpoint) getEndpoint();
if (endpoint.getCookieHandler() != null) {
Series<Cookie> cookies = request.getCookies();
Map<String, List<String>> cookieHeaders = endpoint.getCookieHandler().loadCookies(exchange, uri);
// parse the cookies
for (String cookieHeader : cookieHeaders.keySet()) {
for (String cookieStr : cookieHeaders.get(cookieHeader)) {
for (HttpCookie cookie : HttpCookie.parse(cookieStr)) {
cookies.add(new Cookie(cookie.getVersion(), cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getDomain()));
}
}
}
}
}
use of org.restlet.data.Cookie in project vcell by virtualcell.
the class VCellCookieAuthenticator method logout.
@Override
protected int logout(Request request, Response response) {
try {
Cookie credentialsCookie = request.getCookies().getFirst(getCookieName());
if (credentialsCookie != null) {
ChallengeResponse challengeResponse = parseCredentials(credentialsCookie.getValue());
ApiAccessToken apiAccessToken = vcellApiApplication.getApiAccessToken(challengeResponse);
if (apiAccessToken != null) {
vcellApiApplication.getUserVerifier().invalidateApiAccessToken(apiAccessToken.getToken());
getLogger().log(Level.INFO, "MyCookieAuthenticator.login(request,response) - invalidated accessToken '" + apiAccessToken.getToken() + "'");
}
}
} catch (Exception e) {
e.printStackTrace(System.out);
getLogger().log(Level.SEVERE, "MyCookieAuthenticator.logout(request,response) - exception while invalidating '" + CustomAuthHelper.ACCESS_TOKEN + "'", e);
}
return super.logout(request, response);
}
Aggregations