org.springframework.webflow.engine.ActionState Java Examples

The following examples show how to use org.springframework.webflow.engine.ActionState. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ValidateWebflowConfigurer.java    From sso with MIT License 6 votes vote down vote up
/**
 * 发送邮箱前输入验证码流程
 */
private void createPasswordResetValidateFlow() {
    final Flow flow = getLoginFlow();
    if (flow != null) {
        ViewState accountInfo = (ViewState) flow.getState(CasWebflowConstants.VIEW_ID_SEND_RESET_PASSWORD_ACCT_INFO);
        //提交查找用户后,先校验验证码
        createTransitionForState(accountInfo, "findAccount", VALIDATE_CAPTCHA_ACTION, true);
        //校验图片动作
        ActionState actionState = createActionState(flow, VALIDATE_CAPTCHA_ACTION, createEvaluateAction(VALIDATE_CAPTCHA_ACTION));
        //失败重新是发送页
        createTransitionForState(actionState, CasWebflowConstants.TRANSITION_ID_RESET_PASSWORD,
                CasWebflowConstants.VIEW_ID_SEND_RESET_PASSWORD_ACCT_INFO);
        //发送邮件
        createTransitionForState(actionState, "sendInstructions", "sendInstructions");
    }
}
 
Example #2
Source File: CasMultiFactorWebflowConfigurer.java    From cas-mfa with Apache License 2.0 6 votes vote down vote up
/**
 * Add multi factor outcome transitions to submission action state.
 *
 * @param flow the flow
 * @param flowIds the flow ids
 */
protected void addMultiFactorOutcomeTransitionsToSubmissionActionState(final Flow flow, final String[] flowIds) {
    final ActionState actionState = (ActionState) flow.getState(STATE_DEFINITION_ID_REAL_SUBMIT);
    LOGGER.debug("Retrieved action state {}", actionState.getId());

    final Action existingAction = actionState.getActionList().get(0);
    actionState.getActionList().remove(existingAction);

    final EvaluateAction action = createEvaluateAction("initiatingAuthenticationViaFormAction");
    actionState.getActionList().add(action);
    LOGGER.debug("Set action {} for action state {}", actionState.getId());

    for (final String flowId : flowIds) {
        addTransitionToActionState(actionState, flowId, flowId);
    }

}
 
Example #3
Source File: CasMultiFactorWebflowConfigurer.java    From cas-mfa with Apache License 2.0 6 votes vote down vote up
/**
 * Create multi factor parent subflow state definitions.
 *
 * @param flow the flow
 * @param id the id
 */
protected void createMultiFactorParentSubflowStateDefinitions(final Flow flow, final String id) {
    final EvaluateAction action = createEvaluateAction("generateMfaCredentialsAction");

    final SubflowState subflowState = createSubflowState(flow, id, id, action);

    final List<DefaultMapping> mappings = new ArrayList<>();
    mappings.add(createMappingToSubflowState("mfaCredentials", "flowScope.mfaCredentials", true,
            MultiFactorCredentials.class));
    mappings.add(createMappingToSubflowState("mfaService", "flowScope.service", true,
            MultiFactorAuthenticationSupportingWebApplicationService.class));

    final Mapper inputMapper = createMapperToSubflowState(mappings);
    final SubflowAttributeMapper subflowMapper = createSubflowAttributeMapper(inputMapper, null);
    subflowState.setAttributeMapper(subflowMapper);

    final ActionState actionState = (ActionState) flow.getState(STATE_DEFINITION_ID_REAL_SUBMIT);
    final String targettedStateId = actionState.getTransition(SUCCESS_EVENT_ID).getTargetStateId();
    subflowState.getTransitionSet().add(createTransition(MFA_SUCCESS_EVENT_ID, targettedStateId));
    subflowState.getTransitionSet().add(createTransition(UNKNOWN_PRINCIPAL_ERROR_EVENT_ID,
            "viewUnknownPrincipalErrorView"));
    subflowState.getTransitionSet().add(createTransition(MFA_UNRECOGNIZED_AUTHN_METHOD_ERROR_EVENT_ID,
            VIEW_MFA_UNRECOGNIZED_AUTHN_METHOD_ERROR_VIEW));
}
 
