use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class DuoSecurityPrepareWebLoginFormActionTests method verifyOperation.
@Test
public void verifyOperation() throws Exception {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.holdApplicationContext(applicationContext);
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
val flowSession = new MockFlowSession(new Flow(CasWebflowConfigurer.FLOW_ID_LOGIN));
flowSession.setState(new ViewState(flowSession.getDefinitionInternal(), "viewState", mock(ViewFactory.class)));
val exec = new MockFlowExecutionContext(flowSession);
val context = new MockRequestContext(exec);
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());
val authentication = CoreAuthenticationTestUtils.getAuthentication();
WebUtils.putAuthentication(authentication, context);
val duoService = mock(DuoSecurityAuthenticationService.class);
when(duoService.getProperties()).thenReturn(casProperties.getAuthn().getMfa().getDuo().get(0));
val provider = mock(DuoSecurityMultifactorAuthenticationProvider.class);
when(provider.getId()).thenReturn(DuoSecurityMultifactorAuthenticationProperties.DEFAULT_IDENTIFIER);
when(provider.getDuoAuthenticationService()).thenReturn(duoService);
when(provider.matches(anyString())).thenReturn(Boolean.TRUE);
WebUtils.putCredential(context, new DuoSecurityCredential(authentication.getPrincipal().getId(), UUID.randomUUID().toString(), provider.getId()));
WebUtils.putMultifactorAuthenticationProviderIdIntoFlowScope(context, provider);
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext, provider);
val action = new DuoSecurityPrepareWebLoginFormAction();
val event = action.execute(context);
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, event.getId());
}
use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class Pac4jWebflowConfigurer method createStopWebflowViewState.
private void createStopWebflowViewState(final Flow flow) {
final ViewState state = createViewState(flow, DelegatedClientAuthenticationAction.STOP_WEBFLOW, DelegatedClientAuthenticationAction.VIEW_ID_STOP_WEBFLOW);
state.getEntryActionList().add(new AbstractAction() {
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
final HttpServletRequest request = WebUtils.getHttpServletRequest(requestContext);
final HttpServletResponse response = WebUtils.getHttpServletResponse(requestContext);
final Optional<ModelAndView> mv = DelegatedClientAuthenticationAction.hasDelegationRequestFailed(request, response.getStatus());
mv.ifPresent(modelAndView -> modelAndView.getModel().forEach((k, v) -> requestContext.getFlowScope().put(k, v)));
return null;
}
});
}
use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class PasswordManagementWebflowConfigurer method configure.
private void configure(final Flow flow, final String id) {
createFlowVariable(flow, FLOW_VAR_ID_PASSWORD, PasswordChangeBean.class);
final BinderConfiguration binder = createStateBinderConfiguration(Arrays.asList(FLOW_VAR_ID_PASSWORD, "confirmedPassword"));
final ViewState viewState = createViewState(flow, id, id, binder);
createStateModelBinding(viewState, FLOW_VAR_ID_PASSWORD, PasswordChangeBean.class);
viewState.getEntryActionList().add(this.passwordChangeAction);
final Transition transition = createTransitionForState(viewState, CasWebflowConstants.TRANSITION_ID_SUBMIT, PASSWORD_CHANGE_ACTION);
transition.getAttributes().put("bind", Boolean.TRUE);
transition.getAttributes().put("validate", Boolean.TRUE);
createStateDefaultTransition(viewState, id);
final ActionState pswChangeAction = createActionState(flow, PASSWORD_CHANGE_ACTION, createEvaluateAction(PASSWORD_CHANGE_ACTION));
pswChangeAction.getTransitionSet().add(createTransition(PasswordChangeAction.PASSWORD_UPDATE_SUCCESS, "casPasswordUpdateSuccess"));
pswChangeAction.getTransitionSet().add(createTransition(CasWebflowConstants.TRANSITION_ID_ERROR, id));
}
use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class SamlIdPMetadataUIWebflowConfigurer method doInitialize.
@Override
protected void doInitialize() {
final Flow flow = getLoginFlow();
if (flow != null) {
final ViewState state = getTransitionableState(flow, CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM, ViewState.class);
state.getEntryActionList().add(this.samlMetadataUIParserAction);
}
}
use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class WSFederationWebflowConfigurer method doInitialize.
@Override
protected void doInitialize() {
final Flow loginFlow = getLoginFlow();
if (loginFlow != null) {
final ViewState state = getTransitionableState(loginFlow, CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM, ViewState.class);
state.getEntryActionList().add(this.wsfedAction);
}
}
Aggregations