Search in sources :

Example 1 with LocalAttributeMap

use of org.springframework.webflow.core.collection.LocalAttributeMap in project cas by apereo.

the class AbstractCasWebflowEventResolver method validateEventIdForMatchingTransitionInContext.

/**
     * Validate event for transition.
     *
     * @param eventId    the event id
     * @param context    the context
     * @param attributes the attributes
     * @return the event
     */
protected Event validateEventIdForMatchingTransitionInContext(final String eventId, final RequestContext context, final Map<String, Object> attributes) {
    try {
        final AttributeMap<Object> attributesMap = new LocalAttributeMap<>(attributes);
        final Event event = new Event(this, eventId, attributesMap);
        LOGGER.debug("Resulting event id is [{}]. Locating transitions in the context for that event id...", event.getId());
        final TransitionDefinition def = context.getMatchingTransition(event.getId());
        if (def == null) {
            LOGGER.warn("Transition definition cannot be found for event [{}]", event.getId());
            throw new AuthenticationException();
        }
        LOGGER.debug("Found matching transition [{}] with target [{}] for event [{}] with attributes [{}].", def.getId(), def.getTargetStateId(), event.getId(), event.getAttributes());
        return event;
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : LocalAttributeMap(org.springframework.webflow.core.collection.LocalAttributeMap) AuthenticationException(org.apereo.cas.authentication.AuthenticationException) Event(org.springframework.webflow.execution.Event) TransitionDefinition(org.springframework.webflow.definition.TransitionDefinition) AuthenticationException(org.apereo.cas.authentication.AuthenticationException)

Example 2 with LocalAttributeMap

use of org.springframework.webflow.core.collection.LocalAttributeMap in project cas by apereo.

the class FrontChannelLogoutActionTests method onSetUp.

@Before
public void onSetUp() throws Exception {
    final DefaultSingleLogoutServiceMessageHandler handler = new DefaultSingleLogoutServiceMessageHandler(new SimpleHttpClientFactoryBean().getObject(), new SamlCompliantLogoutMessageCreator(), servicesManager, new DefaultSingleLogoutServiceLogoutUrlBuilder(), false, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
    final LogoutManagerImpl logoutManager = new LogoutManagerImpl(new SamlCompliantLogoutMessageCreator(), handler, false);
    this.frontChannelLogoutAction = new FrontChannelLogoutAction(logoutManager);
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final MockHttpServletResponse response = new MockHttpServletResponse();
    this.requestContext = mock(RequestContext.class);
    final ServletExternalContext servletExternalContext = mock(ServletExternalContext.class);
    when(this.requestContext.getExternalContext()).thenReturn(servletExternalContext);
    when(servletExternalContext.getNativeRequest()).thenReturn(request);
    when(servletExternalContext.getNativeResponse()).thenReturn(response);
    final LocalAttributeMap flowScope = new LocalAttributeMap();
    when(this.requestContext.getFlowScope()).thenReturn(flowScope);
    final MockFlowExecutionKey mockFlowExecutionKey = new MockFlowExecutionKey(FLOW_EXECUTION_KEY);
    final MockFlowExecutionContext mockFlowExecutionContext = new MockFlowExecutionContext();
    mockFlowExecutionContext.setKey(mockFlowExecutionKey);
    when(this.requestContext.getFlowExecutionContext()).thenReturn(mockFlowExecutionContext);
}
Also used : DefaultAuthenticationServiceSelectionStrategy(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy) LocalAttributeMap(org.springframework.webflow.core.collection.LocalAttributeMap) MockFlowExecutionKey(org.springframework.webflow.test.MockFlowExecutionKey) DefaultSingleLogoutServiceMessageHandler(org.apereo.cas.logout.DefaultSingleLogoutServiceMessageHandler) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DefaultSingleLogoutServiceLogoutUrlBuilder(org.apereo.cas.logout.DefaultSingleLogoutServiceLogoutUrlBuilder) DefaultAuthenticationServiceSelectionPlan(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan) SimpleHttpClientFactoryBean(org.apereo.cas.util.http.SimpleHttpClientFactoryBean) MockFlowExecutionContext(org.springframework.webflow.test.MockFlowExecutionContext) SamlCompliantLogoutMessageCreator(org.apereo.cas.logout.SamlCompliantLogoutMessageCreator) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) RequestContext(org.springframework.webflow.execution.RequestContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) LogoutManagerImpl(org.apereo.cas.logout.LogoutManagerImpl) Before(org.junit.Before)

Example 3 with LocalAttributeMap

use of org.springframework.webflow.core.collection.LocalAttributeMap in project head by mifos.

the class CreateSavingsAccountTest method testStartFlow_CustomerIdProvided.

@Test
public void testStartFlow_CustomerIdProvided() {
    Integer customerId = 1;
    MutableAttributeMap input = new LocalAttributeMap();
    MockParameterMap requestParameterMap = new MockParameterMap();
    requestParameterMap.put("customerId", customerId.toString());
    MockExternalContext context = new MockExternalContext();
    context.setRequestParameterMap(requestParameterMap);
    startFlow(input, context);
    assertCurrentStateEquals("selectProductOfferingStep");
    verify(controller).customerSelected(eq(customerId), any(CreateSavingsAccountFormBean.class));
    verify(controller).getProductOfferings(any(CreateSavingsAccountFormBean.class));
}
Also used : LocalAttributeMap(org.springframework.webflow.core.collection.LocalAttributeMap) MockExternalContext(org.springframework.webflow.test.MockExternalContext) MutableAttributeMap(org.springframework.webflow.core.collection.MutableAttributeMap) MockParameterMap(org.springframework.webflow.test.MockParameterMap) CreateSavingsAccountFormBean(org.mifos.ui.core.controller.CreateSavingsAccountFormBean) Test(org.junit.Test)

Example 4 with LocalAttributeMap

use of org.springframework.webflow.core.collection.LocalAttributeMap in project cas by apereo.

the class CasWebflowContextConfigurationTests method verifyFlowExecutorByServerSession.

@Test
public void verifyFlowExecutorByServerSession() {
    final RequestContext ctx = getMockRequestContext();
    final LocalAttributeMap map = new LocalAttributeMap<>();
    flowExecutorViaServerSessionBindingExecution.launchExecution("login", map, ctx.getExternalContext());
}
Also used : LocalAttributeMap(org.springframework.webflow.core.collection.LocalAttributeMap) MockRequestContext(org.springframework.webflow.test.MockRequestContext) RequestContext(org.springframework.webflow.execution.RequestContext) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with LocalAttributeMap

use of org.springframework.webflow.core.collection.LocalAttributeMap in project cas by apereo.

the class ServiceThemeResolverTests method verifyGetServiceThemeDoesNotExist.

@Test
public void verifyGetServiceThemeDoesNotExist() {
    final RegexRegisteredService r = new RegexRegisteredService();
    r.setTheme("myTheme");
    r.setId(1000);
    r.setName("Test Service");
    r.setServiceId("myServiceId");
    this.servicesManager.save(r);
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final RequestContext ctx = mock(RequestContext.class);
    final MutableAttributeMap scope = new LocalAttributeMap();
    scope.put("service", RegisteredServiceTestUtils.getService(r.getServiceId()));
    when(ctx.getFlowScope()).thenReturn(scope);
    RequestContextHolder.setRequestContext(ctx);
    request.addHeader(WebUtils.USER_AGENT_HEADER, MOZILLA);
    assertEquals(DEFAULT_THEME_NAME, this.serviceThemeResolver.resolveThemeName(request));
}
Also used : LocalAttributeMap(org.springframework.webflow.core.collection.LocalAttributeMap) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MutableAttributeMap(org.springframework.webflow.core.collection.MutableAttributeMap) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) RequestContext(org.springframework.webflow.execution.RequestContext) Test(org.junit.Test)

Aggregations

LocalAttributeMap (org.springframework.webflow.core.collection.LocalAttributeMap)9 Test (org.junit.Test)5 RequestContext (org.springframework.webflow.execution.RequestContext)5 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)3 MutableAttributeMap (org.springframework.webflow.core.collection.MutableAttributeMap)3 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)2 Before (org.junit.Before)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)2 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)2 Event (org.springframework.webflow.execution.Event)2 MockExternalContext (org.springframework.webflow.test.MockExternalContext)2 MockRequestContext (org.springframework.webflow.test.MockRequestContext)2 DefaultAuthenticationServiceSelectionPlan (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan)1 DefaultAuthenticationServiceSelectionStrategy (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy)1 UnauthorizedAuthenticationException (org.apereo.cas.authentication.adaptive.UnauthorizedAuthenticationException)1 GeoLocationRequest (org.apereo.cas.authentication.adaptive.geo.GeoLocationRequest)1 DefaultSingleLogoutServiceLogoutUrlBuilder (org.apereo.cas.logout.DefaultSingleLogoutServiceLogoutUrlBuilder)1 DefaultSingleLogoutServiceMessageHandler (org.apereo.cas.logout.DefaultSingleLogoutServiceMessageHandler)1 LogoutManagerImpl (org.apereo.cas.logout.LogoutManagerImpl)1