Search in sources :

Example 21 with Transition

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

the class AbstractCasWebflowConfigurer method createTransitionForState.

@Override
public Transition createTransitionForState(final TransitionableState state, final String criteriaOutcome, final String targetState, final boolean removeExisting, final Map<String, Object> attributes, final Action... actions) {
    try {
        if (removeExisting) {
            var transition = (Transition) null;
            do {
                transition = (Transition) state.getTransition(criteriaOutcome);
                if (transition != null) {
                    state.getTransitionSet().remove(transition);
                }
            } while (transition != null);
        }
        val transition = createTransition(criteriaOutcome, targetState, actions);
        attributes.forEach((key, value) -> transition.getAttributes().put(key, value));
        state.getTransitionSet().add(transition);
        LOGGER.trace("Added transition [{}] to the state [{}]", transition.getId(), state.getId());
        return transition;
    } catch (final Exception e) {
        LoggingUtils.error(LOGGER, e);
    }
    return null;
}
Also used : lombok.val(lombok.val) Transition(org.springframework.webflow.engine.Transition)

Example 22 with Transition

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

the class PasswordlessAuthenticationWebflowConfigurer method createStateAcceptPasswordless.

/**
 * Create state accept passwordless.
 *
 * @param flow the flow
 */
protected void createStateAcceptPasswordless(final Flow flow) {
    val acceptAction = createEvaluateAction(CasWebflowConstants.ACTION_ID_ACCEPT_PASSWORDLESS_AUTHN);
    val acceptState = createActionState(flow, CasWebflowConstants.STATE_ID_ACCEPT_PASSWORDLESS_AUTHENTICATION, acceptAction);
    createTransitionForState(acceptState, CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE, CasWebflowConstants.STATE_ID_PASSWORDLESS_DISPLAY);
    val submission = getState(flow, CasWebflowConstants.STATE_ID_REAL_SUBMIT, ActionState.class);
    val transition = (Transition) submission.getTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS);
    val targetStateId = transition.getTargetStateId();
    createTransitionForState(acceptState, CasWebflowConstants.TRANSITION_ID_SUCCESS, targetStateId);
}
Also used : lombok.val(lombok.val) Transition(org.springframework.webflow.engine.Transition)

Example 23 with Transition

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

the class OidcAuthenticationContextWebflowEventResolverTests method initialize.

