Search in sources :

Example 66 with EventFactorySupport

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

the class AccepttoQRCodeValidateWebSocketChannelAction method returnError.

private Event returnError(final String message) {
    val eventAttributes = new LocalAttributeMap<>();
    LOGGER.error(message);
    eventAttributes.put("error", new AuthenticationException(new UnauthorizedAuthenticationException(message)));
    return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE, eventAttributes);
}
Also used : lombok.val(lombok.val) 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) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Example 67 with EventFactorySupport

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

the class AccepttoMultifactorFetchChannelAction method doExecute.

@Override
public Event doExecute(final RequestContext requestContext) throws Exception {
    val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext);
    val response = WebUtils.getHttpServletResponseFromExternalWebflowContext(requestContext);
    val webContext = new JEEContext(request, response);
    val channel = authenticateAndFetchChannel(requestContext);
    LOGGER.debug("Storing channel [{}] in session", channel);
    AccepttoWebflowUtils.storeChannelInSessionStore(channel, webContext, sessionStore);
    val authentication = WebUtils.getInProgressAuthentication();
    AccepttoWebflowUtils.storeAuthenticationInSessionStore(authentication, webContext, sessionStore);
    val accepttoRedirectUrl = buildAccepttoAuthenticationSelectionUrl(request, channel);
    LOGGER.debug("Redirecting to [{}]", accepttoRedirectUrl);
    requestContext.getRequestScope().put("accepttoRedirectUrl", accepttoRedirectUrl);
    return new EventFactorySupport().success(this);
}
Also used : lombok.val(lombok.val) JEEContext(org.pac4j.core.context.JEEContext) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Example 68 with EventFactorySupport

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

the class SurrogateEligibilitySelectionAuditResourceResolverTests method verifyOperation.

@Test
public void verifyOperation() {
    val resolver = new SurrogateEligibilitySelectionAuditResourceResolver();
    val jp = mock(JoinPoint.class);
    val result = new HashMap<>();
    result.put("key1", "value1");
    result.put("key2", "value2");
    val event = new EventFactorySupport().success(this, result);
    val outcome = resolver.resolveFrom(jp, event);
    assertTrue(outcome.length > 0);
}
Also used : lombok.val(lombok.val) HashMap(java.util.HashMap) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport) Test(org.junit.jupiter.api.Test)

Example 69 with EventFactorySupport

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

the class SurrogateEligibilitySelectionAuditResourceResolver method resolveFrom.

@Override
public String[] resolveFrom(final JoinPoint auditableTarget, final Object returnValue) {
    Objects.requireNonNull(returnValue, "Event must not be null");
    val resultEvent = Event.class.cast(returnValue);
    val resultAttributeName = new EventFactorySupport().getResultAttributeName();
    val values = new HashMap<String, Object>(resultEvent.getAttributes().get(resultAttributeName, Map.class));
    values.put("status", resultEvent.getId());
    return new String[] { auditFormat.serialize(values) };
}
Also used : lombok.val(lombok.val) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Example 70 with EventFactorySupport

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

the class YubiKeyAccountCheckRegistrationAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) {
    val authentication = WebUtils.getAuthentication(requestContext);
    val uid = resolvePrincipal(authentication.getPrincipal()).getId();
    if (registry.isYubiKeyRegisteredFor(uid)) {
        return success();
    }
    return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_REGISTER);
}
Also used : lombok.val(lombok.val) 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