Search in sources :

Example 1 with InweboMultifactorAuthenticationProperties

use of org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties in project cas by apereo.

the class BaseActionTests method setUp.

@BeforeEach
public void setUp() {
    val applicationContext = new StaticApplicationContext();
    applicationContext.refresh();
    ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, CoreAuthenticationTestUtils.getAuthenticationSystemSupport(), AuthenticationSystemSupport.BEAN_NAME);
    requestContext = new MockRequestContext();
    request = new MockHttpServletRequest();
    val response = new MockHttpServletResponse();
    requestContext.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
    setRequestContext(requestContext);
    setExternalContext(requestContext.getExternalContext());
    ((DefaultMessageContext) requestContext.getMessageContext()).setMessageSource(new AbstractMessageSource() {

        @Override
        protected MessageFormat resolveCode(final String code, final Locale locale) {
            return new MessageFormat(StringUtils.EMPTY);
        }
    });
    service = mock(InweboService.class);
    val authenticationEventExecutionPlan = new DefaultAuthenticationEventExecutionPlan();
    authenticationEventExecutionPlan.registerAuthenticationHandler(new InweboAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), new InweboMultifactorAuthenticationProperties(), service));
    authenticationEventExecutionPlan.registerAuthenticationMetadataPopulator(new InweboAuthenticationDeviceMetadataPopulator());
    val authenticationManager = new DefaultAuthenticationManager(authenticationEventExecutionPlan, true, applicationContext);
    val authenticationTransactionManager = new DefaultAuthenticationTransactionManager(applicationContext, authenticationManager);
    val authenticationSystemSupport = new DefaultAuthenticationSystemSupport(authenticationTransactionManager, new DefaultPrincipalElectionStrategy(), new DefaultAuthenticationResultBuilderFactory(), new DefaultAuthenticationTransactionFactory());
    val context = CasWebflowEventResolutionConfigurationContext.builder().authenticationSystemSupport(authenticationSystemSupport).build();
    resolver = new InweboMultifactorAuthenticationWebflowEventResolver(context);
    setAuthenticationInContext(LOGIN);
}
Also used : Locale(java.util.Locale) InweboAuthenticationDeviceMetadataPopulator(org.apereo.cas.support.inwebo.authentication.InweboAuthenticationDeviceMetadataPopulator) MockServletContext(org.springframework.mock.web.MockServletContext) DefaultAuthenticationManager(org.apereo.cas.authentication.DefaultAuthenticationManager) DefaultPrincipalElectionStrategy(org.apereo.cas.authentication.principal.DefaultPrincipalElectionStrategy) AbstractMessageSource(org.springframework.context.support.AbstractMessageSource) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) lombok.val(lombok.val) InweboAuthenticationHandler(org.apereo.cas.support.inwebo.authentication.InweboAuthenticationHandler) InweboMultifactorAuthenticationWebflowEventResolver(org.apereo.cas.support.inwebo.web.flow.InweboMultifactorAuthenticationWebflowEventResolver) MessageFormat(java.text.MessageFormat) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockRequestContext(org.springframework.webflow.test.MockRequestContext) DefaultAuthenticationTransactionFactory(org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory) DefaultAuthenticationTransactionManager(org.apereo.cas.authentication.DefaultAuthenticationTransactionManager) DefaultAuthenticationEventExecutionPlan(org.apereo.cas.authentication.DefaultAuthenticationEventExecutionPlan) DefaultAuthenticationResultBuilderFactory(org.apereo.cas.authentication.DefaultAuthenticationResultBuilderFactory) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) InweboMultifactorAuthenticationProperties(org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties) DefaultMessageContext(org.springframework.binding.message.DefaultMessageContext) DefaultAuthenticationSystemSupport(org.apereo.cas.authentication.DefaultAuthenticationSystemSupport) InweboService(org.apereo.cas.support.inwebo.service.InweboService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with InweboMultifactorAuthenticationProperties

use of org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties in project cas by apereo.

the class InweboAuthenticationHandlerTests method verifyOperation.

@Test
public void verifyOperation() throws Exception {
    val inweboService = mock(InweboService.class);
    val response = new InweboDeviceNameResponse();
    response.setDeviceName("DeviceName");
    response.setResult(InweboResult.OK);
    when(inweboService.authenticateExtended(anyString(), anyString())).thenReturn(response);
    val handler = new InweboAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), new InweboMultifactorAuthenticationProperties(), inweboService);
    val credential = new InweboCredential("token");
    credential.setOtp("otp");
    val result = handler.authenticate(credential);
    assertNotNull(result);
    assertNotNull(credential.getDeviceName());
    assertTrue(handler.supports(credential));
    assertTrue(handler.supports(credential.getCredentialClass()));
}
Also used : lombok.val(lombok.val) ServicesManager(org.apereo.cas.services.ServicesManager) InweboMultifactorAuthenticationProperties(org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties) InweboDeviceNameResponse(org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse) Test(org.junit.jupiter.api.Test)

