Search in sources :

Example 1 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 (ActionState) flow.getTransitionableState(name);
    }
    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 2 with ActionState

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

the class AbstractCasWebflowConfigurer method registerMultifactorProviderAuthenticationWebflow.

/**
     * Register multifactor provider authentication webflow.
     *
     * @param flow      the flow
     * @param subflowId the subflow id
     * @param registry  the registry
     */
protected void registerMultifactorProviderAuthenticationWebflow(final Flow flow, final String subflowId, final FlowDefinitionRegistry registry) {
    final SubflowState subflowState = createSubflowState(flow, subflowId, subflowId);
    final ActionState actionState = (ActionState) flow.getState(CasWebflowConstants.TRANSITION_ID_REAL_SUBMIT);
    final String targetStateId = actionState.getTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS).getTargetStateId();
    final List<DefaultMapping> mappings = new ArrayList<>();
    final Mapper inputMapper = createMapperToSubflowState(mappings);
    final SubflowAttributeMapper subflowMapper = createSubflowAttributeMapper(inputMapper, null);
    subflowState.setAttributeMapper(subflowMapper);
    subflowState.getTransitionSet().add(createTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS, targetStateId));
    LOGGER.debug("Retrieved action state [{}]", actionState.getId());
    createTransitionForState(actionState, subflowId, subflowId);
    registerFlowDefinitionIntoLoginFlowRegistry(registry);
    final TransitionableState state = flow.getTransitionableState(CasWebflowConstants.TRANSITION_ID_INITIAL_AUTHN_REQUEST_VALIDATION_CHECK);
    createTransitionForState(state, subflowId, subflowId);
}
Also used : DefaultMapper(org.springframework.binding.mapping.impl.DefaultMapper) SubflowAttributeMapper(org.springframework.webflow.engine.SubflowAttributeMapper) GenericSubflowAttributeMapper(org.springframework.webflow.engine.support.GenericSubflowAttributeMapper) Mapper(org.springframework.binding.mapping.Mapper) SubflowAttributeMapper(org.springframework.webflow.engine.SubflowAttributeMapper) GenericSubflowAttributeMapper(org.springframework.webflow.engine.support.GenericSubflowAttributeMapper) ArrayList(java.util.ArrayList) SubflowState(org.springframework.webflow.engine.SubflowState) DefaultMapping(org.springframework.binding.mapping.impl.DefaultMapping) TransitionableState(org.springframework.webflow.engine.TransitionableState) ActionState(org.springframework.webflow.engine.ActionState)

Example 3 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) {
    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);
}
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 4 with ActionState

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

the class DefaultWebflowConfigurer method createGatewayServicesMgmtAction.

private void createGatewayServicesMgmtAction(final Flow flow) {
    final ActionState gatewayServicesManagementCheck = createActionState(flow, CasWebflowConstants.STATE_ID_GATEWAY_SERVICES_MGMT_CHECK, createEvaluateAction("gatewayServicesManagementCheck"));
    createTransitionForState(gatewayServicesManagementCheck, CasWebflowConstants.STATE_ID_SUCCESS, CasWebflowConstants.STATE_ID_REDIRECT);
}
Also used : ActionState(org.springframework.webflow.engine.ActionState)

Example 5 with ActionState

use of org.springframework.webflow.engine.ActionState 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);
}
Also used : ViewState(org.springframework.webflow.engine.ViewState) ActionState(org.springframework.webflow.engine.ActionState)

Aggregations

ActionState (org.springframework.webflow.engine.ActionState)31 Flow (org.springframework.webflow.engine.Flow)15 ViewState (org.springframework.webflow.engine.ViewState)5 Transition (org.springframework.webflow.engine.Transition)3 ArrayList (java.util.ArrayList)2 Action (org.springframework.webflow.execution.Action)2 Mapper (org.springframework.binding.mapping.Mapper)1 DefaultMapper (org.springframework.binding.mapping.impl.DefaultMapper)1 DefaultMapping (org.springframework.binding.mapping.impl.DefaultMapping)1 DecisionState (org.springframework.webflow.engine.DecisionState)1 SubflowAttributeMapper (org.springframework.webflow.engine.SubflowAttributeMapper)1 SubflowState (org.springframework.webflow.engine.SubflowState)1 TransitionSet (org.springframework.webflow.engine.TransitionSet)1 TransitionableState (org.springframework.webflow.engine.TransitionableState)1 BinderConfiguration (org.springframework.webflow.engine.builder.BinderConfiguration)1 DefaultTargetStateResolver (org.springframework.webflow.engine.support.DefaultTargetStateResolver)1 GenericSubflowAttributeMapper (org.springframework.webflow.engine.support.GenericSubflowAttributeMapper)1