use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class VerifyPasswordlessAccountAuthenticationAction method doExecute.
@Override
public Event doExecute(final RequestContext requestContext) {
val username = requestContext.getRequestParameters().getRequired("username");
val account = passwordlessUserAccountStore.findUser(username);
if (account.isEmpty()) {
WebUtils.addErrorMessageToContext(requestContext, "passwordless.error.unknown.user");
return error();
}
val user = account.get();
if (StringUtils.isBlank(user.getPhone()) && StringUtils.isBlank(user.getEmail())) {
WebUtils.addErrorMessageToContext(requestContext, "passwordless.error.invalid.user");
return error();
}
WebUtils.putPasswordlessAuthenticationAccount(requestContext, user);
if (user.isRequestPassword()) {
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_PROMPT);
}
return success();
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class SpnegoKnownClientSystemsFilterActionTests method ensureAltRemoteIpHeaderShouldBeChecked.
@Test
public void ensureAltRemoteIpHeaderShouldBeChecked() throws Exception {
val action = new BaseSpnegoKnownClientSystemsFilterAction(RegexUtils.createPattern("^74\\.125\\..+"), "alternateRemoteIp", 120);
val ctx = new MockRequestContext();
val req = new MockHttpServletRequest();
req.setRemoteAddr("555.555.555.555");
req.addHeader("alternateRemoteIp", ALTERNATE_REMOTE_IP);
val extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
val 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 SpnegoKnownClientSystemsFilterActionTests method ensureHostnameAndIpShouldDoSpnego.
@Test
public void ensureHostnameAndIpShouldDoSpnego() throws Exception {
val action = new HostNameSpnegoKnownClientSystemsFilterAction(RegexUtils.createPattern("74\\..+"), StringUtils.EMPTY, 0, "\\w+\\.\\w+\\.\\w+");
val ctx = new MockRequestContext();
val req = new MockHttpServletRequest();
req.setRemoteAddr(ALTERNATE_REMOTE_IP);
val extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
val 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 BaseLdapSpnegoKnownClientSystemsFilterActionTests method ensureLdapAttributeShouldDoSpnego.
@Test
public void ensureLdapAttributeShouldDoSpnego() throws Exception {
val ctx = new MockRequestContext();
val req = new MockHttpServletRequest();
req.setRemoteAddr("localhost");
val extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
val ev = ldapSpnegoClientAction.execute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class SpnegoKnownClientSystemsFilterActionTests method ensureRemoteIpShouldBeChecked.
@Test
public void ensureRemoteIpShouldBeChecked() throws Exception {
val action = new BaseSpnegoKnownClientSystemsFilterAction(RegexUtils.createPattern("^192\\.158\\..+"), StringUtils.EMPTY, 0);
val ctx = new MockRequestContext();
val req = new MockHttpServletRequest();
req.setRemoteAddr("192.158.5.781");
val extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
val ev = action.doExecute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
Aggregations