Example 3 with InweboMultifactorAuthenticationProperties

use of org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties in project cas by apereo.

the class InweboAuthenticationHandlerTests method verifyFailsOperation.

@Test
public void verifyFailsOperation() {
    val inweboService = mock(InweboService.class);
    val response = new InweboDeviceNameResponse();
    response.setDeviceName("DeviceName");
    response.setResult(InweboResult.OK);
    when(inweboService.authenticateExtended(anyString(), anyString())).thenReturn(response);
    val handler = new InweboAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), new InweboMultifactorAuthenticationProperties(), inweboService);
    val credential = new InweboCredential("token");
    assertThrows(FailedLoginException.class, () -> handler.authenticate(credential));
}
Also used : lombok.val(lombok.val) ServicesManager(org.apereo.cas.services.ServicesManager) InweboMultifactorAuthenticationProperties(org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties) InweboDeviceNameResponse(org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse) Test(org.junit.jupiter.api.Test)

Example 4 with InweboMultifactorAuthenticationProperties

use of org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties in project cas by apereo.

the class InweboCheckUserActionTests method setUp.

@BeforeEach
public void setUp() {
    super.setUp();
    val inwebo = new InweboMultifactorAuthenticationProperties();
    inwebo.setSiteAlias(SITE_ALIAS);
    val casProperties = new CasConfigurationProperties();
    casProperties.getAuthn().getMfa().setInwebo(inwebo);
    action = new InweboCheckUserAction(service, casProperties);
}
Also used : lombok.val(lombok.val) InweboMultifactorAuthenticationProperties(org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

lombok.val (lombok.val)4 InweboMultifactorAuthenticationProperties (org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties)4 ServicesManager (org.apereo.cas.services.ServicesManager)2 InweboDeviceNameResponse (org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Test (org.junit.jupiter.api.Test)2 MessageFormat (java.text.MessageFormat)1 Locale (java.util.Locale)1 DefaultAuthenticationEventExecutionPlan (org.apereo.cas.authentication.DefaultAuthenticationEventExecutionPlan)1 DefaultAuthenticationManager (org.apereo.cas.authentication.DefaultAuthenticationManager)1 DefaultAuthenticationResultBuilderFactory (org.apereo.cas.authentication.DefaultAuthenticationResultBuilderFactory)1 DefaultAuthenticationSystemSupport (org.apereo.cas.authentication.DefaultAuthenticationSystemSupport)1 DefaultAuthenticationTransactionFactory (org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory)1 DefaultAuthenticationTransactionManager (org.apereo.cas.authentication.DefaultAuthenticationTransactionManager)1 DefaultPrincipalElectionStrategy (org.apereo.cas.authentication.principal.DefaultPrincipalElectionStrategy)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 InweboAuthenticationDeviceMetadataPopulator (org.apereo.cas.support.inwebo.authentication.InweboAuthenticationDeviceMetadataPopulator)1 InweboAuthenticationHandler (org.apereo.cas.support.inwebo.authentication.InweboAuthenticationHandler)1 InweboService (org.apereo.cas.support.inwebo.service.InweboService)1 InweboMultifactorAuthenticationWebflowEventResolver (org.apereo.cas.support.inwebo.web.flow.InweboMultifactorAuthenticationWebflowEventResolver)1