Search in sources :

Example 1 with AbstractMessageSource

use of org.springframework.context.support.AbstractMessageSource 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)

Aggregations

MessageFormat (java.text.MessageFormat)1 Locale (java.util.Locale)1 lombok.val (lombok.val)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 InweboMultifactorAuthenticationProperties (org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties)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 BeforeEach (org.junit.jupiter.api.BeforeEach)1 DefaultMessageContext (org.springframework.binding.message.DefaultMessageContext)1 AbstractMessageSource (org.springframework.context.support.AbstractMessageSource)1 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1