Search in sources :

Example 1 with BinderModel

use of org.springframework.webflow.engine.model.BinderModel in project cas by apereo.

the class DuoMultifactorWebflowConfigurer method buildDuoFlowRegistry.

private FlowDefinitionRegistry buildDuoFlowRegistry(final MultifactorAuthenticationProvider p) {
    final DynamicFlowModelBuilder modelBuilder = new DynamicFlowModelBuilder();
    // vars
    final LinkedList<VarModel> vars = new LinkedList<>();
    vars.add(new VarModel(CasWebflowConstants.VAR_ID_CREDENTIAL, DuoCredential.class.getName()));
    modelBuilder.setVars(vars);
    // starts
    final LinkedList<AbstractActionModel> starts = new LinkedList<>();
    starts.add(new EvaluateModel("initialFlowSetupAction"));
    modelBuilder.setOnStartActions(starts);
    // states
    final LinkedList<AbstractStateModel> states = new LinkedList<>();
    ActionStateModel actModel = new ActionStateModel(CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM);
    LinkedList<AbstractActionModel> actions = new LinkedList<>();
    actions.add(new EvaluateModel("initializeLoginAction"));
    actModel.setActions(actions);
    LinkedList<TransitionModel> trans = new LinkedList<>();
    TransitionModel transModel = new TransitionModel();
    transModel.setOn(CasWebflowConstants.TRANSITION_ID_SUCCESS);
    transModel.setTo("determineDuoRequest");
    trans.add(transModel);
    actModel.setTransitions(trans);
    states.add(actModel);
    ///////////////
    actModel = new ActionStateModel("determineDuoRequest");
    actions = new LinkedList<>();
    actions.add(new EvaluateModel("checkWebAuthenticationRequestAction"));
    actModel.setActions(actions);
    trans = new LinkedList<>();
    transModel = new TransitionModel();
    transModel.setOn(CasWebflowConstants.TRANSITION_ID_YES);
    transModel.setTo("viewLoginFormDuo");
    trans.add(transModel);
    transModel = new TransitionModel();
    transModel.setOn(CasWebflowConstants.TRANSITION_ID_NO);
    transModel.setTo("doNonWebAuthentication");
    trans.add(transModel);
    actModel.setTransitions(trans);
    states.add(actModel);
    ///////////////
    actModel = new ActionStateModel("doNonWebAuthentication");
    actions = new LinkedList<>();
    actions.add(new EvaluateModel("duoNonWebAuthenticationAction"));
    actModel.setActions(actions);
    trans = new LinkedList<>();
    transModel = new TransitionModel();
    transModel.setOn(CasWebflowConstants.TRANSITION_ID_SUCCESS);
    transModel.setTo("finalizeAuthentication");
    trans.add(transModel);
    actModel.setTransitions(trans);
    states.add(actModel);
    ///////////////
    actModel = new ActionStateModel("finalizeAuthentication");
    actions = new LinkedList<>();
    actions.add(new EvaluateModel("duoAuthenticationWebflowAction"));
    actModel.setActions(actions);
    trans = new LinkedList<>();
    transModel = new TransitionModel();
    transModel.setOn(CasWebflowConstants.TRANSITION_ID_SUCCESS);
    transModel.setTo(CasWebflowConstants.TRANSITION_ID_SUCCESS);
    trans.add(transModel);
    actModel.setTransitions(trans);
    states.add(actModel);
    /////////////////
    final ViewStateModel viewState = new ViewStateModel("viewLoginFormDuo");
    viewState.setView("casDuoLoginView");
    viewState.setModel(CasWebflowConstants.VAR_ID_CREDENTIAL);
    final BinderModel bm = new BinderModel();
    final LinkedList<BindingModel> bindings = new LinkedList<>();
    final BindingModel bme = new BindingModel("signedDuoResponse", null, null);
    bindings.add(bme);
    bm.setBindings(bindings);
    viewState.setBinder(bm);
    actions = new LinkedList<>();
    actions.add(new EvaluateModel("prepareDuoWebLoginFormAction"));
    viewState.setOnEntryActions(actions);
    transModel = new TransitionModel();
    transModel.setOn(CasWebflowConstants.TRANSITION_ID_SUBMIT);
    transModel.setTo(CasWebflowConstants.TRANSITION_ID_REAL_SUBMIT);
    transModel.setBind(Boolean.TRUE.toString());
    transModel.setValidate(Boolean.FALSE.toString());
    trans.add(transModel);
    viewState.setTransitions(trans);
    states.add(viewState);
    /////////////////
    actModel = new ActionStateModel(CasWebflowConstants.TRANSITION_ID_REAL_SUBMIT);
    actions = new LinkedList<>();
    actions.add(new EvaluateModel("duoAuthenticationWebflowAction"));
    actModel.setActions(actions);
    trans = new LinkedList<>();
    transModel = new TransitionModel();
    transModel.setOn(CasWebflowConstants.TRANSITION_ID_SUCCESS);
    transModel.setTo(CasWebflowConstants.TRANSITION_ID_SUCCESS);
    trans.add(transModel);
    transModel = new TransitionModel();
    transModel.setOn(CasWebflowConstants.TRANSITION_ID_ERROR);
    transModel.setTo(CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM);
    trans.add(transModel);
    actModel.setTransitions(trans);
    states.add(actModel);
    ////////////////////
    states.add(new EndStateModel(CasWebflowConstants.TRANSITION_ID_SUCCESS));
    ////////////////////
    modelBuilder.setStates(states);
    final FlowModelHolder holder = new DefaultFlowModelHolder(modelBuilder);
    final FlowBuilder flowBuilder = new FlowModelFlowBuilder(holder);
    final FlowDefinitionRegistryBuilder builder = new FlowDefinitionRegistryBuilder(this.applicationContext, flowBuilderServices);
    builder.addFlowBuilder(flowBuilder, p.getId());
    return builder.build();
}
Also used : FlowDefinitionRegistryBuilder(org.springframework.webflow.config.FlowDefinitionRegistryBuilder) ActionStateModel(org.springframework.webflow.engine.model.ActionStateModel) TransitionModel(org.springframework.webflow.engine.model.TransitionModel) BindingModel(org.springframework.webflow.engine.model.BindingModel) FlowModelFlowBuilder(org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder) AbstractActionModel(org.springframework.webflow.engine.model.AbstractActionModel) DefaultFlowModelHolder(org.springframework.webflow.engine.model.builder.DefaultFlowModelHolder) LinkedList(java.util.LinkedList) EndStateModel(org.springframework.webflow.engine.model.EndStateModel) FlowModelHolder(org.springframework.webflow.engine.model.registry.FlowModelHolder) DefaultFlowModelHolder(org.springframework.webflow.engine.model.builder.DefaultFlowModelHolder) FlowBuilder(org.springframework.webflow.engine.builder.FlowBuilder) FlowModelFlowBuilder(org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder) DynamicFlowModelBuilder(org.apereo.cas.web.flow.DynamicFlowModelBuilder) AbstractStateModel(org.springframework.webflow.engine.model.AbstractStateModel) VarModel(org.springframework.webflow.engine.model.VarModel) ViewStateModel(org.springframework.webflow.engine.model.ViewStateModel) EvaluateModel(org.springframework.webflow.engine.model.EvaluateModel) BinderModel(org.springframework.webflow.engine.model.BinderModel)

