use of org.springframework.webflow.engine.support.DefaultTargetStateResolver in project cas by apereo.
the class RequestSessionAttributeMultifactorAuthenticationPolicyEventResolverTests method verifyOperation.
@Test
public void verifyOperation() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val service = RegisteredServiceTestUtils.getRegisteredService();
servicesManager.save(service);
WebUtils.putRegisteredService(context, service);
WebUtils.putAuthentication(RegisteredServiceTestUtils.getAuthentication(), context);
WebUtils.putServiceIntoFlowScope(context, RegisteredServiceTestUtils.getService());
var results = requestSessionAttributeAuthenticationPolicyWebflowEventResolver.resolve(context);
assertNull(results);
val targetResolver = new DefaultTargetStateResolver(TestMultifactorAuthenticationProvider.ID);
val transition = new Transition(new DefaultTransitionCriteria(new LiteralExpression(TestMultifactorAuthenticationProvider.ID)), targetResolver);
context.getRootFlow().getGlobalTransitionSet().add(transition);
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
request.getSession(true).setAttribute(casProperties.getAuthn().getMfa().getTriggers().getHttp().getSessionAttribute(), TestMultifactorAuthenticationProvider.ID);
results = requestSessionAttributeAuthenticationPolicyWebflowEventResolver.resolve(context);
assertNotNull(results);
assertEquals(1, results.size());
assertEquals(TestMultifactorAuthenticationProvider.ID, results.iterator().next().getId());
}
use of org.springframework.webflow.engine.support.DefaultTargetStateResolver in project cas by apereo.
the class OidcAuthenticationContextWebflowEventResolverTests method initialize.
@BeforeEach
@Override
public void initialize() throws Exception {
super.initialize();
this.context = new MockRequestContext();
val request = new MockHttpServletRequest();
request.setRemoteAddr("385.86.151.11");
request.setLocalAddr("295.88.151.11");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "MSIE");
request.addParameter(OAuth20Constants.ACR_VALUES, TestMultifactorAuthenticationProvider.ID);
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val targetResolver = new DefaultTargetStateResolver(TestMultifactorAuthenticationProvider.ID);
val transition = new Transition(new DefaultTransitionCriteria(new LiteralExpression(TestMultifactorAuthenticationProvider.ID)), targetResolver);
context.getRootFlow().getGlobalTransitionSet().add(transition);
WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication(), context);
}
use of org.springframework.webflow.engine.support.DefaultTargetStateResolver in project cas by apereo.
the class AbstractCasWebflowConfigurer method createTransition.
@Override
public Transition createTransition(final Expression criteriaOutcomeExpression, final String targetState) {
final TransitionCriteria criteria;
if (criteriaOutcomeExpression.toString().equals(WildcardTransitionCriteria.WILDCARD_EVENT_ID)) {
criteria = WildcardTransitionCriteria.INSTANCE;
} else {
criteria = new DefaultTransitionCriteria(criteriaOutcomeExpression);
}
final DefaultTargetStateResolver resolver = new DefaultTargetStateResolver(targetState);
final Transition t = new Transition(criteria, resolver);
return t;
}
use of org.springframework.webflow.engine.support.DefaultTargetStateResolver in project cas by apereo.
the class AbstractCasWebflowConfigurer method createTransition.
@Override
public Transition createTransition(final Expression criteriaOutcomeExpression, final String targetState) {
final TransitionCriteria criteria;
if (criteriaOutcomeExpression.toString().equals(WildcardTransitionCriteria.WILDCARD_EVENT_ID)) {
criteria = WildcardTransitionCriteria.INSTANCE;
} else {
criteria = new DefaultTransitionCriteria(criteriaOutcomeExpression);
}
final DefaultTargetStateResolver resolver = new DefaultTargetStateResolver(targetState);
final Transition t = new Transition(criteria, resolver);
return t;
}
use of org.springframework.webflow.engine.support.DefaultTargetStateResolver in project cas by apereo.
the class MultifactorAuthenticationUtilsTests method verifyResolveBySingleAttribute.
@Test
public void verifyResolveBySingleAttribute() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
ApplicationContextProvider.holdApplicationContext(applicationContext);
val provider = TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
assertTrue(MultifactorAuthenticationUtils.getMultifactorAuthenticationProviderFromApplicationContext(provider.getId()).isPresent());
val targetResolver = new DefaultTargetStateResolver(TestMultifactorAuthenticationProvider.ID);
val transition = new Transition(new DefaultTransitionCriteria(new LiteralExpression(TestMultifactorAuthenticationProvider.ID)), targetResolver);
context.getRootFlow().getGlobalTransitionSet().add(transition);
val result = MultifactorAuthenticationUtils.resolveEventViaSingleAttribute(MultifactorAuthenticationTestUtils.getPrincipal("casuser"), List.of("mfa-value1"), MultifactorAuthenticationTestUtils.getRegisteredService(), Optional.of(context), provider, (s, mfaProvider) -> RegexUtils.find("mismatch-.+", s));
assertNull(result);
}
Aggregations