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);
}
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);
}
Aggregations