Search in sources :

Example 16 with ActionState

use of org.springframework.webflow.engine.ActionState in project cas by apereo.

the class AbstractCasWebflowConfigurer method createEvaluateActionForExistingActionState.

/**
 * Create evaluate action for action state action.
 *
 * @param flow             the flow
 * @param actionStateId    the action state id
 * @param evaluateActionId the evaluate action id
 * @return the action
 */
public Action createEvaluateActionForExistingActionState(final Flow flow, final String actionStateId, final String evaluateActionId) {
    final ActionState action = getState(flow, actionStateId, ActionState.class);
    final Action[] actions = action.getActionList().toArray();
    Arrays.stream(actions).forEach(action.getActionList()::remove);
    final Action evaluateAction = createEvaluateAction(evaluateActionId);
    action.getActionList().add(evaluateAction);
    action.getActionList().addAll(actions);
    return evaluateAction;
}
Also used : Action(org.springframework.webflow.execution.Action) ExternalRedirectAction(org.springframework.webflow.action.ExternalRedirectAction) EvaluateAction(org.springframework.webflow.action.EvaluateAction) ActionState(org.springframework.webflow.engine.ActionState)

Example 17 with ActionState

use of org.springframework.webflow.engine.ActionState in project cas by apereo.

the class AbstractCasWebflowConfigurer method createClonedActionState.

/**
 * Clone and create action state.
 *
 * @param flow                 the flow
 * @param actionStateId        the action state id
 * @param actionStateIdToClone the action state id to clone
 */
public void createClonedActionState(final Flow flow, final String actionStateId, final String actionStateIdToClone) {
    final ActionState generateServiceTicket = getState(flow, actionStateIdToClone, ActionState.class);
    final ActionState consentTicketAction = createActionState(flow, actionStateId);
    cloneActionState(generateServiceTicket, consentTicketAction);
}
Also used : ActionState(org.springframework.webflow.engine.ActionState)

Example 18 with ActionState

use of org.springframework.webflow.engine.ActionState in project cas by apereo.

the class AbstractCasWebflowConfigurer method createActionState.

@Override
public ActionState createActionState(final Flow flow, final String name, final Action... actions) {
    if (containsFlowState(flow, name)) {
        LOGGER.debug("Flow [{}] already contains a definition for state id [{}]", flow.getId(), name);
        return getTransitionableState(flow, name, ActionState.class);
    }
    final ActionState actionState = new ActionState(flow, name);
    LOGGER.debug("Created action state [{}]", actionState.getId());
    actionState.getActionList().addAll(actions);
    LOGGER.debug("Added action to the action state [{}] list of actions: [{}]", actionState.getId(), actionState.getActionList());
    return actionState;
}
Also used : ActionState(org.springframework.webflow.engine.ActionState)

Example 19 with ActionState

use of org.springframework.webflow.engine.ActionState 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) {
    validateFlowDefinitionConfiguration(flowDefinitionRegistry);
    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 = getState(flow, CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM, ActionState.class);
    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(MFA_VERIFY_TRUST_ACTION_BEAN_ID));
    // handle device registration
    if (enableDeviceRegistration) {
        createTransitionForState(verifyAction, CasWebflowConstants.TRANSITION_ID_YES, CasWebflowConstants.STATE_ID_FINISH_MFA_TRUSTED_AUTH);
    } else {
        createTransitionForState(verifyAction, CasWebflowConstants.TRANSITION_ID_YES, CasWebflowConstants.STATE_ID_REAL_SUBMIT);
    }
    createTransitionForState(verifyAction, CasWebflowConstants.TRANSITION_ID_NO, targetStateId);
    createDecisionState(flow, CasWebflowConstants.DECISION_STATE_REQUIRE_REGISTRATION, isDeviceRegistrationRequired(), CasWebflowConstants.VIEW_ID_REGISTER_DEVICE, CasWebflowConstants.STATE_ID_REAL_SUBMIT);
    final ActionState submit = getState(flow, CasWebflowConstants.STATE_ID_REAL_SUBMIT, ActionState.class);
    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");
    final Transition viewRegisterTransition = createTransition(CasWebflowConstants.TRANSITION_ID_SUBMIT, CasWebflowConstants.STATE_ID_REGISTER_TRUSTED_DEVICE);
    viewRegister.getTransitionSet().add(viewRegisterTransition);
    final ActionState registerAction = createActionState(flow, CasWebflowConstants.STATE_ID_REGISTER_TRUSTED_DEVICE, createEvaluateAction(MFA_SET_TRUST_ACTION_BEAN_ID));
    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, CasWebflowConstants.STATE_ID_FINISH_MFA_TRUSTED_AUTH, act);
    final Transition finishedTransition = createTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS, CasWebflowConstants.STATE_ID_SUCCESS);
    finishMfaTrustedAuth.getTransitionSet().add(finishedTransition);
    createStateDefaultTransition(finishMfaTrustedAuth, CasWebflowConstants.STATE_ID_SUCCESS);
}
Also used : Action(org.springframework.webflow.execution.Action) Transition(org.springframework.webflow.engine.Transition) DefaultTargetStateResolver(org.springframework.webflow.engine.support.DefaultTargetStateResolver) ViewState(org.springframework.webflow.engine.ViewState) ActionState(org.springframework.webflow.engine.ActionState) Flow(org.springframework.webflow.engine.Flow)

