Java Code Examples for org.keycloak.adapters.KeycloakDeployment#getTokenStore()

The following examples show how to use org.keycloak.adapters.KeycloakDeployment#getTokenStore() . 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: UndertowKeycloakConsumer.java    From keycloak with Apache License 2.0 5 votes vote down vote up
protected AdapterTokenStore getTokenStore(HttpServerExchange exchange, HttpFacade facade, KeycloakDeployment deployment, SecurityContext securityContext) {
    if (deployment.getTokenStore() == TokenStore.SESSION) {
        return new UndertowSessionTokenStore(exchange, deployment, userSessionManagement, securityContext);
    } else {
        return new UndertowCookieTokenStore(facade, deployment, securityContext);
    }
}
 
Example 3
Source File: AbstractKeycloakAuthenticatorValve.java    From keycloak with Apache License 2.0 5 votes vote down vote up
protected AdapterTokenStore getTokenStore(Request request, HttpFacade facade, KeycloakDeployment resolvedDeployment) {
    AdapterTokenStore store = (AdapterTokenStore)request.getNote(TOKEN_STORE_NOTE);
    if (store != null) {
        return store;
    }

    if (resolvedDeployment.getTokenStore() == TokenStore.SESSION) {
        store = createSessionTokenStore(request, resolvedDeployment);
    } else {
        store = new CatalinaCookieTokenStore(request, facade, resolvedDeployment, createPrincipalFactory());
    }

    request.setNote(TOKEN_STORE_NOTE, store);
    return store;
}
 
Example 4
Source File: SpringSecurityAdapterTokenStoreFactory.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public AdapterTokenStore createAdapterTokenStore(KeycloakDeployment deployment, HttpServletRequest request, HttpServletResponse response) {
    Assert.notNull(deployment, "KeycloakDeployment is required");
    if (deployment.getTokenStore() == TokenStore.COOKIE) {
        return new SpringSecurityCookieTokenStore(deployment, request, response);
    }
    return new SpringSecurityTokenStore(deployment, request);
}
 
Example 5
Source File: AbstractUndertowKeycloakAuthMech.java    From keycloak with Apache License 2.0 5 votes vote down vote up
protected AdapterTokenStore getTokenStore(HttpServerExchange exchange, HttpFacade facade, KeycloakDeployment deployment, SecurityContext securityContext) {
    if (deployment.getTokenStore() == TokenStore.SESSION) {
        return new UndertowSessionTokenStore(exchange, deployment, sessionManagement, securityContext);
    } else {
        return new UndertowCookieTokenStore(facade, deployment, securityContext);
    }
}
 
Example 6
Source File: ServletKeycloakAuthMech.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
protected AdapterTokenStore getTokenStore(HttpServerExchange exchange, HttpFacade facade, KeycloakDeployment deployment, SecurityContext securityContext) {
    if (deployment.getTokenStore() == TokenStore.SESSION) {
        return new ServletSessionTokenStore(exchange, deployment, sessionManagement, securityContext);
    } else {
        return new UndertowCookieTokenStore(facade, deployment, securityContext);
    }
}
 
Example 7
Source File: AbstractKeycloakJettyAuthenticator.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public AdapterTokenStore getTokenStore(Request request, HttpFacade facade, KeycloakDeployment resolvedDeployment) {
    AdapterTokenStore store = (AdapterTokenStore) request.getAttribute(TOKEN_STORE_NOTE);
    if (store != null) {
        return store;
    }

    if (resolvedDeployment.getTokenStore() == TokenStore.SESSION) {
        store = createSessionTokenStore(request, resolvedDeployment);
    } else {
        store = new JettyCookieTokenStore(request, facade, resolvedDeployment);
    }

    request.setAttribute(TOKEN_STORE_NOTE, store);
    return store;
}