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);
}
}
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"));
}
Aggregations