Example 20 with ActionState

use of org.springframework.webflow.engine.ActionState in project cas by apereo.

the class DefaultLoginWebflowConfigurer method createGenerateServiceTicketAction.

/**
 * Create generate service ticket action.
 *
 * @param flow the flow
 */
protected void createGenerateServiceTicketAction(final Flow flow) {
    final ActionState handler = createActionState(flow, CasWebflowConstants.STATE_ID_GENERATE_SERVICE_TICKET, createEvaluateAction(CasWebflowConstants.ACTION_ID_GENERATE_SERVICE_TICKET));
    createTransitionForState(handler, CasWebflowConstants.TRANSITION_ID_SUCCESS, CasWebflowConstants.STATE_ID_REDIRECT);
    createTransitionForState(handler, CasWebflowConstants.TRANSITION_ID_WARN, CasWebflowConstants.STATE_ID_WARN);
    createTransitionForState(handler, CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE, CasWebflowConstants.STATE_ID_HANDLE_AUTHN_FAILURE);
    createTransitionForState(handler, CasWebflowConstants.TRANSITION_ID_ERROR, CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM);
    createTransitionForState(handler, CasWebflowConstants.TRANSITION_ID_GATEWAY, CasWebflowConstants.STATE_ID_GATEWAY_SERVICES_MGMT_CHECK);
}
Also used : ActionState(org.springframework.webflow.engine.ActionState)

Aggregations

ActionState (org.springframework.webflow.engine.ActionState)59 Flow (org.springframework.webflow.engine.Flow)17 ViewState (org.springframework.webflow.engine.ViewState)12 Transition (org.springframework.webflow.engine.Transition)6 Action (org.springframework.webflow.execution.Action)4 ArrayList (java.util.ArrayList)2 EvaluateAction (org.springframework.webflow.action.EvaluateAction)2 SubflowState (org.springframework.webflow.engine.SubflowState)2 BinderConfiguration (org.springframework.webflow.engine.builder.BinderConfiguration)2 DefaultTargetStateResolver (org.springframework.webflow.engine.support.DefaultTargetStateResolver)2 AccountLockedException (javax.security.auth.login.AccountLockedException)1 AccountNotFoundException (javax.security.auth.login.AccountNotFoundException)1 CredentialExpiredException (javax.security.auth.login.CredentialExpiredException)1 FailedLoginException (javax.security.auth.login.FailedLoginException)1 PrincipalException (org.apereo.cas.authentication.PrincipalException)1 UnauthorizedAuthenticationException (org.apereo.cas.authentication.adaptive.UnauthorizedAuthenticationException)1 AccountDisabledException (org.apereo.cas.authentication.exceptions.AccountDisabledException)1 AccountPasswordMustChangeException (org.apereo.cas.authentication.exceptions.AccountPasswordMustChangeException)1 InvalidLoginLocationException (org.apereo.cas.authentication.exceptions.InvalidLoginLocationException)1 InvalidLoginTimeException (org.apereo.cas.authentication.exceptions.InvalidLoginTimeException)1