Search in sources :

Example 1 with Cookie

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()));
                }
            }
        }
    }
}
Also used : HttpCookie(java.net.HttpCookie) Cookie(org.restlet.data.Cookie) List(java.util.List) HttpCookie(java.net.HttpCookie)

Example 2 with Cookie

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);
}
Also used : Cookie(org.restlet.data.Cookie) ApiAccessToken(cbit.vcell.modeldb.ApiAccessToken) DataAccessException(org.vcell.util.DataAccessException) SQLException(java.sql.SQLException) ChallengeResponse(org.restlet.data.ChallengeResponse)

Aggregations

Cookie (org.restlet.data.Cookie)2 ApiAccessToken (cbit.vcell.modeldb.ApiAccessToken)1 HttpCookie (java.net.HttpCookie)1 SQLException (java.sql.SQLException)1 List (java.util.List)1 ChallengeResponse (org.restlet.data.ChallengeResponse)1 DataAccessException (org.vcell.util.DataAccessException)1