Search in sources :

Example 1 with PrincipalAttributeMultifactorAuthenticationTrigger

use of org.apereo.cas.authentication.mfa.trigger.PrincipalAttributeMultifactorAuthenticationTrigger in project cas by apereo.

the class DefaultMultifactorAuthenticationProviderResolverTests method verifyMultipleProvidersWithPrincipalAttributes.

@Test
public void verifyMultipleProvidersWithPrincipalAttributes() {
    val applicationContext = new StaticApplicationContext();
    applicationContext.refresh();
    val casProperties = new CasConfigurationProperties();
    casProperties.getAuthn().getMfa().getTriggers().getPrincipal().setGlobalPrincipalAttributeNameTriggers("mfa-principal");
    val resolver = new DefaultMultifactorAuthenticationProviderResolver(MultifactorAuthenticationPrincipalResolver.identical());
    val trigger = new PrincipalAttributeMultifactorAuthenticationTrigger(casProperties, resolver, applicationContext);
    assertProviderResolutionFromManyProviders(trigger, applicationContext, true);
    assertThrows(UnsatisfiedAuthenticationContextTicketValidationException.class, () -> {
        throw new UnsatisfiedAuthenticationContextTicketValidationException(MultifactorAuthenticationTestUtils.getService("id"));
    });
}
Also used : lombok.val(lombok.val) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) PrincipalAttributeMultifactorAuthenticationTrigger(org.apereo.cas.authentication.mfa.trigger.PrincipalAttributeMultifactorAuthenticationTrigger) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) UnsatisfiedAuthenticationContextTicketValidationException(org.apereo.cas.ticket.UnsatisfiedAuthenticationContextTicketValidationException) Test(org.junit.jupiter.api.Test)

Example 2 with PrincipalAttributeMultifactorAuthenticationTrigger

use of org.apereo.cas.authentication.mfa.trigger.PrincipalAttributeMultifactorAuthenticationTrigger in project cas by apereo.

the class DefaultMultifactorAuthenticationProviderResolverTests method verifyInvalidPrincipalAttributes.

@Test
public void verifyInvalidPrincipalAttributes() {
    val applicationContext = new StaticApplicationContext();
    applicationContext.refresh();
    val casProperties = new CasConfigurationProperties();
    casProperties.getAuthn().getMfa().getTriggers().getPrincipal().setGlobalPrincipalAttributeNameTriggers("does-not-exist");
    val resolver = new DefaultMultifactorAuthenticationProviderResolver(MultifactorAuthenticationPrincipalResolver.identical());
    val trigger = new PrincipalAttributeMultifactorAuthenticationTrigger(casProperties, resolver, applicationContext);
    assertProviderResolutionFromManyProviders(trigger, applicationContext, false);
}
Also used : lombok.val(lombok.val) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) PrincipalAttributeMultifactorAuthenticationTrigger(org.apereo.cas.authentication.mfa.trigger.PrincipalAttributeMultifactorAuthenticationTrigger) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)2 PrincipalAttributeMultifactorAuthenticationTrigger (org.apereo.cas.authentication.mfa.trigger.PrincipalAttributeMultifactorAuthenticationTrigger)2 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)2 Test (org.junit.jupiter.api.Test)2 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)2 UnsatisfiedAuthenticationContextTicketValidationException (org.apereo.cas.ticket.UnsatisfiedAuthenticationContextTicketValidationException)1