use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class YubiKeyAccountCheckRegistrationActionTests method setup.
@BeforeEach
public void setup() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.holdApplicationContext(applicationContext);
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext, new YubiKeyMultifactorAuthenticationProvider());
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
}
use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class YubiKeyAuthenticationPrepareLoginActionTests method setup.
@BeforeEach
public void setup() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.holdApplicationContext(applicationContext);
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext, new YubiKeyMultifactorAuthenticationProvider());
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
}
use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class YamlServiceRegistryTests method getNewServiceRegistry.
@Override
@SneakyThrows
public ResourceBasedServiceRegistry getNewServiceRegistry() {
val appCtx = new StaticApplicationContext();
appCtx.refresh();
newServiceRegistry = new YamlServiceRegistry(RESOURCE, WatcherService.noOp(), appCtx, new NoOpRegisteredServiceReplicationStrategy(), new DefaultRegisteredServiceResourceNamingStrategy(), new ArrayList<>());
return newServiceRegistry;
}
use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class DefaultMultifactorAuthenticationContextValidatorTests method getStaticApplicationContext.
private static ConfigurableApplicationContext getStaticApplicationContext() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
return applicationContext;
}
use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class DefaultMultifactorAuthenticationContextValidatorTests method verifyContextPassesValidationWithChainProvider.
@Test
public void verifyContextPassesValidationWithChainProvider() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
val casProperties = new CasConfigurationProperties();
casProperties.getAuthn().getMfa().getCore().setGlobalFailureMode(BaseMultifactorAuthenticationProviderProperties.MultifactorAuthenticationProviderFailureModes.OPEN);
val failureEvaluator = new DefaultMultifactorAuthenticationFailureModeEvaluator(casProperties);
val chainProvider = new DefaultChainingMultifactorAuthenticationProvider(failureEvaluator);
val provider1 = new TestMultifactorAuthenticationProvider("mfa-first");
provider1.setOrder(10);
val provider2 = new TestMultifactorAuthenticationProvider("mfa-second");
provider2.setOrder(20);
chainProvider.addMultifactorAuthenticationProvider(provider1);
chainProvider.addMultifactorAuthenticationProvider(provider2);
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext, chainProvider);
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext, provider1);
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext, provider2);
val v = new DefaultMultifactorAuthenticationContextValidator("authn_method", "trusted_authn", applicationContext);
val authentication = MultifactorAuthenticationTestUtils.getAuthentication(MultifactorAuthenticationTestUtils.getPrincipal("casuser"), CollectionUtils.wrap("authn_method", List.of(provider2.getId())));
val result = v.validate(authentication, provider2.getId(), Optional.of(MultifactorAuthenticationTestUtils.getRegisteredService()));
assertTrue(result.isSuccess());
}
Aggregations