/** * 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, "viewMfaUnrecognizedAuthnMethodErrorView")); }
val transitionSet = subflowState.getTransitionSet(); transitionSet.add(createTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS, targetSuccessId)); transitionSet.add(createTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS_WITH_WARNINGS, targetWarningsId));
@SuppressWarnings("unchecked") public void testReturnWithOutput() { subflowState.setAttributeMapper(new SubflowAttributeMapper() { public MutableAttributeMap<Object> createSubflowInput(RequestContext context) { return new LocalAttributeMap<>(); } public void mapSubflowOutput(AttributeMap<?> flowOutput, RequestContext context) { assertEquals("bar", flowOutput.get("foo")); } }); subflowState.getTransitionSet().add(new Transition(on("end"), to("whatev"))); new State(parentFlow, "whatev") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { } }; new EndState(subflow, "end"); subflow.setOutputMapper((source, target) -> { MutableAttributeMap<Object> map = (MutableAttributeMap<Object>) target; map.put("foo", "bar"); return new DefaultMappingResults(source, target, Collections.emptyList()); }); subflowState.enter(context); assertEquals("parent", context.getActiveFlow().getId()); }
public void testEnterEndStateTerminateFlowSession() { final Flow subflow = new Flow("mySubflow"); EndState state = new EndState(subflow, "end"); MockFlowSession session = new MockFlowSession(subflow); Flow parent = new Flow("parent"); SubflowState subflowState = new SubflowState(parent, "subflow", new AbstractGetValueExpression() { public Object getValue(Object context) throws EvaluationException { return subflow; } }); subflowState.getTransitionSet().add(new Transition(on("end"), to("end"))); new EndState(parent, "end"); MockFlowSession parentSession = new MockFlowSession(parent); parentSession.setState(subflowState); session.setParent(parentSession); MockRequestControlContext context = new MockRequestControlContext(new MockFlowExecutionContext(session)); state.enter(context); assertFalse("Active", context.getFlowExecutionContext().isActive()); }