Search in sources :

Example 6 with LocalAttributeMap

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

the class CasWebflowContextConfigurationTests method verifyFlowExecutorByClient.

@Test
public void verifyFlowExecutorByClient() {
    final RequestContext ctx = getMockRequestContext();
    final LocalAttributeMap map = new LocalAttributeMap<>();
    flowExecutorViaClientFlowExecution.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 7 with LocalAttributeMap

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

the class LogoutActionTests method onSetUp.

@Before
public void onSetUp() throws Exception {
    this.request = new MockHttpServletRequest();
    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(new MockHttpServletResponse());
    when(this.requestContext.getFlowScope()).thenReturn(new LocalAttributeMap());
    this.serviceManager = new DefaultServicesManager(new InMemoryServiceRegistry());
    this.serviceManager.load();
}
Also used : LocalAttributeMap(org.springframework.webflow.core.collection.LocalAttributeMap) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) RequestContext(org.springframework.webflow.execution.RequestContext) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) InMemoryServiceRegistry(org.apereo.cas.services.InMemoryServiceRegistry) Before(org.junit.Before)

Example 8 with LocalAttributeMap

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

the class AbstractAuthenticationAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
    final String agent = WebUtils.getHttpServletRequestUserAgent();
    final GeoLocationRequest geoLocation = WebUtils.getHttpServletRequestGeoLocation();
    if (!adaptiveAuthenticationPolicy.apply(agent, geoLocation)) {
        final String msg = "Adaptive authentication policy does not allow this request for " + agent + " and " + geoLocation;
        final Map<String, Class<? extends Exception>> map = Collections.singletonMap(UnauthorizedAuthenticationException.class.getSimpleName(), UnauthorizedAuthenticationException.class);
        final AuthenticationException error = new AuthenticationException(msg, map, Collections.emptyMap());
        return new Event(this, CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE, new LocalAttributeMap(CasWebflowConstants.TRANSITION_ID_ERROR, error));
    }
    final Event serviceTicketEvent = this.serviceTicketRequestWebflowEventResolver.resolveSingle(requestContext);
    if (serviceTicketEvent != null) {
        fireEventHooks(serviceTicketEvent, requestContext);
        return serviceTicketEvent;
    }
    final Event finalEvent = this.initialAuthenticationAttemptWebflowEventResolver.resolveSingle(requestContext);
    fireEventHooks(finalEvent, requestContext);
    return finalEvent;
}
Also used : LocalAttributeMap(org.springframework.webflow.core.collection.LocalAttributeMap) UnauthorizedAuthenticationException(org.apereo.cas.authentication.adaptive.UnauthorizedAuthenticationException) AuthenticationException(org.apereo.cas.authentication.AuthenticationException) UnauthorizedAuthenticationException(org.apereo.cas.authentication.adaptive.UnauthorizedAuthenticationException) Event(org.springframework.webflow.execution.Event) GeoLocationRequest(org.apereo.cas.authentication.adaptive.geo.GeoLocationRequest) AuthenticationException(org.apereo.cas.authentication.AuthenticationException) UnauthorizedAuthenticationException(org.apereo.cas.authentication.adaptive.UnauthorizedAuthenticationException)

Example 9 with LocalAttributeMap

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

the class CreateSavingsAccountTest method testStartFlow_CustomerIdNotProvided.

@Test
public void testStartFlow_CustomerIdNotProvided() {
    MutableAttributeMap input = new LocalAttributeMap();
    MockExternalContext context = new MockExternalContext();
    startFlow(input, context);
    assertCurrentStateEquals("customerSearchStep");
}
Also used : LocalAttributeMap(org.springframework.webflow.core.collection.LocalAttributeMap) MockExternalContext(org.springframework.webflow.test.MockExternalContext) MutableAttributeMap(org.springframework.webflow.core.collection.MutableAttributeMap) 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