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) 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.action.EventFactorySupport in project cas by apereo.
the class AllSpnegoKnownClientSystemsFilterActionTests method ensureRemoteIpShouldBeChecked.
@Test
public void ensureRemoteIpShouldBeChecked() {
final BaseSpnegoKnownClientSystemsFilterAction action = new BaseSpnegoKnownClientSystemsFilterAction("^192\\.158\\..+", "", 0);
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr("192.158.5.781");
final ServletExternalContext extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
final Event ev = action.doExecute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class AllSpnegoKnownClientSystemsFilterActionTests method ensureRemoteIpShouldNotBeChecked.
@Test
public void ensureRemoteIpShouldNotBeChecked() {
final BaseSpnegoKnownClientSystemsFilterAction action = new BaseSpnegoKnownClientSystemsFilterAction("^192\\.158\\..+", "", 0);
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr("193.158.5.781");
final ServletExternalContext extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
final Event ev = action.doExecute(ctx);
assertNotEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class AllSpnegoKnownClientSystemsFilterActionTests method verifyIpMismatchWhenCheckingHostnameForSpnego.
@Test
public void verifyIpMismatchWhenCheckingHostnameForSpnego() {
final HostNameSpnegoKnownClientSystemsFilterAction action = new HostNameSpnegoKnownClientSystemsFilterAction("14\\..+", "", 0, "\\w+\\.\\w+\\.\\w+");
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr(ALTERNATE_REMOTE_IP);
final ServletExternalContext extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
final Event ev = action.doExecute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().no(this).getId());
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class LdapSpnegoKnownClientSystemsFilterActionTests method ensureLdapAttributeShouldDoSpnego.
@Test
public void ensureLdapAttributeShouldDoSpnego() throws Exception {
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr("localhost");
final ServletExternalContext extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
final Event ev = action.execute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
Aggregations