Aggregations

LinkedList (java.util.LinkedList)1 DynamicFlowModelBuilder (org.apereo.cas.web.flow.DynamicFlowModelBuilder)1 FlowDefinitionRegistryBuilder (org.springframework.webflow.config.FlowDefinitionRegistryBuilder)1 FlowBuilder (org.springframework.webflow.engine.builder.FlowBuilder)1 FlowModelFlowBuilder (org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder)1 AbstractActionModel (org.springframework.webflow.engine.model.AbstractActionModel)1 AbstractStateModel (org.springframework.webflow.engine.model.AbstractStateModel)1 ActionStateModel (org.springframework.webflow.engine.model.ActionStateModel)1 BinderModel (org.springframework.webflow.engine.model.BinderModel)1 BindingModel (org.springframework.webflow.engine.model.BindingModel)1 EndStateModel (org.springframework.webflow.engine.model.EndStateModel)1 EvaluateModel (org.springframework.webflow.engine.model.EvaluateModel)1 TransitionModel (org.springframework.webflow.engine.model.TransitionModel)1 VarModel (org.springframework.webflow.engine.model.VarModel)1 ViewStateModel (org.springframework.webflow.engine.model.ViewStateModel)1 DefaultFlowModelHolder (org.springframework.webflow.engine.model.builder.DefaultFlowModelHolder)1 FlowModelHolder (org.springframework.webflow.engine.model.registry.FlowModelHolder)1