Search in sources :

Example 6 with AuthenticationMethod

use of org.forgerock.oauth2.core.AuthenticationMethod in project OpenAM by OpenRock.

the class OpenAMOAuth2ProviderSettings method getAcrMapping.

@Override
public Map<String, AuthenticationMethod> getAcrMapping() throws ServerException {
    try {
        final Map<String, String> map = getMapSetting(realm, OAuth2ProviderService.ACR_VALUE_MAPPING);
        final Map<String, AuthenticationMethod> methods = new HashMap<String, AuthenticationMethod>(map.size());
        for (Map.Entry<String, String> entry : map.entrySet()) {
            methods.put(entry.getKey(), new OpenAMAuthenticationMethod(entry.getValue(), AuthContext.IndexType.SERVICE));
        }
        return methods;
    } catch (SSOException e) {
        logger.message(e.getMessage());
        throw new ServerException(e);
    } catch (SMSException e) {
        logger.message(e.getMessage());
        throw new ServerException(e);
    }
}
Also used : ServerException(org.forgerock.oauth2.core.exceptions.ServerException) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) AuthenticationMethod(org.forgerock.oauth2.core.AuthenticationMethod) Map(java.util.Map) HashMap(java.util.HashMap)

Example 7 with AuthenticationMethod

use of org.forgerock.oauth2.core.AuthenticationMethod in project OpenAM by OpenRock.

the class OpenAMResourceOwnerSessionValidatorTest method shouldUseFirstAcrValueThatIsSupported.

@Test
public void shouldUseFirstAcrValueThatIsSupported() throws Exception {
    // Given
    String acrValues = "1 2 3";
    mockPrompt("login");
    mockSSOToken(NO_SESSION_TOKEN);
    mockRequestAcrValues(acrValues);
    final Map<String, AuthenticationMethod> acrMap = new HashMap<>();
    acrMap.put("2", new OpenAMAuthenticationMethod("service2", AuthContext.IndexType.SERVICE));
    acrMap.put("3", new OpenAMAuthenticationMethod("service3", AuthContext.IndexType.SERVICE));
    mockAcrValuesMap(acrMap);
    // When
    URI loginUri = null;
    try {
        resourceOwnerSessionValidator.validate(mockOAuth2Request);
        fail();
    } catch (ResourceOwnerAuthenticationRequired ex) {
        loginUri = ex.getRedirectUri();
    }
    // Then
    assertTrue(loginUri.getQuery().contains("service=service2"));
}
Also used : ResourceOwnerAuthenticationRequired(org.forgerock.oauth2.core.exceptions.ResourceOwnerAuthenticationRequired) HashMap(java.util.HashMap) AuthenticationMethod(org.forgerock.oauth2.core.AuthenticationMethod) URI(java.net.URI) Test(org.testng.annotations.Test)

Aggregations

AuthenticationMethod (org.forgerock.oauth2.core.AuthenticationMethod)4 URI (java.net.URI)3 OAuth2ProviderSettings (org.forgerock.oauth2.core.OAuth2ProviderSettings)3 ResourceOwnerAuthenticationRequired (org.forgerock.oauth2.core.exceptions.ResourceOwnerAuthenticationRequired)3 Test (org.testng.annotations.Test)3 HashMap (java.util.HashMap)2 SSOException (com.iplanet.sso.SSOException)1 SMSException (com.sun.identity.sm.SMSException)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 OAuth2Request (org.forgerock.oauth2.core.OAuth2Request)1 ServerException (org.forgerock.oauth2.core.exceptions.ServerException)1 Request (org.restlet.Request)1