use of org.openid4java.OpenIDException in project pac4j by pac4j.
the class YahooAuthenticator method validate.
@Override
public void validate(final OpenIdCredentials credentials, final WebContext context) {
final ParameterList parameterList = credentials.getParameterList();
final DiscoveryInformation discoveryInformation = credentials.getDiscoveryInformation();
logger.debug("parameterList: {}", parameterList);
logger.debug("discoveryInformation: {}", discoveryInformation);
try {
// verify the response
final VerificationResult verification = this.client.getConsumerManager().verify(this.client.computeFinalCallbackUrl(context), parameterList, discoveryInformation);
// examine the verification result and extract the verified identifier
final Identifier verified = verification.getVerifiedId();
if (verified != null) {
final AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();
logger.debug("authSuccess: {}", authSuccess);
final YahooOpenIdProfile profile = createProfile(authSuccess);
profile.setId(verified.getIdentifier());
logger.debug("profile: {}", profile);
credentials.setUserProfile(profile);
return;
}
} catch (final OpenIDException e) {
throw new TechnicalException("OpenID exception", e);
}
final String message = "No verifiedId found";
throw new TechnicalException(message);
}
use of org.openid4java.OpenIDException in project pac4j by pac4j.
the class YahooRedirectActionBuilder method redirect.
@Override
public RedirectAction redirect(final WebContext context) {
try {
// perform discovery on the user-supplied identifier
final List discoveries = this.client.getConsumerManager().discover(YAHOO_GENERIC_USER_IDENTIFIER);
// attempt to associate with the OpenID provider
// and retrieve one service endpoint for authentication
final DiscoveryInformation discoveryInformation = this.client.getConsumerManager().associate(discoveries);
// save discovery information in session
context.getSessionStore().set(context, this.client.getDiscoveryInformationSessionAttributeName(), discoveryInformation);
// create authentication request to be sent to the OpenID provider
final AuthRequest authRequest = this.client.getConsumerManager().authenticate(discoveryInformation, this.client.computeFinalCallbackUrl(context));
// create fetch request for attributes
final FetchRequest fetchRequest = getFetchRequest();
if (fetchRequest != null) {
authRequest.addExtension(fetchRequest);
}
final String redirectionUrl = authRequest.getDestinationUrl(true);
logger.debug("redirectionUrl: {}", redirectionUrl);
return RedirectAction.redirect(redirectionUrl);
} catch (final OpenIDException e) {
throw new TechnicalException("OpenID exception", e);
}
}
Aggregations