use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class RegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluatorTests method verifyNoService.
@Test
public void verifyNoService() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.holdApplicationContext(applicationContext);
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
val provider = TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
val eval = new DefaultChainingMultifactorAuthenticationBypassProvider();
eval.addMultifactorAuthenticationProviderBypassEvaluator(new RegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator(TestMultifactorAuthenticationProvider.ID));
val principal = CoreAuthenticationTestUtils.getPrincipal(Map.of("cn", List.of("example")));
val authentication = CoreAuthenticationTestUtils.getAuthentication(principal);
assertTrue(eval.shouldMultifactorAuthenticationProviderExecute(authentication, null, provider, new MockHttpServletRequest()));
}
use of org.springframework.context.support.StaticApplicationContext 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);
}
use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class JcifsConfigTests method verifyKerbSysConfig.
@Test
public void verifyKerbSysConfig() throws Exception {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
val path = new ClassPathResource("kerb5.conf").getFile().getCanonicalPath();
val loginConf = new ClassPathResource("jaas.conf").getFile().getCanonicalPath();
val settings = new JcifsConfig.SystemSettings();
settings.setKerberosDebug("true");
settings.setKerberosConf("file:" + path);
assertDoesNotThrow(new Executable() {
@Override
public void execute() {
settings.initialize(applicationContext, "file:" + loginConf);
}
});
}
use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class DefaultAuthenticationManagerTests method setup.
@BeforeEach
public void setup() {
applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, CoreAuthenticationTestUtils.getAuthenticationSystemSupport(), AuthenticationSystemSupport.BEAN_NAME);
}
use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class PasswordEncoderUtilsTests method verifyNoType.
@Test
public void verifyNoType() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
val properties = new PasswordEncoderProperties();
properties.setType(null);
var encoder = PasswordEncoderUtils.newPasswordEncoder(properties, applicationContext);
assertNotNull(encoder);
properties.setType(StringUtils.EMPTY);
encoder = PasswordEncoderUtils.newPasswordEncoder(properties, applicationContext);
assertNotNull(encoder);
}
Aggregations