Search in sources :

Example 46 with EventFactorySupport

use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.

the class RedirectToServiceAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
    final WebApplicationService service = WebUtils.getService(requestContext);
    final String serviceTicketId = WebUtils.getServiceTicketFromRequestScope(requestContext);
    final Response response = responseBuilderLocator.locate(service).build(service, serviceTicketId);
    WebUtils.putServiceResponseIntoRequestScope(requestContext, response);
    WebUtils.putServiceOriginalUrlIntoRequestScope(requestContext, service);
    return new EventFactorySupport().event(this, response.getResponseType().name().toLowerCase());
}
Also used : Response(org.apereo.cas.authentication.principal.Response) WebApplicationService(org.apereo.cas.authentication.principal.WebApplicationService) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Example 47 with EventFactorySupport

use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.

the class AzureAuthenticatorGenerateTokenAction method doExecute.

@Override
public Event doExecute(final RequestContext requestContext) {
    final Integer code = Integer.valueOf(RandomStringUtils.randomNumeric(8));
    final AzureAuthenticatorTokenCredential c = new AzureAuthenticatorTokenCredential();
    c.setToken(code.toString());
    WebUtils.putCredential(requestContext, c);
    requestContext.getFlowScope().put("azureToken", code);
    if (mode == AzureMultifactorProperties.AuthenticationModes.POUND) {
        return new EventFactorySupport().event(this, "authenticate");
    }
    return success();
}
Also used : AzureAuthenticatorTokenCredential(org.apereo.cas.adaptors.azure.AzureAuthenticatorTokenCredential) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Example 48 with EventFactorySupport

use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.

the class AuthyAuthenticationWebflowEventResolverTests method verifyOperation.

@Test
public void verifyOperation() {
    val authn = RegisteredServiceTestUtils.getAuthentication("casuser");
    val builder = mock(AuthenticationResultBuilder.class);
    when(builder.getInitialAuthentication()).thenReturn(Optional.of(authn));
    when(builder.collect(any(Authentication.class))).thenReturn(builder);
    WebUtils.putAuthenticationResultBuilder(builder, context);
    WebUtils.putAuthentication(authn, context);
    val event = resolver.resolveSingle(context);
    assertEquals(CasWebflowConstants.TRANSITION_ID_ERROR, event.getId());
    val support = new EventFactorySupport();
    assertTrue(event.getAttributes().contains(support.getExceptionAttributeName()));
}
Also used : lombok.val(lombok.val) Authentication(org.apereo.cas.authentication.Authentication) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 49 with EventFactorySupport

use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.

the class InitializeCaptchaAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) {
    activationStrategy.shouldActivate(requestContext, recaptchaProperties).ifPresent(properties -> {
        WebUtils.putRecaptchaPropertiesFlowScope(requestContext, properties);
        onActivationConsumer.accept(requestContext);
    });
    return new EventFactorySupport().success(this);
}
Also used : EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Example 50 with EventFactorySupport

use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.

the class QRAuthenticationValidateTokenAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) {
    val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext);
    val token = request.getParameter(TokenConstants.PARAMETER_NAME_TOKEN);
    val deviceId = request.getParameter("deviceId");
    LOGGER.debug("Received QR token [{}] with device identifier [{}]", token, deviceId);
    val credential = new QRAuthenticationTokenCredential(token, deviceId);
    WebUtils.putCredential(requestContext, credential);
    return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_FINALIZE);
}
Also used : lombok.val(lombok.val) QRAuthenticationTokenCredential(org.apereo.cas.qr.authentication.QRAuthenticationTokenCredential) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Aggregations

EventFactorySupport (org.springframework.webflow.action.EventFactorySupport)78 lombok.val (lombok.val)61 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)26 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)26 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)26 MockServletContext (org.springframework.mock.web.MockServletContext)25 MockRequestContext (org.springframework.webflow.test.MockRequestContext)23 Test (org.junit.jupiter.api.Test)21 Event (org.springframework.webflow.execution.Event)12 Test (org.junit.Test)7 LocalAttributeMap (org.springframework.webflow.core.collection.LocalAttributeMap)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 HashMap (java.util.HashMap)4 Authentication (org.apereo.cas.authentication.Authentication)4 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 WebUtils (org.apereo.cas.web.support.WebUtils)3 LiteralExpression (org.springframework.binding.expression.support.LiteralExpression)3 MessageContext (org.springframework.binding.message.MessageContext)3 Transition (org.springframework.webflow.engine.Transition)3