use of org.springframework.webflow.engine.Flow in project cas by apereo.
the class AbstractCasWebflowConfigurer method createFlowVariable.
/**
* Create flow variable flow variable.
*
* @param flow the flow
* @param id the id
* @param type the type
* @return the flow variable
*/
protected FlowVariable createFlowVariable(final Flow flow, final String id, final Class type) {
final Optional<FlowVariable> opt = Arrays.stream(flow.getVariables()).filter(v -> v.getName().equalsIgnoreCase(id)).findFirst();
if (opt.isPresent()) {
return opt.get();
}
final FlowVariable flowVar = new FlowVariable(id, new BeanFactoryVariableValueFactory(type, applicationContext.getAutowireCapableBeanFactory()));
flow.addVariable(flowVar);
return flowVar;
}
use of org.springframework.webflow.engine.Flow 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);
}
use of org.springframework.webflow.engine.Flow in project cas by apereo.
the class ClearWebflowCredentialAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
WebUtils.putCredential(requestContext, null);
final String current = requestContext.getCurrentEvent().getId();
if (current.equalsIgnoreCase(CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE) || current.equalsIgnoreCase(CasWebflowConstants.TRANSITION_ID_ERROR)) {
LOGGER.debug("Current event signaled a failure. Recreating credentials instance from the context");
try {
final Flow flow = (Flow) requestContext.getFlowExecutionContext().getDefinition();
final FlowVariable var = flow.getVariable(CasWebflowConstants.VAR_ID_CREDENTIAL);
var.create(requestContext);
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
return null;
}
use of org.springframework.webflow.engine.Flow in project cas by apereo.
the class AcceptableUsagePolicyWebflowConfigurer method doInitialize.
@Override
protected void doInitialize() throws Exception {
final Flow flow = getLoginFlow();
if (flow != null) {
createVerifyActionState(flow);
createAcceptableUsagePolicyView(flow);
createSubmitActionState(flow);
createTransitionStateToAcceptableUsagePolicy(flow);
}
}
use of org.springframework.webflow.engine.Flow in project cas by apereo.
the class GraphicalUserAuthenticationWebflowConfigurer method doInitialize.
@Override
protected void doInitialize() throws Exception {
final Flow flow = getLoginFlow();
if (flow != null) {
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();
createTransitionForState(state, TRANSITION_ID_GUA_GET_USERID, STATE_ID_GUA_GET_USERID);
final ViewState viewState = createViewState(flow, STATE_ID_GUA_GET_USERID, "casGuaGetUserIdView");
createTransitionForState(viewState, CasWebflowConstants.TRANSITION_ID_SUBMIT, STATE_ID_GUA_DISPLAY_USER_GFX);
final ViewState viewStateGfx = createViewState(flow, STATE_ID_GUA_DISPLAY_USER_GFX, "casGuaDisplayUserGraphicsView");
viewStateGfx.getRenderActionList().add(createEvaluateAction("displayUserGraphicsBeforeAuthenticationAction"));
createTransitionForState(viewStateGfx, CasWebflowConstants.TRANSITION_ID_SUBMIT, STATE_ID_ACCEPT_GUA);
final ActionState acceptState = createActionState(flow, STATE_ID_ACCEPT_GUA, createEvaluateAction("acceptUserGraphicsForAuthenticationAction"));
createStateDefaultTransition(acceptState, targetStateId);
}
}
Aggregations