Search in sources :

Example 1 with J2EContext

use of org.obiba.oidc.web.J2EContext in project obiba-commons by obiba.

the class OIDCCallbackFilter method doFilterInternal.

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
    J2EContext context = new J2EContext(request, response);
    String provider = OIDCHelper.extractProviderName(context, providerParameter);
    if (Strings.isNullOrEmpty(provider)) {
        log.error("No ID provider could be identified.");
    } else {
        doOIDCDance(context, provider);
    }
    onRedirect(oidcSessionManager.getSession(context.getClientId()), context.getResponse());
    filterChain.doFilter(request, response);
}
Also used : J2EContext(org.obiba.oidc.web.J2EContext)

Example 2 with J2EContext

use of org.obiba.oidc.web.J2EContext in project obiba-commons by obiba.

the class OIDCLoginFilter method doFilterInternal.

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
    J2EContext context = new J2EContext(request, response);
    String provider = OIDCHelper.extractProviderName(context, providerParameter);
    if (Strings.isNullOrEmpty(provider)) {
        log.error("No ID provider could be identified.");
    } else {
        try {
            OIDCConfiguration config = oidcConfigurationProvider.getConfiguration(provider);
            if (config == null)
                throw new OIDCException("No OIDC configuration could be found: " + provider);
            OIDCAuthenticationRequestFactory factory = new OIDCAuthenticationRequestFactory(makeCallbackURL(provider));
            AuthenticationRequest authRequest = factory.create(config);
            if (oidcSessionManager != null) {
                OIDCSession session = makeSession(context, authRequest);
                oidcSessionManager.saveSession(session);
            }
            response.sendRedirect(authRequest.toURI().toString());
        } catch (OIDCException e) {
            log.error("OIDC login request to '{}' failed.", provider, e);
            throw e;
        }
    }
    filterChain.doFilter(request, response);
}
Also used : J2EContext(org.obiba.oidc.web.J2EContext) OIDCAuthenticationRequestFactory(org.obiba.oidc.utils.OIDCAuthenticationRequestFactory) AuthenticationRequest(com.nimbusds.openid.connect.sdk.AuthenticationRequest)

Aggregations

J2EContext (org.obiba.oidc.web.J2EContext)2 AuthenticationRequest (com.nimbusds.openid.connect.sdk.AuthenticationRequest)1 OIDCAuthenticationRequestFactory (org.obiba.oidc.utils.OIDCAuthenticationRequestFactory)1