Search in sources :

Example 56 with EventFactorySupport

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

the class RedirectToServiceAction method finalizeResponseEvent.

/**
 * Finalize response event event.
 *
 * @param requestContext the request context
 * @param service        the service
 * @param response       the response
 * @return the event
 */
protected Event finalizeResponseEvent(final RequestContext requestContext, final WebApplicationService service, final Response response) {
    WebUtils.putServiceResponseIntoRequestScope(requestContext, response);
    WebUtils.putServiceOriginalUrlIntoRequestScope(requestContext, service);
    val eventId = getFinalResponseEventId(service, response, requestContext);
    return new EventFactorySupport().event(this, eventId);
}
Also used : lombok.val(lombok.val) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Example 57 with EventFactorySupport

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

the class GenericCasWebflowExceptionHandler method handle.

@Override
public Event handle(final Exception exception, final RequestContext requestContext) {
    val messageContext = requestContext.getMessageContext();
    LOGGER.trace("Unable to translate errors of the authentication exception [{}]. Returning [{}]", exception, CasWebflowExceptionHandler.UNKNOWN);
    val message = buildErrorMessageResolver(exception, requestContext);
    messageContext.addMessage(message);
    return new EventFactorySupport().event(this, CasWebflowExceptionHandler.UNKNOWN);
}
Also used : lombok.val(lombok.val) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Example 58 with EventFactorySupport

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

the class RenewAuthenticationRequestCheckAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) {
    val ssoRequest = SingleSignOnParticipationRequest.builder().requestContext(requestContext).build();
    val ssoParticipation = this.singleSignOnParticipationStrategy.supports(ssoRequest) && this.singleSignOnParticipationStrategy.isParticipating(ssoRequest);
    if (ssoParticipation) {
        return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_PROCEED);
    }
    return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_RENEW);
}
Also used : lombok.val(lombok.val) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Example 59 with EventFactorySupport

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

the class CheckWebAuthenticationRequestAction method doExecute.

@Override
protected Event doExecute(final RequestContext context) {
    val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
    LOGGER.trace("Checking request content type [{}] against [{}]", request.getContentType(), this.contentType);
    val requestContentType = request.getContentType();
    if (StringUtils.isNotBlank(requestContentType) && RegexUtils.find(this.contentType, requestContentType)) {
        LOGGER.debug("Authentication request via type [{}] is not web-based", this.contentType);
        return new EventFactorySupport().no(this);
    }
    LOGGER.debug("Authenticated request is identified as web-based via type [{}]", requestContentType);
    return new EventFactorySupport().yes(this);
}
Also used : lombok.val(lombok.val) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Example 60 with EventFactorySupport

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

the class DuoSecurityUniversalPromptValidateLoginAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
    val requestParameters = requestContext.getRequestParameters();
    if (requestParameters.contains(REQUEST_PARAMETER_CODE) && requestParameters.contains(REQUEST_PARAMETER_STATE)) {
        val duoState = requestParameters.get(REQUEST_PARAMETER_STATE, String.class);
        LOGGER.trace("Received Duo Security state [{}]", duoState);
        var ticket = (TransientSessionTicket) null;
        try {
            ticket = centralAuthenticationService.getTicket(duoState, TransientSessionTicket.class);
            val authentication = ticket.getProperty(Authentication.class.getSimpleName(), Authentication.class);
            populateContextWithCredential(requestContext, ticket, authentication);
            populateContextWithAuthentication(requestContext, ticket);
            populateContextWithService(requestContext, ticket);
            return super.doExecute(requestContext);
        } catch (final Exception e) {
            LoggingUtils.warn(LOGGER, e);
            return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_ERROR);
        } finally {
            if (ticket != null) {
                val flowScope = ticket.getProperty(MutableAttributeMap.class.getSimpleName(), Map.class);
                flowScope.forEach((key, value) -> requestContext.getFlowScope().put(key.toString(), value));
                val credential = ticket.getProperty(Credential.class.getSimpleName(), Credential.class);
                WebUtils.putCredential(requestContext, credential);
            }
            centralAuthenticationService.deleteTicket(duoState);
        }
    }
    return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_SKIP);
}
Also used : lombok.val(lombok.val) TransientSessionTicket(org.apereo.cas.ticket.TransientSessionTicket) DuoSecurityUniversalPromptCredential(org.apereo.cas.adaptors.duo.authn.DuoSecurityUniversalPromptCredential) Credential(org.apereo.cas.authentication.Credential) Authentication(org.apereo.cas.authentication.Authentication) MutableAttributeMap(org.springframework.webflow.core.collection.MutableAttributeMap) 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