use of org.obiba.oidc.OIDCException in project obiba-commons by obiba.
the class OIDCAuthenticationRequestFactory method create.
public AuthenticationRequest create(OIDCConfiguration configuration) {
OIDCProviderMetadata providerMetadata = configuration.findProviderMetaData();
// Generate random state string for pairing the response to the request
State state = new State();
// Generate nonce
Nonce nonce = configuration.isUseNonce() ? new Nonce() : null;
// Specify scope
Scope scope = Scope.parse(configuration.getScope());
AuthenticationRequest authenticationRequest = null;
try {
authenticationRequest = new AuthenticationRequest(providerMetadata.getAuthorizationEndpointURI(), new ResponseType(ResponseType.Value.CODE), scope, new ClientID(configuration.getClientId()), new URI(callbackURI), state, nonce);
} catch (URISyntaxException e) {
throw new OIDCException(e);
}
return authenticationRequest;
}
use of org.obiba.oidc.OIDCException in project obiba-commons by obiba.
the class OIDCTokenValidator method validate.
public IDTokenClaimsSet validate(final JWT idToken, final Nonce expectedNonce) throws BadJOSEException, JOSEException {
BadJOSEException badJOSEException = null;
JOSEException joseException = null;
for (final IDTokenValidator idTokenValidator : idTokenValidators) {
try {
return idTokenValidator.validate(idToken, expectedNonce);
} catch (final BadJOSEException e1) {
badJOSEException = e1;
} catch (final JOSEException e2) {
joseException = e2;
}
}
if (badJOSEException != null) {
throw badJOSEException;
} else if (joseException != null) {
throw joseException;
} else {
throw new OIDCException("Unable to validate the ID token");
}
}
Aggregations