Search in sources :

Example 1 with BaseCasWebflowAction

use of org.apereo.cas.web.flow.actions.BaseCasWebflowAction in project cas by apereo.

the class DelegatedAuthenticationWebflowConfigurer method createStopWebflowViewState.

/**
 * Create stop webflow view state.
 *
 * @param flow the flow
 */
protected void createStopWebflowViewState(final Flow flow) {
    createDecisionState(flow, DECISION_STATE_CHECK_DELEGATED_AUTHN_FAILURE, "flowScope.unauthorizedRedirectUrl != null", CasWebflowConstants.STATE_ID_SERVICE_UNAUTHZ_CHECK, CasWebflowConstants.STATE_ID_STOP_WEBFLOW);
    val stopWebflowState = createViewState(flow, CasWebflowConstants.STATE_ID_STOP_WEBFLOW, CasWebflowConstants.VIEW_ID_PAC4J_STOP_WEBFLOW);
    stopWebflowState.getEntryActionList().add(new BaseCasWebflowAction() {

        @Override
        protected Event doExecute(final RequestContext requestContext) {
            val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext);
            val response = WebUtils.getHttpServletResponseFromExternalWebflowContext(requestContext);
            val mv = DelegatedClientAuthenticationAction.hasDelegationRequestFailed(request, response.getStatus());
            mv.ifPresent(modelAndView -> modelAndView.getModel().forEach((k, v) -> requestContext.getFlowScope().put(k, v)));
            return null;
        }
    });
    createTransitionForState(stopWebflowState, CasWebflowConstants.TRANSITION_ID_RETRY, CasWebflowConstants.STATE_ID_DELEGATED_AUTHENTICATION_CLIENT_RETRY);
    val retryState = createEndState(flow, CasWebflowConstants.STATE_ID_DELEGATED_AUTHENTICATION_CLIENT_RETRY);
    retryState.setFinalResponseAction(createEvaluateAction(CasWebflowConstants.ACTION_ID_DELEGATED_AUTHENTICATION_CLIENT_RETRY));
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) ActionState(org.springframework.webflow.engine.ActionState) FlowDefinitionRegistry(org.springframework.webflow.definition.registry.FlowDefinitionRegistry) lombok.val(lombok.val) Flow(org.springframework.webflow.engine.Flow) HashMap(java.util.HashMap) History(org.springframework.webflow.engine.History) FlowBuilderServices(org.springframework.webflow.engine.builder.support.FlowBuilderServices) RequestContext(org.springframework.webflow.execution.RequestContext) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AbstractCasWebflowConfigurer(org.apereo.cas.web.flow.configurer.AbstractCasWebflowConfigurer) WebUtils(org.apereo.cas.web.support.WebUtils) BaseCasWebflowAction(org.apereo.cas.web.flow.actions.BaseCasWebflowAction) Event(org.springframework.webflow.execution.Event) Event(org.springframework.webflow.execution.Event) BaseCasWebflowAction(org.apereo.cas.web.flow.actions.BaseCasWebflowAction) RequestContext(org.springframework.webflow.execution.RequestContext)

Aggregations

HashMap (java.util.HashMap)1 lombok.val (lombok.val)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 BaseCasWebflowAction (org.apereo.cas.web.flow.actions.BaseCasWebflowAction)1 AbstractCasWebflowConfigurer (org.apereo.cas.web.flow.configurer.AbstractCasWebflowConfigurer)1 WebUtils (org.apereo.cas.web.support.WebUtils)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 FlowDefinitionRegistry (org.springframework.webflow.definition.registry.FlowDefinitionRegistry)1 ActionState (org.springframework.webflow.engine.ActionState)1 Flow (org.springframework.webflow.engine.Flow)1 History (org.springframework.webflow.engine.History)1 FlowBuilderServices (org.springframework.webflow.engine.builder.support.FlowBuilderServices)1 Event (org.springframework.webflow.execution.Event)1 RequestContext (org.springframework.webflow.execution.RequestContext)1