@BeforeEach
@Override
public void initialize() throws Exception {
    super.initialize();
    this.context = new MockRequestContext();
    val request = new MockHttpServletRequest();
    request.setRemoteAddr("385.86.151.11");
    request.setLocalAddr("295.88.151.11");
    request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "MSIE");
    request.addParameter(OAuth20Constants.ACR_VALUES, TestMultifactorAuthenticationProvider.ID);
    ClientInfoHolder.setClientInfo(new ClientInfo(request));
    val response = new MockHttpServletResponse();
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
    val targetResolver = new DefaultTargetStateResolver(TestMultifactorAuthenticationProvider.ID);
    val transition = new Transition(new DefaultTransitionCriteria(new LiteralExpression(TestMultifactorAuthenticationProvider.ID)), targetResolver);
    context.getRootFlow().getGlobalTransitionSet().add(transition);
    WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());
    TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
    WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication(), context);
}
Also used : lombok.val(lombok.val) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) DefaultTransitionCriteria(org.springframework.webflow.engine.support.DefaultTransitionCriteria) LiteralExpression(org.springframework.binding.expression.support.LiteralExpression) Transition(org.springframework.webflow.engine.Transition) DefaultTargetStateResolver(org.springframework.webflow.engine.support.DefaultTargetStateResolver) MockRequestContext(org.springframework.webflow.test.MockRequestContext) ClientInfo(org.apereo.inspektr.common.web.ClientInfo) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) MockServletContext(org.springframework.mock.web.MockServletContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 24 with Transition

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

the class PasswordManagementWebflowConfigurer method configure.

private void configure(final Flow flow, final String id) {
    createFlowVariable(flow, FLOW_VAR_ID_PASSWORD, PasswordChangeBean.class);
    final BinderConfiguration binder = createStateBinderConfiguration(Arrays.asList(FLOW_VAR_ID_PASSWORD, "confirmedPassword"));
    final ViewState viewState = createViewState(flow, id, id, binder);
    createStateModelBinding(viewState, FLOW_VAR_ID_PASSWORD, PasswordChangeBean.class);
    viewState.getEntryActionList().add(this.passwordChangeAction);
    final Transition transition = createTransitionForState(viewState, CasWebflowConstants.TRANSITION_ID_SUBMIT, PASSWORD_CHANGE_ACTION);
    transition.getAttributes().put("bind", Boolean.TRUE);
    transition.getAttributes().put("validate", Boolean.TRUE);
    createStateDefaultTransition(viewState, id);
    final ActionState pswChangeAction = createActionState(flow, PASSWORD_CHANGE_ACTION, createEvaluateAction(PASSWORD_CHANGE_ACTION));
    pswChangeAction.getTransitionSet().add(createTransition(PasswordChangeAction.PASSWORD_UPDATE_SUCCESS, "casPasswordUpdateSuccess"));
    pswChangeAction.getTransitionSet().add(createTransition(CasWebflowConstants.TRANSITION_ID_ERROR, id));
}
Also used : Transition(org.springframework.webflow.engine.Transition) ViewState(org.springframework.webflow.engine.ViewState) ActionState(org.springframework.webflow.engine.ActionState) BinderConfiguration(org.springframework.webflow.engine.builder.BinderConfiguration)

Example 25 with Transition

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

the class AbstractCasWebflowConfigurer method createTransition.

@Override
public Transition createTransition(final Expression criteriaOutcomeExpression, final String targetState) {
    final TransitionCriteria criteria;
    if (criteriaOutcomeExpression.toString().equals(WildcardTransitionCriteria.WILDCARD_EVENT_ID)) {
        criteria = WildcardTransitionCriteria.INSTANCE;
    } else {
        criteria = new DefaultTransitionCriteria(criteriaOutcomeExpression);
    }
    final DefaultTargetStateResolver resolver = new DefaultTargetStateResolver(targetState);
    final Transition t = new Transition(criteria, resolver);
    return t;
}
Also used : DefaultTransitionCriteria(org.springframework.webflow.engine.support.DefaultTransitionCriteria) Transition(org.springframework.webflow.engine.Transition) DefaultTargetStateResolver(org.springframework.webflow.engine.support.DefaultTargetStateResolver) DefaultTransitionCriteria(org.springframework.webflow.engine.support.DefaultTransitionCriteria) WildcardTransitionCriteria(org.springframework.webflow.engine.WildcardTransitionCriteria) TransitionCriteria(org.springframework.webflow.engine.TransitionCriteria)

Aggregations

Transition (org.springframework.webflow.engine.Transition)38 lombok.val (lombok.val)29 DefaultTargetStateResolver (org.springframework.webflow.engine.support.DefaultTargetStateResolver)29 DefaultTransitionCriteria (org.springframework.webflow.engine.support.DefaultTransitionCriteria)24 LiteralExpression (org.springframework.binding.expression.support.LiteralExpression)23 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)22 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)22 MockServletContext (org.springframework.mock.web.MockServletContext)22 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)22 MockRequestContext (org.springframework.webflow.test.MockRequestContext)22 Test (org.junit.jupiter.api.Test)17 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)5 ClientInfo (org.apereo.inspektr.common.web.ClientInfo)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 Flow (org.springframework.webflow.engine.Flow)4 EventFactorySupport (org.springframework.webflow.action.EventFactorySupport)3 ActionState (org.springframework.webflow.engine.ActionState)3 Authentication (org.apereo.cas.authentication.Authentication)2 DefaultRegisteredServiceMultifactorPolicy (org.apereo.cas.services.DefaultRegisteredServiceMultifactorPolicy)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2