public FlowDefinition getFlowDefinition(String id) throws NoSuchFlowDefinitionException, FlowDefinitionConstructionException { Assert.hasText(id, "An id is required to lookup a FlowDefinition"); try { if (logger.isDebugEnabled()) { logger.debug("Getting FlowDefinition with id '" + id + "'"); } return getFlowDefinitionHolder(id).getFlowDefinition(); } catch (NoSuchFlowDefinitionException e) { if (parent != null) { // try parent return parent.getFlowDefinition(id); } throw e; } }
/** * Register flow definition into login flow registry. * * @param sourceRegistry the source registry */ protected void registerMultifactorFlowDefinitionIntoLoginFlowRegistry(final FlowDefinitionRegistry sourceRegistry) { val flowIds = sourceRegistry.getFlowDefinitionIds(); for (val flowId : flowIds) { val definition = sourceRegistry.getFlowDefinition(flowId); LOGGER.trace("Registering flow definition [{}]", flowId); this.loginFlowDefinitionRegistry.registerFlowDefinition(definition); } }
@Override public Flow getLogoutFlow() { if (this.logoutFlowDefinitionRegistry == null) { LOGGER.warn("Logout flow registry is not configured correctly."); return null; } if (logoutFlowDefinitionRegistry.containsFlowDefinition(FLOW_ID_LOGOUT)) { return (Flow) this.logoutFlowDefinitionRegistry.getFlowDefinition(FLOW_ID_LOGOUT); } LOGGER.warn("Logout flow registry does not contain a logout flow definition."); return null; }
@Override public Flow getLoginFlow() { if (this.loginFlowDefinitionRegistry == null) { LOGGER.error("Login flow registry is not configured and/or initialized correctly."); return null; } val found = Arrays.asList(this.loginFlowDefinitionRegistry.getFlowDefinitionIds()).contains(FLOW_ID_LOGIN); if (found) { return (Flow) this.loginFlowDefinitionRegistry.getFlowDefinition(FLOW_ID_LOGIN); } LOGGER.error("Could not find flow definition [{}]. Available flow definition ids are [{}]", FLOW_ID_LOGIN, this.loginFlowDefinitionRegistry.getFlowDefinitionIds()); return null; }
public void testParent() { assertNotNull(registry.getParent()); assertEquals("parentFlow", registry.getParent().getFlowDefinition("parentFlow").getId()); }
public boolean containsFlowDefinition(String flowId) { boolean containsFlow = flowDefinitions.containsKey(flowId); if (!containsFlow && parent != null) { containsFlow = parent.containsFlowDefinition(flowId); } return containsFlow; }
protected List<String> getFlowDefinitionIds() { return Arrays.asList(loginFlowDefinitionRegistry.getFlowDefinitionIds()); }
/** * Helper method to register the flow built from an externalized resource in the registry. * @param resource representation of the externalized flow definition resource * @param registry the flow registry to register the flow in */ protected final void register(FlowDefinitionResource resource, FlowDefinitionRegistry registry) { registry.registerFlowDefinition(createFlowDefinitionHolder(resource)); }
/** * Augment mfa provider flow registry. * * @param mfaProviderFlowRegistry the mfa provider flow registry */ protected void augmentMultifactorProviderFlowRegistry(final FlowDefinitionRegistry mfaProviderFlowRegistry) { val flowIds = mfaProviderFlowRegistry.getFlowDefinitionIds(); Arrays.stream(flowIds).forEach(id -> { val flow = (Flow) mfaProviderFlowRegistry.getFlowDefinition(id); if (containsFlowState(flow, CasWebflowConstants.STATE_ID_REAL_SUBMIT)) { val states = getCandidateStatesForMultifactorAuthentication(); states.forEach(s -> { val state = getState(flow, s); ensureEndStateTransitionExists(state, flow, CasWebflowConstants.TRANSITION_ID_SUCCESS, CasWebflowConstants.STATE_ID_SUCCESS); ensureEndStateTransitionExists(state, flow, CasWebflowConstants.TRANSITION_ID_SUCCESS_WITH_WARNINGS, CasWebflowConstants.TRANSITION_ID_SUCCESS_WITH_WARNINGS); ensureEndStateTransitionExists(state, flow, CasWebflowConstants.TRANSITION_ID_UNAVAILABLE, CasWebflowConstants.STATE_ID_MFA_UNAVAILABLE); ensureEndStateTransitionExists(state, flow, CasWebflowConstants.TRANSITION_ID_DENY, CasWebflowConstants.STATE_ID_MFA_DENIED); }); } }); }
protected Object getHandlerInternal(HttpServletRequest request) throws Exception { String flowId = flowUrlHandler.getFlowId(request); if (flowId == null) { return null; } if (getApplicationContext().containsBean(flowId)) { Object handler = getApplicationContext().getBean(flowId); if (handler instanceof FlowHandler) { if (logger.isDebugEnabled()) { logger.debug("Mapping request with URI '" + request.getRequestURI() + "' to flow with id '" + flowId + "'; custom FlowHandler " + handler + " will manage flow execution"); } return handler; } } if (flowRegistry.containsFlowDefinition(flowId)) { if (logger.isDebugEnabled()) { logger.debug("Mapping request with URI '" + request.getRequestURI() + "' to flow with id '" + flowId + "'"); } return createDefaultFlowHandler(flowId); } if (logger.isDebugEnabled()) { logger.debug("No flow mapping found for request with URI '" + request.getRequestURI() + "'"); } return null; }
/** * Gets flow definition ids. * * @param excludedFlowIds the excluded flow ids * @return the flow definition ids */ protected List<String> getFlowDefinitionIds(final String[] excludedFlowIds) { String[] flowIds = loginFlowDefinitionRegistry.getFlowDefinitionIds(); for (final String flowId : excludedFlowIds) { flowIds = ArrayUtils.removeElement(flowIds, flowId); } return Arrays.asList(flowIds); }
/** * Register a subflow definition in the backing flow registry, typically to support a flow execution test. For test * scenarios, the subflow is often a stub used to verify parent flow input and output mapping behavior. * @param subflow the subflow */ public void registerSubflow(Flow subflow) { getSubflowRegistry().registerFlowDefinition(new StaticFlowDefinitionHolder(subflow)); }
/** * Gets login flow. * * @return the login flow */ protected Flow getLoginFlow() { final Flow flow = (Flow) this.loginFlowDefinitionRegistry.getFlowDefinition(FLOW_ID_LOGIN); return flow; }
val map = this.applicationContext.getBeansOfType(FlowDefinitionRegistry.class, false, true); map.forEach((k, v) -> Arrays.stream(v.getFlowDefinitionIds()) .filter(currentId -> { if (StringUtils.isNotBlank(flowId)) { .forEach(id -> { val flowDetails = new LinkedHashMap<String, Object>(); val def = Flow.class.cast(v.getFlowDefinition(id)); flowDetails.put("startState", def.getStartState().getId());
public boolean containsFlowDefinition(String flowId) { boolean containsFlow = flowDefinitions.containsKey(flowId); if (!containsFlow && parent != null) { containsFlow = parent.containsFlowDefinition(flowId); } return containsFlow; }
@Override @PostConstruct public void afterPropertiesSet() throws Exception { try { String[] flowIds = flowDefinitionRegistry.getFlowDefinitionIds(); flowIds = ArrayUtils.removeElement(flowIds, FLOW_ID_LOGIN); flowIds = ArrayUtils.removeElement(flowIds, FLOW_ID_LOGOUT); LOGGER.debug("Detected {} flow configurations: [{}]", flowIds.length, Arrays.toString(flowIds)); LOGGER.debug("Configuring webflow for multifactor authentication..."); setupWebflow(flowIds); LOGGER.debug("Configured webflow for multifactor authentication."); LOGGER.debug("Registering default credentials-to-principal resolver..."); registerDefaultCredentialsToPrincipalResolver(); LOGGER.debug("Registered default credentials-to-principal resolver."); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } }
/** * Register the flow built by given flow builder in specified flow definition registry. * <p> * Note that this method will set the {@link #getFlowServiceLocator() flow service locator} of this class on given * flow builder. * @param registry the registry to register the flow in * @param flowId the flow id to assign * @param flowAttributes externally assigned flow attributes that can affect flow construction * @param flowBuilder the builder used to build the flow */ protected void registerFlowDefinition(FlowDefinitionRegistry registry, String flowId, AttributeMap flowAttributes, AbstractFlowBuilder flowBuilder) { flowBuilder.setFlowServiceLocator(getFlowServiceLocator()); Flow flow = new FlowAssembler(flowId, flowAttributes, flowBuilder).assembleFlow(); FlowDefinitionHolder flowHolder = new StaticFlowDefinitionHolder(flow); registry.registerFlowDefinition(flowHolder); } }
@Override public Object getValue(final Object context) throws EvaluationException { return this.flowDefinitionRegistry.getFlowDefinition(this.subflowId); } }
validateFlowDefinitionConfiguration(flowDefinitionRegistry); LOGGER.debug("Flow definitions found in the registry are [{}]", (Object[]) flowDefinitionRegistry.getFlowDefinitionIds()); val flowId = Arrays.stream(flowDefinitionRegistry.getFlowDefinitionIds()).findFirst().get(); LOGGER.debug("Processing flow definition [{}]", flowId); val flow = (Flow) flowDefinitionRegistry.getFlowDefinition(flowId);
protected Object getHandlerInternal(HttpServletRequest request) throws Exception { String flowId = flowUrlHandler.getFlowId(request); if (getApplicationContext().containsBean(flowId)) { Object handler = getApplicationContext().getBean(flowId); if (handler instanceof FlowHandler) { if (logger.isDebugEnabled()) { logger.debug("Mapping request with URI '" + request.getRequestURI() + "' to flow with id '" + flowId + "'; custom FlowHandler " + handler + " will manage flow execution"); } return handler; } } if (flowRegistry.containsFlowDefinition(flowId)) { if (logger.isDebugEnabled()) { logger.debug("Mapping request with URI '" + request.getRequestURI() + "' to flow with id '" + flowId + "'"); } return new DefaultFlowHandler(flowId); } if (logger.isDebugEnabled()) { logger.debug("No flow mapping found for request with URI '" + request.getRequestURI() + "'"); } return null; }