use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class AbstractCasWebflowConfigurer method createViewState.
@Override
public ViewState createViewState(final Flow flow, final String id, final Expression expression, final BinderConfiguration binder) {
try {
if (containsFlowState(flow, id)) {
LOGGER.debug("Flow [{}] already contains a definition for state id [{}]", flow.getId(), id);
return (ViewState) flow.getTransitionableState(id);
}
final ViewFactory viewFactory = this.flowBuilderServices.getViewFactoryCreator().createViewFactory(expression, this.flowBuilderServices.getExpressionParser(), this.flowBuilderServices.getConversionService(), binder, this.flowBuilderServices.getValidator(), this.flowBuilderServices.getValidationHintResolver());
final ViewState viewState = new ViewState(flow, id, viewFactory);
LOGGER.debug("Added view state [{}]", viewState.getId());
return viewState;
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return null;
}
use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class AbstractMultifactorTrustedDeviceWebflowConfigurer method registerMultifactorTrustedAuthentication.
/**
* Register multifactor trusted authentication into webflow.
*
* @param flowDefinitionRegistry the flow definition registry
*/
protected void registerMultifactorTrustedAuthentication(final FlowDefinitionRegistry flowDefinitionRegistry) {
if (flowDefinitionRegistry.getFlowDefinitionCount() <= 0) {
throw new IllegalArgumentException("Flow definition registry has no flow definitions");
}
LOGGER.debug("Flow definitions found in the registry are [{}]", (Object[]) flowDefinitionRegistry.getFlowDefinitionIds());
final String flowId = Arrays.stream(flowDefinitionRegistry.getFlowDefinitionIds()).findFirst().get();
LOGGER.debug("Processing flow definition [{}]", flowId);
final Flow flow = (Flow) flowDefinitionRegistry.getFlowDefinition(flowId);
// Set the verify action
final ActionState state = (ActionState) flow.getState(CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM);
final Transition transition = (Transition) state.getTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS);
final String targetStateId = transition.getTargetStateId();
transition.setTargetStateResolver(new DefaultTargetStateResolver(CasWebflowConstants.STATE_ID_VERIFY_TRUSTED_DEVICE));
final ActionState verifyAction = createActionState(flow, CasWebflowConstants.STATE_ID_VERIFY_TRUSTED_DEVICE, createEvaluateAction("mfaVerifyTrustAction"));
// handle device registration
if (enableDeviceRegistration) {
createTransitionForState(verifyAction, CasWebflowConstants.TRANSITION_ID_YES, "finishMfaTrustedAuth");
} else {
createTransitionForState(verifyAction, CasWebflowConstants.TRANSITION_ID_YES, CasWebflowConstants.TRANSITION_ID_REAL_SUBMIT);
}
createTransitionForState(verifyAction, CasWebflowConstants.TRANSITION_ID_NO, targetStateId);
createDecisionState(flow, CasWebflowConstants.DECISION_STATE_REQUIRE_REGISTRATION, isDeviceRegistrationRequired(), CasWebflowConstants.VIEW_ID_REGISTER_DEVICE, CasWebflowConstants.TRANSITION_ID_REAL_SUBMIT);
final ActionState submit = (ActionState) flow.getState(CasWebflowConstants.TRANSITION_ID_REAL_SUBMIT);
final Transition success = (Transition) submit.getTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS);
if (enableDeviceRegistration) {
success.setTargetStateResolver(new DefaultTargetStateResolver(CasWebflowConstants.VIEW_ID_REGISTER_DEVICE));
} else {
success.setTargetStateResolver(new DefaultTargetStateResolver(CasWebflowConstants.STATE_ID_REGISTER_TRUSTED_DEVICE));
}
final ViewState viewRegister = createViewState(flow, CasWebflowConstants.VIEW_ID_REGISTER_DEVICE, "casMfaRegisterDeviceView");
viewRegister.getTransitionSet().add(createTransition(CasWebflowConstants.TRANSITION_ID_SUBMIT, CasWebflowConstants.STATE_ID_REGISTER_TRUSTED_DEVICE));
final ActionState registerAction = createActionState(flow, CasWebflowConstants.STATE_ID_REGISTER_TRUSTED_DEVICE, createEvaluateAction("mfaSetTrustAction"));
createStateDefaultTransition(registerAction, CasWebflowConstants.STATE_ID_SUCCESS);
if (submit.getActionList().size() == 0) {
throw new IllegalArgumentException("There are no actions defined for the final submission event of " + flowId);
}
final Action act = submit.getActionList().iterator().next();
final ActionState finishMfaTrustedAuth = createActionState(flow, "finishMfaTrustedAuth", act);
finishMfaTrustedAuth.getTransitionSet().add(createTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS, CasWebflowConstants.STATE_ID_SUCCESS));
createStateDefaultTransition(finishMfaTrustedAuth, CasWebflowConstants.STATE_ID_SUCCESS);
}
use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class DefaultWebflowConfigurer method createRememberMeAuthnWebflowConfig.
private void createRememberMeAuthnWebflowConfig(final Flow flow) {
if (casProperties.getTicket().getTgt().getRememberMe().isEnabled()) {
createFlowVariable(flow, CasWebflowConstants.VAR_ID_CREDENTIAL, RememberMeUsernamePasswordCredential.class);
final ViewState state = (ViewState) flow.getState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);
final BinderConfiguration cfg = getViewStateBinderConfiguration(state);
cfg.addBinding(new BinderConfiguration.Binding("rememberMe", null, false));
} else {
createFlowVariable(flow, CasWebflowConstants.VAR_ID_CREDENTIAL, UsernamePasswordCredential.class);
}
}
use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class DefaultWebflowConfigurer method createServiceWarningViewState.
private void createServiceWarningViewState(final Flow flow) {
final ViewState stateWarning = createViewState(flow, CasWebflowConstants.STATE_ID_SHOW_WARNING_VIEW, CasWebflowConstants.VIEW_ID_CONFIRM);
createTransitionForState(stateWarning, CasWebflowConstants.TRANSITION_ID_SUCCESS, "finalizeWarning");
final ActionState finalizeWarn = createActionState(flow, "finalizeWarning", createEvaluateAction("serviceWarningAction"));
createTransitionForState(finalizeWarn, CasWebflowConstants.STATE_ID_REDIRECT, CasWebflowConstants.STATE_ID_REDIRECT);
}
use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class PasswordManagementWebflowConfigurer method configurePasswordReset.
private void configurePasswordReset() {
final Flow flow = getLoginFlow();
if (flow != null) {
final ViewState state = (ViewState) flow.getState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);
createTransitionForState(state, CasWebflowConstants.TRANSITION_ID_RESET_PASSWORD, CasWebflowConstants.VIEW_ID_SEND_RESET_PASSWORD_ACCT_INFO);
final ViewState accountInfo = createViewState(flow, CasWebflowConstants.VIEW_ID_SEND_RESET_PASSWORD_ACCT_INFO, CasWebflowConstants.VIEW_ID_SEND_RESET_PASSWORD_ACCT_INFO);
createTransitionForState(accountInfo, "findAccount", SEND_PASSWORD_RESET_INSTRUCTIONS_ACTION);
final ActionState sendInst = createActionState(flow, SEND_PASSWORD_RESET_INSTRUCTIONS_ACTION, createEvaluateAction("sendPasswordResetInstructionsAction"));
createTransitionForState(sendInst, CasWebflowConstants.TRANSITION_ID_SUCCESS, CasWebflowConstants.VIEW_ID_SENT_RESET_PASSWORD_ACCT_INFO);
createTransitionForState(sendInst, CasWebflowConstants.TRANSITION_ID_ERROR, accountInfo.getId());
createViewState(flow, CasWebflowConstants.VIEW_ID_SENT_RESET_PASSWORD_ACCT_INFO, CasWebflowConstants.VIEW_ID_SENT_RESET_PASSWORD_ACCT_INFO);
final Flow pswdFlow = buildFlow("classpath:/webflow/pswdreset/pswdreset-webflow.xml", FLOW_ID_PASSWORD_RESET);
createViewState(pswdFlow, "passwordResetErrorView", "casResetPasswordErrorView");
createEndState(pswdFlow, "casPasswordUpdateSuccess", "casPasswordUpdateSuccessView");
configure(pswdFlow, CAS_MUST_CHANGE_PASS_VIEW);
loginFlowDefinitionRegistry.registerFlowDefinition(pswdFlow);
}
}
Aggregations