Search in sources :

Example 1 with YahooOpenIdProfile

use of org.pac4j.openid.profile.yahoo.YahooOpenIdProfile in project pac4j by pac4j.

the class RunYahooOpenIdClient method verifyProfile.

@Override
protected void verifyProfile(CommonProfile userProfile) {
    final YahooOpenIdProfile profile = (YahooOpenIdProfile) userProfile;
    assertNotNull(profile);
    final String id = "mnsYAxIag.AfFGVrKZckRIVkvVYLEYRM4Q--#02050";
    assertEquals("https://me.yahoo.com/a/" + id, profile.getId());
    assertEquals(YahooOpenIdProfile.class.getName() + CommonProfile.SEPARATOR + "https://me.yahoo.com/a/" + id, profile.getTypedId());
    assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), YahooOpenIdProfile.class));
    assertCommonProfile(userProfile, getLogin(), null, null, "Test ScribeUP", null, Gender.UNSPECIFIED, Locale.FRANCE, "https://s.yimg.com/dg/users/1DJGkdA6uAAECQWEo8AceAQ==.medium.png", null, null);
    assertEquals(4, profile.getAttributes().size());
}
Also used : YahooOpenIdProfile(org.pac4j.openid.profile.yahoo.YahooOpenIdProfile)

Example 2 with YahooOpenIdProfile

use of org.pac4j.openid.profile.yahoo.YahooOpenIdProfile 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);
}
Also used : YahooOpenIdProfile(org.pac4j.openid.profile.yahoo.YahooOpenIdProfile) Identifier(org.openid4java.discovery.Identifier) TechnicalException(org.pac4j.core.exception.TechnicalException) VerificationResult(org.openid4java.consumer.VerificationResult) OpenIDException(org.openid4java.OpenIDException) DiscoveryInformation(org.openid4java.discovery.DiscoveryInformation) AuthSuccess(org.openid4java.message.AuthSuccess) ParameterList(org.openid4java.message.ParameterList)

Aggregations

YahooOpenIdProfile (org.pac4j.openid.profile.yahoo.YahooOpenIdProfile)2 OpenIDException (org.openid4java.OpenIDException)1 VerificationResult (org.openid4java.consumer.VerificationResult)1 DiscoveryInformation (org.openid4java.discovery.DiscoveryInformation)1 Identifier (org.openid4java.discovery.Identifier)1 AuthSuccess (org.openid4java.message.AuthSuccess)1 ParameterList (org.openid4java.message.ParameterList)1 TechnicalException (org.pac4j.core.exception.TechnicalException)1