Example #4
Source File: CustomWebflowConfigurer.java    From CAS with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定自定义的Credential信息
 *
 * @param flow
 */
protected void bindCredential(Flow flow) {

    // 重写绑定自定义credential
    createFlowVariable(flow, CasWebflowConstants.VAR_ID_CREDENTIAL, CustomCredential.class);

    // 登录页绑定新参数
    final ViewState state = (ViewState) flow.getState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);
    final BinderConfiguration cfg = getViewStateBinderConfiguration(state);
    // 由于用户名以及密码已经绑定,所以只需对新加系统参数绑定即可
    // 字段名,转换器,是否必须字段
    cfg.addBinding(new BinderConfiguration.Binding("email", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("telephone", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("capcha", null, false));



    final ActionState actionState = (ActionState) flow.getState(CasWebflowConstants.STATE_ID_REAL_SUBMIT);
    final List<Action> currentActions = new ArrayList<>();
    actionState.getActionList().forEach(currentActions::add);
    currentActions.forEach(a -> actionState.getActionList().remove(a));

    actionState.getActionList().add(createEvaluateAction("validateLoginAction"));
    currentActions.forEach(a -> actionState.getActionList().add(a));

    actionState.getTransitionSet().add(createTransition("emailError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("telephoneError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("captchaError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));


}
 
Example #5
Source File: CustomWebflowConfigurer.java    From CAS with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定自定义的Credential信息
 *
 * @param flow
 */
protected void bindCredential(Flow flow) {

    // 重写绑定自定义credential
    createFlowVariable(flow, CasWebflowConstants.VAR_ID_CREDENTIAL, CustomCredential.class);

    // 登录页绑定新参数
    final ViewState state = (ViewState) flow.getState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);
    final BinderConfiguration cfg = getViewStateBinderConfiguration(state);
    // 由于用户名以及密码已经绑定,所以只需对新加系统参数绑定即可
    // 字段名,转换器,是否必须字段
    cfg.addBinding(new BinderConfiguration.Binding("email", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("telephone", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("capcha", null, false));



    final ActionState actionState = (ActionState) flow.getState(CasWebflowConstants.STATE_ID_REAL_SUBMIT);
    final List<Action> currentActions = new ArrayList<>();
    actionState.getActionList().forEach(currentActions::add);
    currentActions.forEach(a -> actionState.getActionList().remove(a));

    actionState.getActionList().add(createEvaluateAction("validateLoginAction"));
    currentActions.forEach(a -> actionState.getActionList().add(a));

    actionState.getTransitionSet().add(createTransition("emailError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("telephoneError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("captchaError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));


}
 
Example #6
Source File: CustomWebflowConfigurer.java    From CAS with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定自定义的Credential信息
 *
 * @param flow
 */
protected void bindCredential(Flow flow) {

    // 重写绑定自定义credential
    createFlowVariable(flow, CasWebflowConstants.VAR_ID_CREDENTIAL, CustomCredential.class);

    // 登录页绑定新参数
    final ViewState state = (ViewState) flow.getState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);
    final BinderConfiguration cfg = getViewStateBinderConfiguration(state);
    // 由于用户名以及密码已经绑定,所以只需对新加系统参数绑定即可
    // 字段名,转换器,是否必须字段
    cfg.addBinding(new BinderConfiguration.Binding("email", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("telephone", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("capcha", null, false));



    final ActionState actionState = (ActionState) flow.getState(CasWebflowConstants.STATE_ID_REAL_SUBMIT);
    final List<Action> currentActions = new ArrayList<>();
    actionState.getActionList().forEach(currentActions::add);
    currentActions.forEach(a -> actionState.getActionList().remove(a));

    actionState.getActionList().add(createEvaluateAction("validateLoginAction"));
    currentActions.forEach(a -> actionState.getActionList().add(a));

    actionState.getTransitionSet().add(createTransition("emailError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("telephoneError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("captchaError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));


}
 
Example #7
Source File: CustomWebflowConfigurer.java    From CAS with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定自定义的Credential信息
 *
 * @param flow
 */
protected void bindCredential(Flow flow) {

    // 重写绑定自定义credential
    createFlowVariable(flow, CasWebflowConstants.VAR_ID_CREDENTIAL, CustomCredential.class);

    // 登录页绑定新参数
    final ViewState state = (ViewState) flow.getState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);
    final BinderConfiguration cfg = getViewStateBinderConfiguration(state);
    // 由于用户名以及密码已经绑定,所以只需对新加系统参数绑定即可
    // 字段名,转换器,是否必须字段
    cfg.addBinding(new BinderConfiguration.Binding("email", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("telephone", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("capcha", null, false));



    final ActionState actionState = (ActionState) flow.getState(CasWebflowConstants.STATE_ID_REAL_SUBMIT);
    final List<Action> currentActions = new ArrayList<>();
    actionState.getActionList().forEach(currentActions::add);
    currentActions.forEach(a -> actionState.getActionList().remove(a));

    actionState.getActionList().add(createEvaluateAction("validateLoginAction"));
    currentActions.forEach(a -> actionState.getActionList().add(a));

    actionState.getTransitionSet().add(createTransition("emailError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("telephoneError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("captchaError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));


}
 
Example #8
Source File: CustomWebflowConfigurer.java    From CAS with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定自定义的Credential信息
 *
 * @param flow
 */
protected void bindCredential(Flow flow) {

    // 重写绑定自定义credential
    createFlowVariable(flow, CasWebflowConstants.VAR_ID_CREDENTIAL, CustomCredential.class);

    // 登录页绑定新参数
    final ViewState state = (ViewState) flow.getState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);
    final BinderConfiguration cfg = getViewStateBinderConfiguration(state);
    // 由于用户名以及密码已经绑定,所以只需对新加系统参数绑定即可
    // 字段名,转换器,是否必须字段
    cfg.addBinding(new BinderConfiguration.Binding("email", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("telephone", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("capcha", null, false));



    final ActionState actionState = (ActionState) flow.getState(CasWebflowConstants.STATE_ID_REAL_SUBMIT);
    final List<Action> currentActions = new ArrayList<>();
    actionState.getActionList().forEach(currentActions::add);
    currentActions.forEach(a -> actionState.getActionList().remove(a));

    actionState.getActionList().add(createEvaluateAction("validateLoginAction"));
    currentActions.forEach(a -> actionState.getActionList().add(a));

    actionState.getTransitionSet().add(createTransition("emailError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("telephoneError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("captchaError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));


}
 
Example #9
Source File: CustomWebflowConfigurer.java    From CAS with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定自定义的Credential信息
 *
 * @param flow
 */
protected void bindCredential(Flow flow) {

    // 重写绑定自定义credential
    createFlowVariable(flow, CasWebflowConstants.VAR_ID_CREDENTIAL, CustomCredential.class);

    // 登录页绑定新参数
    final ViewState state = (ViewState) flow.getState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);
    final BinderConfiguration cfg = getViewStateBinderConfiguration(state);
    // 由于用户名以及密码已经绑定,所以只需对新加系统参数绑定即可
    // 字段名,转换器,是否必须字段
    cfg.addBinding(new BinderConfiguration.Binding("email", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("telephone", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("capcha", null, false));



    final ActionState actionState = (ActionState) flow.getState(CasWebflowConstants.STATE_ID_REAL_SUBMIT);
    final List<Action> currentActions = new ArrayList<>();
    actionState.getActionList().forEach(currentActions::add);
    currentActions.forEach(a -> actionState.getActionList().remove(a));

    actionState.getActionList().add(createEvaluateAction("validateLoginAction"));
    currentActions.forEach(a -> actionState.getActionList().add(a));

    actionState.getTransitionSet().add(createTransition("emailError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("telephoneError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("captchaError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));


}
 
Example #10
Source File: CustomWebflowConfigurer.java    From CAS with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定自定义的Credential信息
 *
 * @param flow
 */
protected void bindCredential(Flow flow) {

    // 重写绑定自定义credential
    createFlowVariable(flow, CasWebflowConstants.VAR_ID_CREDENTIAL, CustomCredential.class);

    // 登录页绑定新参数
    final ViewState state = (ViewState) flow.getState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);
    final BinderConfiguration cfg = getViewStateBinderConfiguration(state);
    // 由于用户名以及密码已经绑定,所以只需对新加系统参数绑定即可
    // 字段名,转换器,是否必须字段
    cfg.addBinding(new BinderConfiguration.Binding("email", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("telephone", null, false));
    cfg.addBinding(new BinderConfiguration.Binding("capcha", null, false));



    final ActionState actionState = (ActionState) flow.getState(CasWebflowConstants.STATE_ID_REAL_SUBMIT);
    final List<Action> currentActions = new ArrayList<>();
    actionState.getActionList().forEach(currentActions::add);
    currentActions.forEach(a -> actionState.getActionList().remove(a));

    actionState.getActionList().add(createEvaluateAction("validateLoginAction"));
    currentActions.forEach(a -> actionState.getActionList().add(a));

    actionState.getTransitionSet().add(createTransition("emailError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("telephoneError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    actionState.getTransitionSet().add(createTransition("captchaError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));


}
 
Example #11
Source File: ValidateWebflowConfigurer.java    From sso with MIT License 5 votes vote down vote up
/**
 * 登录校验流程
 */
private void createLoginValidateValidateFlow() {
    final Flow flow = getLoginFlow();
    if (flow != null) {
        final ActionState state = (ActionState) flow.getState(CasWebflowConstants.TRANSITION_ID_REAL_SUBMIT);
        final List<Action> currentActions = new ArrayList<>();
        state.getActionList().forEach(currentActions::add);
        currentActions.forEach(a -> state.getActionList().remove(a));

        state.getActionList().add(createEvaluateAction("validateLoginCaptchaAction"));
        currentActions.forEach(a -> state.getActionList().add(a));

        state.getTransitionSet().add(createTransition("captchaError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    }
}
 
Example #12
Source File: CasMultiFactorWebflowConfigurer.java    From cas-mfa with Apache License 2.0 5 votes vote down vote up
/**
 * Add ticket granting ticket exists check.
 *
 * @param flow the flow
 * @param flowIds the flow ids
 */
protected void addTicketGrantingTicketExistsCheck(final Flow flow, final String[] flowIds) {
    try {
        final ActionState actionState = new ActionState(flow, "mfaTicketGrantingTicketExistsCheck");
        LOGGER.debug("Created action state {}", actionState.getId());
        actionState.getActionList().add(createEvaluateAction("validateInitialMfaRequestAction"));
        LOGGER.debug("Added action to the action state {} list of actions: {}", actionState.getId(), actionState.getActionList());

        for (final String flowId : flowIds) {
            addTransitionToActionState(actionState, flowId, flowId);
        }
        final TransitionableState currentStartState = TransitionableState.class.cast(flow.getStartState());

        LOGGER.debug("Mapping the transition [{}] of state [{}] to the existing start state [{}]",
                ValidateInitialMultiFactorAuthenticationRequestAction.EVENT_ID_REQUIRE_TGT,
                actionState.getId(), currentStartState.getId());
        addTransitionToActionState(actionState, "requireTgt", currentStartState.getId());

        if (!STATE_DEFINITION_ID_TGT_EXISTS_CHECK.equals(currentStartState.getId())) {
            LOGGER.debug("Found a custom existing start state [{}]. Will add a default transition to "
                            + "[{}] so the flow can resume normally.",
                    STATE_DEFINITION_ID_TGT_EXISTS_CHECK,
                    currentStartState.getId());
            addDefaultTransitionToState(currentStartState, STATE_DEFINITION_ID_TGT_EXISTS_CHECK);
        }

        flow.setStartState(actionState);
        LOGGER.debug("Replaced flow {} start state with {}", flow.getId(), flow.getStartState().getId());
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}
 
Example #13
Source File: CasMultiFactorWebflowConfigurer.java    From cas-mfa with Apache License 2.0 5 votes vote down vote up
/**
 * Add transition to action state.
 *
 * @param actionState     the action state
 * @param criteriaOutcome the criteria outcome
 * @param targetState     the target state
 */
protected static void addTransitionToActionState(final ActionState actionState,
                                                 final String criteriaOutcome, final String targetState) {
    try {
        final Transition transition = createTransition(criteriaOutcome, targetState);
        actionState.getTransitionSet().add(transition);

        LOGGER.debug("Added transition {} to the action state {}", transition.getId(), actionState.getId());
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}