Search in sources :

Example 6 with RequiredAuthenticationHandlerAuthenticationPolicy

use of org.apereo.cas.authentication.policy.RequiredAuthenticationHandlerAuthenticationPolicy in project cas by apereo.

the class DefaultAuthenticationManagerTests method verifyAuthenticateRequiredHandlerSuccess.

@Test
public void verifyAuthenticateRequiredHandlerSuccess() {
    val map = new LinkedHashMap<AuthenticationHandler, PrincipalResolver>();
    map.put(newMockHandler(HANDLER_A, true), null);
    map.put(newMockHandler(HANDLER_B, false), null);
    val authenticationExecutionPlan = getAuthenticationExecutionPlan(map);
    authenticationExecutionPlan.registerAuthenticationPolicy(new RequiredAuthenticationHandlerAuthenticationPolicy(HANDLER_A));
    val manager = new DefaultAuthenticationManager(authenticationExecutionPlan, false, applicationContext);
    val auth = manager.authenticate(transaction);
    assertEquals(1, auth.getSuccesses().size());
    assertEquals(2, auth.getCredentials().size());
}
Also used : lombok.val(lombok.val) RequiredAuthenticationHandlerAuthenticationPolicy(org.apereo.cas.authentication.policy.RequiredAuthenticationHandlerAuthenticationPolicy) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.jupiter.api.Test)

Example 7 with RequiredAuthenticationHandlerAuthenticationPolicy

use of org.apereo.cas.authentication.policy.RequiredAuthenticationHandlerAuthenticationPolicy in project cas by apereo.

the class DefaultAuthenticationManagerTests method verifyAuthenticateRequiredHandlerFailure.

@Test
public void verifyAuthenticateRequiredHandlerFailure() {
    val map = new LinkedHashMap<AuthenticationHandler, PrincipalResolver>();
    map.put(newMockHandler(HANDLER_A, true), null);
    map.put(newMockHandler(HANDLER_B, false), null);
    val authenticationExecutionPlan = getAuthenticationExecutionPlan(map);
    authenticationExecutionPlan.registerAuthenticationPolicy(new RequiredAuthenticationHandlerAuthenticationPolicy(HANDLER_B));
    val manager = new DefaultAuthenticationManager(authenticationExecutionPlan, false, applicationContext);
    assertThrows(AuthenticationException.class, () -> manager.authenticate(transaction));
}
Also used : lombok.val(lombok.val) RequiredAuthenticationHandlerAuthenticationPolicy(org.apereo.cas.authentication.policy.RequiredAuthenticationHandlerAuthenticationPolicy) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)7 RequiredAuthenticationHandlerAuthenticationPolicy (org.apereo.cas.authentication.policy.RequiredAuthenticationHandlerAuthenticationPolicy)7 Test (org.junit.jupiter.api.Test)6 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)3 UsernamePasswordCredential (org.apereo.cas.authentication.credential.UsernamePasswordCredential)2 Splitter (com.google.common.base.Splitter)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 Multimap (com.google.common.collect.Multimap)1 GroovyClassLoader (groovy.lang.GroovyClassLoader)1 StandardCharsets (java.nio.charset.StandardCharsets)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Predicate (java.util.function.Predicate)1