/** * Factory method that creates a new transition, a path from one step in a flow to another. This method is an atomic * operation that returns a fully initialized transition. It encapsulates the selection of the transition * implementation as well as the transition assembly. * @param targetStateResolver the resolver of the target state of the transition (required) * @param matchingCriteria the criteria that matches the transition; may be null * @param executionCriteria the criteria that governs execution of the transition after match; may be null * @param attributes attributes to assign to the transition, which may also be used to affect transition * construction; may be null * @return the fully initialized transition instance */ public Transition createTransition(TargetStateResolver targetStateResolver, TransitionCriteria matchingCriteria, TransitionCriteria executionCriteria, AttributeMap<?> attributes) { Transition transition = new Transition(targetStateResolver); if (matchingCriteria != null) { transition.setMatchingCriteria(matchingCriteria); } if (executionCriteria != null) { transition.setExecutionCriteria(executionCriteria); } transition.getAttributes().putAll(attributes); return transition; }
/** * Factory method that creates a new transition, a path from one step in a flow to another. This method is an atomic * operation that returns a fully initialized transition. It encapsulates the selection of the transition * implementation as well as the transition assembly. * @param targetStateResolver the resolver of the target state of the transition (required) * @param matchingCriteria the criteria that matches the transition; may be null * @param executionCriteria the criteria that governs execution of the transition after match; may be null * @param attributes attributes to assign to the transition, which may also be used to affect transition * construction; may be null * @return the fully initialized transition instance */ public Transition createTransition(TargetStateResolver targetStateResolver, TransitionCriteria matchingCriteria, TransitionCriteria executionCriteria, AttributeMap<?> attributes) { Transition transition = new Transition(targetStateResolver); if (matchingCriteria != null) { transition.setMatchingCriteria(matchingCriteria); } if (executionCriteria != null) { transition.setExecutionCriteria(executionCriteria); } transition.getAttributes().putAll(attributes); return transition; }
/** * Factory method that creates a new transition, a path from one step in a flow to another. This method is an atomic * operation that returns a fully initialized transition. It encapsulates the selection of the transition * implementation as well as the transition assembly. * @param targetStateResolver the resolver of the target state of the transition (required) * @param matchingCriteria the criteria that matches the transition; may be null * @param executionCriteria the criteria that governs execution of the transition after match; may be null * @param attributes attributes to assign to the transition, which may also be used to affect transition * construction; may be null * @return the fully initialized transition instance */ public Transition createTransition(TargetStateResolver targetStateResolver, TransitionCriteria matchingCriteria, TransitionCriteria executionCriteria, AttributeMap attributes) { Transition transition = new Transition(targetStateResolver); if (matchingCriteria != null) { transition.setMatchingCriteria(matchingCriteria); } if (executionCriteria != null) { transition.setExecutionCriteria(executionCriteria); } transition.getAttributes().putAll(attributes); return transition; }
private void configurePasswordResetFlow(final Flow flow, final String id) { createFlowVariable(flow, FLOW_VAR_ID_PASSWORD, PasswordChangeBean.class); val binder = createStateBinderConfiguration(CollectionUtils.wrapList(FLOW_VAR_ID_PASSWORD, "confirmedPassword")); val viewState = createViewState(flow, id, id, binder); createStateModelBinding(viewState, FLOW_VAR_ID_PASSWORD, PasswordChangeBean.class); viewState.getEntryActionList().add(this.initPasswordChangeAction); val 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); val pswChangeAction = createActionState(flow, PASSWORD_CHANGE_ACTION, createEvaluateAction(PASSWORD_CHANGE_ACTION)); val transitionSet = pswChangeAction.getTransitionSet(); transitionSet.add(createTransition(PasswordChangeAction.PASSWORD_UPDATE_SUCCESS, CasWebflowConstants.STATE_ID_PASSWORD_UPDATE_SUCCESS)); transitionSet.add(createTransition(CasWebflowConstants.TRANSITION_ID_ERROR, id)); } }
public void testTransitionExecutingWithSecurity() { SecurityFlowExecutionListener listener = new SecurityFlowExecutionListener(); RequestContext context = new MockRequestContext(); Transition transition = new Transition(new DefaultTargetStateResolver("target")); SecurityRule rule = getSecurityRuleAnyAuthorized(); transition.getAttributes().put(SecurityRule.SECURITY_ATTRIBUTE_NAME, rule); configureSecurityContext(); listener.transitionExecuting(context, transition); }
public void testFlowSecuredTransition() { model.setStates(asList(new EndStateModel("end"))); TransitionModel transition = new TransitionModel(); transition.setTo("end"); transition.setSecured(new SecuredModel("ROLE_USER")); model.setGlobalTransitions(asList(transition)); Flow flow = getFlow(model); SecurityRule rule = (SecurityRule) flow.getGlobalTransitionSet().toArray()[0].getAttributes().get( SecurityRule.SECURITY_ATTRIBUTE_NAME); assertNotNull(rule); assertEquals(SecurityRule.COMPARISON_ANY, rule.getComparisonType()); assertEquals(1, rule.getAttributes().size()); assertTrue(rule.getAttributes().contains("ROLE_USER")); }
public void testSmartValidatorWithHintOnTransition() { Transition transition = new Transition(); transition.setMatchingCriteria(new DefaultTransitionCriteria(new StaticExpression(eventId))); transition.getAttributes().put("validationHints", new StaticExpression("State1")); ViewState state = new ViewState(requestContext.getRootFlow(), "state2", new StubViewFactory()); state.getTransitionSet().add(transition); requestContext.setCurrentState(state); LegacyModelValidator validator = new LegacyModelValidator(); ExtendedModel model = new ExtendedModel(); ValidationHelper helper = new ValidationHelper(model, requestContext, eventId, modelName, null, codesResolver, null); helper.setValidator(validator); helper.validate(); assertTrue(validator.fallbackInvoked); assertTrue(validator.hints.length > 0); assertEquals(Model.State1.class, validator.hints[0]); }