Java Code Examples for org.eclipse.jetty.server.Request#getBaseRequest()

The following examples show how to use org.eclipse.jetty.server.Request#getBaseRequest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeycloakAuthFilter.java    From keycloak-dropwizard-integration with Apache License 2.0 6 votes vote down vote up
public static AdapterTokenStore getTokenStore(HttpServletRequest request, HttpFacade facade,
                                              KeycloakDeployment resolvedDeployment) {
    AdapterTokenStore store = (AdapterTokenStore) request.getAttribute(TOKEN_STORE_NOTE);
    if (store != null) {
        return store;
    }

    Request r = Request.getBaseRequest(request);
    if (resolvedDeployment.getTokenStore() == TokenStore.SESSION) {
        store = new JettySessionTokenStore(r, resolvedDeployment, new JettyAdapterSessionStore(r));
    } else {
        store = new JettyCookieTokenStore(r, facade, resolvedDeployment);
    }

    request.setAttribute(TOKEN_STORE_NOTE, store);
    return store;
}
 
Example 2
Source File: PushEchoServlet.java    From http2-examples with Apache License 2.0 5 votes vote down vote up
private void push(HttpServletRequest req) {
    Request baseRequest = Request.getBaseRequest(req);
    if (baseRequest.isPushSupported()) {
        baseRequest
                .getPushBuilder()
                .method("GET")
                .path("/data")
                .push();
    }
}
 
Example 3
Source File: KeycloakAuthFilter.java    From keycloak-dropwizard-integration with Apache License 2.0 5 votes vote down vote up
public void validateRequest(final ContainerRequestContext requestContext) {
    if (requestContext.getSecurityContext().getUserPrincipal() != null) {
        // the user is already authenticated, further processing is not necessary
        return;
    }
    Request request = Request.getBaseRequest((ServletRequest)
            requestContext.getProperty(HttpServletRequest.class.getName()));
    JaxrsHttpFacade facade = new JaxrsHttpFacade(requestContext, requestContext.getSecurityContext());
    request.setAttribute(AdapterDeploymentContext.class.getName(), deploymentContext);

    KeycloakDeployment deployment = deploymentContext.resolveDeployment(facade);
    if (deployment == null || !deployment.isConfigured()) {
        return;
    }

    AdapterTokenStore tokenStore = getTokenStore(request, facade, deployment);

    tokenStore.checkCurrentToken();
    JettyRequestAuthenticator authenticator = createRequestAuthenticator(request, facade, deployment, tokenStore);
    AuthOutcome outcome = authenticator.authenticate();
    if (outcome == AuthOutcome.AUTHENTICATED) {
        return;
    }
    AuthChallenge challenge = authenticator.getChallenge();
    if (challenge != null) {
        challenge.challenge(facade);
        if (!adapterConfig.isBearerOnly()) {
            // create session and set cookie for client
            facade.getResponse().setCookie("JSESSIONID", request.getSession().getId(), "/", null, -1, false, false);
        }
        facade.getResponse().end();
    }
}
 
Example 4
Source File: KeycloakAuthFilter.java    From keycloak-dropwizard-integration with Apache License 2.0 4 votes vote down vote up
protected JettyRequestAuthenticator createRequestAuthenticator(HttpServletRequest request, JaxrsHttpFacade facade,
                                                               KeycloakDeployment deployment,
                                                               AdapterTokenStore tokenStore) {
    Request r = Request.getBaseRequest(request);
    return new JettyRequestAuthenticator(facade, deployment, tokenStore, -1, r);
}
 
Example 5
Source File: KeycloakJettyAuthenticator.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
protected Request resolveRequest(ServletRequest req) {
    return Request.getBaseRequest(req);
}
 
Example 6
Source File: KeycloakJettyAuthenticator.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
protected Request resolveRequest(ServletRequest req) {
    return Request.getBaseRequest(req);
}
 
Example 7
Source File: KeycloakSamlAuthenticator.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
protected Request resolveRequest(ServletRequest req) {
   return Request.getBaseRequest(req);
}
 
Example 8
Source File: KeycloakSamlAuthenticator.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
protected Request resolveRequest(ServletRequest req) {
   return Request.getBaseRequest(req);
}
 
Example 9
Source File: PHttpGzipFilter.java    From jphp with Apache License 2.0 4 votes vote down vote up
@Signature
public void __invoke(PHttpServerRequest request, PHttpServerResponse response) throws IOException, ServletException {
    Request baseRequest = Request.getBaseRequest(request.getRequest());

    gzipHandler.handle(request.getRequest().getRequestURI(), baseRequest, request.getRequest(), response.getResponse());
}