use of org.obiba.oidc.utils.OIDCAuthenticationRequestFactory 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);
}
use of org.obiba.oidc.utils.OIDCAuthenticationRequestFactory in project obiba-commons by obiba.
the class OIDCTest method test.
@Test
@Ignore
public void test() throws IOException, URISyntaxException, ParseException {
KeycloakOIDCConfiguration config = new KeycloakOIDCConfiguration();
config.setClientId("opal");
config.setBaseUri("http://localhost:8899/auth");
config.setRealm("obiba");
OIDCAuthenticationRequestFactory factory = new OIDCAuthenticationRequestFactory("https://opal-demo.obiba.org/auth/callback");
URI authReqURI = factory.create(config).toURI();
System.out.println(authReqURI);
}
Aggregations