use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class CreateTicketGrantingTicketAction method doExecute.
@Override
public Event doExecute(final RequestContext context) throws Exception {
val service = WebUtils.getService(context);
val registeredService = WebUtils.getRegisteredService(context);
val authenticationResultBuilder = WebUtils.getAuthenticationResultBuilder(context);
LOGGER.trace("Finalizing authentication transactions and issuing ticket-granting ticket");
val authenticationResult = configurationContext.getAuthenticationSystemSupport().finalizeAllAuthenticationTransactions(authenticationResultBuilder, service);
LOGGER.trace("Finalizing authentication event...");
val authentication = buildFinalAuthentication(authenticationResult);
val ticketGrantingTicket = determineTicketGrantingTicketId(context);
LOGGER.debug("Creating ticket-granting ticket, potentially based on [{}]", ticketGrantingTicket);
val tgt = createOrUpdateTicketGrantingTicket(authenticationResult, authentication, ticketGrantingTicket);
if (registeredService != null && registeredService.getAccessStrategy() != null) {
WebUtils.putUnauthorizedRedirectUrlIntoFlowScope(context, registeredService.getAccessStrategy().getUnauthorizedRedirectUrl());
}
WebUtils.putTicketGrantingTicketInScopes(context, tgt);
WebUtils.putAuthenticationResult(authenticationResult, context);
WebUtils.putAuthentication(tgt.getAuthentication(), context);
LOGGER.trace("Calculating authentication warning messages...");
val warnings = calculateAuthenticationWarningMessages(tgt, context.getMessageContext());
if (!warnings.isEmpty()) {
val attributes = new LocalAttributeMap<Object>(CasWebflowConstants.ATTRIBUTE_ID_AUTHENTICATION_WARNINGS, warnings);
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_SUCCESS_WITH_WARNINGS, attributes);
}
return success();
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class FinishLogoutAction method doInternalExecute.
@Override
protected Event doInternalExecute(final HttpServletRequest request, final HttpServletResponse response, final RequestContext context) {
val logoutRedirect = WebUtils.getLogoutRedirectUrl(context, String.class);
if (StringUtils.isNotBlank(logoutRedirect)) {
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_REDIRECT);
}
val logoutPostUrl = WebUtils.getLogoutPostUrl(context);
val logoutPostData = WebUtils.getLogoutPostData(context);
if (StringUtils.isNotBlank(logoutPostUrl) && logoutPostData != null) {
val flowScope = context.getFlowScope();
flowScope.put("originalUrl", logoutPostUrl);
flowScope.put("parameters", logoutPostData);
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_POST);
}
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_FINISH);
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class FrontChannelLogoutAction method doInternalExecute.
@Override
protected Event doInternalExecute(final HttpServletRequest request, final HttpServletResponse response, final RequestContext context) {
val logoutRequests = WebUtils.getLogoutRequests(context);
if (logoutRequests == null || logoutRequests.isEmpty()) {
return getFinishLogoutEvent();
}
if (casProperties.getSlo().isDisabled()) {
LOGGER.debug("Single logout callbacks are disabled");
return getFinishLogoutEvent();
}
val logoutUrls = new HashMap<SingleLogoutRequestContext, LogoutHttpMessage>();
logoutRequests.stream().filter(r -> r.getStatus() == LogoutRequestStatus.NOT_ATTEMPTED).forEach(r -> {
LOGGER.debug("Using logout url [{}] for front-channel logout requests", r.getLogoutUrl().toExternalForm());
logoutExecutionPlan.getSingleLogoutServiceMessageHandlers().stream().sorted(Comparator.comparing(SingleLogoutServiceMessageHandler::getOrder)).filter(handler -> handler.supports(r.getExecutionRequest(), r.getService())).forEach(handler -> {
val logoutMessage = handler.createSingleLogoutMessage(r);
LOGGER.debug("Front-channel logout message to send to [{}] is [{}]", r.getLogoutUrl(), logoutMessage);
val msg = new LogoutHttpMessage(r.getLogoutUrl(), logoutMessage.getPayload(), true);
logoutUrls.put(r, msg);
r.setStatus(LogoutRequestStatus.SUCCESS);
r.getService().setLoggedOutAlready(true);
});
});
if (!logoutUrls.isEmpty()) {
WebUtils.putLogoutUrls(context, logoutUrls);
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_PROPAGATE);
}
return getFinishLogoutEvent();
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class ConfirmConsentAction method doExecute.
@Override
public Event doExecute(final RequestContext requestContext) throws Exception {
val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext);
val webService = WebUtils.getService(requestContext);
val service = this.authenticationRequestServiceSelectionStrategies.resolveService(webService);
val registeredService = getRegisteredServiceForConsent(requestContext, service);
val authentication = WebUtils.getAuthentication(requestContext);
val optionValue = Integer.parseInt(request.getParameter("option"));
val option = ConsentReminderOptions.valueOf(optionValue);
val reminder = Long.parseLong(request.getParameter("reminder"));
val reminderTimeUnit = request.getParameter("reminderTimeUnit");
val unit = ChronoUnit.valueOf(reminderTimeUnit.toUpperCase());
LOGGER.debug("Storing consent decision for service [{}]", service);
consentEngine.storeConsentDecision(service, registeredService, authentication, reminder, unit, option);
return new EventFactorySupport().success(this);
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class OneTimeTokenAuthenticationWebflowActionTests method verifyAction.
@Test
public void verifyAction() {
val resolver = mock(CasWebflowEventResolver.class);
when(resolver.resolveSingle(any())).thenReturn(new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_SUCCESS));
val action = new OneTimeTokenAuthenticationWebflowAction(resolver);
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, action.doExecute(context).getId());
}
Aggregations