Search in sources :

Example 16 with DefaultAuthenticationTransactionFactory

use of org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory in project cas by apereo.

the class RegisteredServiceAuthenticationPolicyResolverTests method checkGroovyPolicy.

@Test
public void checkGroovyPolicy() {
    val resolver = new RegisteredServiceAuthenticationPolicyResolver(this.servicesManager, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
    val transaction = new DefaultAuthenticationTransactionFactory().newTransaction(RegisteredServiceTestUtils.getService("serviceid5"), RegisteredServiceTestUtils.getCredentialsWithSameUsernameAndPassword("casuser"));
    val policies = resolver.resolve(transaction);
    assertEquals(1, policies.size());
    assertTrue(policies.iterator().next() instanceof GroovyScriptAuthenticationPolicy);
}
Also used : lombok.val(lombok.val) RegisteredServiceAuthenticationPolicyResolver(org.apereo.cas.authentication.policy.RegisteredServiceAuthenticationPolicyResolver) DefaultAuthenticationServiceSelectionStrategy(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy) DefaultAuthenticationServiceSelectionPlan(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan) GroovyScriptAuthenticationPolicy(org.apereo.cas.authentication.policy.GroovyScriptAuthenticationPolicy) DefaultAuthenticationTransactionFactory(org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory) Test(org.junit.jupiter.api.Test)

Example 17 with DefaultAuthenticationTransactionFactory

use of org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory in project cas by apereo.

the class RegisteredServiceAuthenticationPolicyResolverTests method checkAllPolicy.

@Test
public void checkAllPolicy() {
    val resolver = new RegisteredServiceAuthenticationPolicyResolver(this.servicesManager, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
    val transaction = new DefaultAuthenticationTransactionFactory().newTransaction(RegisteredServiceTestUtils.getService("serviceid3"), RegisteredServiceTestUtils.getCredentialsWithSameUsernameAndPassword("casuser"));
    val policies = resolver.resolve(transaction);
    assertEquals(1, policies.size());
    assertTrue(policies.iterator().next() instanceof AllAuthenticationHandlersSucceededAuthenticationPolicy);
}
Also used : lombok.val(lombok.val) RegisteredServiceAuthenticationPolicyResolver(org.apereo.cas.authentication.policy.RegisteredServiceAuthenticationPolicyResolver) DefaultAuthenticationServiceSelectionStrategy(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy) AllAuthenticationHandlersSucceededAuthenticationPolicy(org.apereo.cas.authentication.policy.AllAuthenticationHandlersSucceededAuthenticationPolicy) DefaultAuthenticationServiceSelectionPlan(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan) DefaultAuthenticationTransactionFactory(org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory) Test(org.junit.jupiter.api.Test)

Example 18 with DefaultAuthenticationTransactionFactory

use of org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory in project cas by apereo.

the class LdapPasswordSynchronizationConfigurationTests method verifyOperation.

@Test
public void verifyOperation() {
    val transaction = new DefaultAuthenticationTransactionFactory().newTransaction(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword());
    assertFalse(authenticationEventExecutionPlan.getAuthenticationPostProcessors(transaction).isEmpty());
}
Also used : lombok.val(lombok.val) DefaultAuthenticationTransactionFactory(org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 19 with DefaultAuthenticationTransactionFactory

use of org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory in project cas by apereo.

the class SamlAuthenticationMetaDataPopulatorTests method verifyAuthenticationTypeFound.

@Test
public void verifyAuthenticationTypeFound() {
    val credentials = new UsernamePasswordCredential();
    val builder = CoreAuthenticationTestUtils.getAuthenticationBuilder();
    this.populator.populateAttributes(builder, new DefaultAuthenticationTransactionFactory().newTransaction(credentials));
    val auth = builder.build();
    assertEquals(SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_PASSWORD, auth.getAttributes().get(SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD).get(0));
}
Also used : lombok.val(lombok.val) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) DefaultAuthenticationTransactionFactory(org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory) Test(org.junit.jupiter.api.Test)

Example 20 with DefaultAuthenticationTransactionFactory

use of org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory in project cas by apereo.

the class SamlAuthenticationMetaDataPopulatorTests method verifyAuthenticationTypeFoundByDefault.

@Test
public void verifyAuthenticationTypeFoundByDefault() {
    val credentials = new CustomCredential();
    val builder = CoreAuthenticationTestUtils.getAuthenticationBuilder();
    this.populator.populateAttributes(builder, new DefaultAuthenticationTransactionFactory().newTransaction(credentials));
    val auth = builder.build();
    assertNotNull(auth.getAttributes().get(SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD).get(0));
}
Also used : lombok.val(lombok.val) DefaultAuthenticationTransactionFactory(org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)33 DefaultAuthenticationTransactionFactory (org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory)33 Test (org.junit.jupiter.api.Test)27 DefaultAuthenticationServiceSelectionPlan (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan)9 DefaultAuthenticationServiceSelectionStrategy (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy)9 RegisteredServiceAuthenticationPolicyResolver (org.apereo.cas.authentication.policy.RegisteredServiceAuthenticationPolicyResolver)7 SimpleTestUsernamePasswordAuthenticationHandler (org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler)5 DefaultAuthenticationResultBuilderFactory (org.apereo.cas.authentication.DefaultAuthenticationResultBuilderFactory)4 DefaultAuthenticationSystemSupport (org.apereo.cas.authentication.DefaultAuthenticationSystemSupport)4 DefaultAuthenticationTransactionManager (org.apereo.cas.authentication.DefaultAuthenticationTransactionManager)4 DefaultPrincipalElectionStrategy (org.apereo.cas.authentication.principal.DefaultPrincipalElectionStrategy)4 UsernamePasswordCredential (org.apereo.cas.authentication.credential.UsernamePasswordCredential)3 WebApplicationServiceFactory (org.apereo.cas.authentication.principal.WebApplicationServiceFactory)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 HashMap (java.util.HashMap)2 AuthenticationTransaction (org.apereo.cas.authentication.AuthenticationTransaction)2 RegisteredServiceAuthenticationHandlerResolver (org.apereo.cas.authentication.handler.RegisteredServiceAuthenticationHandlerResolver)2 AtLeastOneCredentialValidatedAuthenticationPolicy (org.apereo.cas.authentication.policy.AtLeastOneCredentialValidatedAuthenticationPolicy)2 UsernamePasswordRestHttpRequestCredentialFactory (org.apereo.cas.rest.factory.UsernamePasswordRestHttpRequestCredentialFactory)2