use of org.springframework.webflow.execution.Event in project cas by apereo.
the class AuthenticationViaFormActionTests method verifyRenewWithServiceAndSameCredentials.
@Test
public void verifyRenewWithServiceAndSameCredentials() throws Exception {
final Credential c = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
final Service service = RegisteredServiceTestUtils.getService(RegisteredServiceTestUtils.CONST_TEST_URL);
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), service, c);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
request.addParameter(CasProtocolConstants.PARAMETER_RENEW, "true");
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, RegisteredServiceTestUtils.getService(RegisteredServiceTestUtils.CONST_TEST_URL).getId());
putCredentialInRequestScope(context, CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword());
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
context.getFlowScope().put(CasProtocolConstants.PARAMETER_SERVICE, RegisteredServiceTestUtils.getService());
final Event ev = this.action.execute(context);
assertEquals(CasWebflowConstants.STATE_ID_SUCCESS, ev.getId());
}
use of org.springframework.webflow.execution.Event in project cas by apereo.
the class FrontChannelLogoutActionTests method verifyLogoutNoIndex.
@Test
public void verifyLogoutNoIndex() throws Exception {
WebUtils.putLogoutRequests(this.requestContext, Collections.emptyList());
final Event event = this.frontChannelLogoutAction.doExecute(this.requestContext);
assertEquals(FrontChannelLogoutAction.FINISH_EVENT, event.getId());
}
use of org.springframework.webflow.execution.Event in project cas by apereo.
the class FrontChannelLogoutAction method doInternalExecute.
@Override
protected Event doInternalExecute(final HttpServletRequest request, final HttpServletResponse response, final RequestContext context) throws Exception {
final List<LogoutRequest> logoutRequests = WebUtils.getLogoutRequests(context);
final Map<LogoutRequest, LogoutHttpMessage> logoutUrls = new HashMap<>();
if (logoutRequests != null) {
logoutRequests.stream().filter(r -> r.getStatus() == LogoutRequestStatus.NOT_ATTEMPTED).forEach(r -> {
LOGGER.debug("Using logout url [{}] for front-channel logout requests", r.getLogoutUrl().toExternalForm());
final String logoutMessage = this.logoutManager.createFrontChannelLogoutMessage(r);
LOGGER.debug("Front-channel logout message to send is [{}]", logoutMessage);
final LogoutHttpMessage msg = new LogoutHttpMessage(r.getLogoutUrl(), logoutMessage, true);
logoutUrls.put(r, msg);
r.setStatus(LogoutRequestStatus.SUCCESS);
r.getService().setLoggedOutAlready(true);
});
if (!logoutUrls.isEmpty()) {
context.getFlowScope().put("logoutUrls", logoutUrls);
return new EventFactorySupport().event(this, "propagate");
}
}
return new EventFactorySupport().event(this, FINISH_EVENT);
}
use of org.springframework.webflow.execution.Event in project cas by apereo.
the class ServiceAuthorizationCheckTests method authorizedServiceProvided.
@Test
public void authorizedServiceProvided() throws Exception {
final MockRequestContext mockRequestContext = new MockRequestContext();
mockRequestContext.getFlowScope().put("service", this.authorizedService);
final Event event = this.serviceAuthorizationCheck.doExecute(mockRequestContext);
assertEquals("success", event.getId());
}
use of org.springframework.webflow.execution.Event in project cas by apereo.
the class TicketGrantingTicketCheckActionTests method verifyNullTicket.
@Test
public void verifyNullTicket() throws Exception {
final MockRequestContext ctx = new MockRequestContext();
final TicketGrantingTicketCheckAction action = new TicketGrantingTicketCheckAction(this.getCentralAuthenticationService());
final Event event = action.doExecute(ctx);
assertEquals(event.getId(), TicketGrantingTicketCheckAction.NOT_EXISTS);
}
Aggregations