use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class AllSpnegoKnownClientSystemsFilterActionTests method ensureHostnameAndIpShouldDoSpnego.
@Test
public void ensureHostnameAndIpShouldDoSpnego() {
final HostNameSpnegoKnownClientSystemsFilterAction action = new HostNameSpnegoKnownClientSystemsFilterAction("74\\..+", "", 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().yes(this).getId());
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class AllSpnegoKnownClientSystemsFilterActionTests method ensureHostnameShouldDoSpnego.
@Test
public void ensureHostnameShouldDoSpnego() {
final HostNameSpnegoKnownClientSystemsFilterAction action = new HostNameSpnegoKnownClientSystemsFilterAction("", "", 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().yes(this).getId());
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class PasswordChangeAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
try {
final UsernamePasswordCredential c = (UsernamePasswordCredential) WebUtils.getCredential(requestContext);
final PasswordChangeBean bean = requestContext.getFlowScope().get(PasswordManagementWebflowConfigurer.FLOW_VAR_ID_PASSWORD, PasswordChangeBean.class);
if (passwordManagementService.change(c, bean)) {
return new EventFactorySupport().event(this, PASSWORD_UPDATE_SUCCESS);
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
requestContext.getMessageContext().addMessage(new MessageBuilder().error().code("pm.updateFailure").defaultText("Could not update the account password").build());
return error();
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class VerifyPasswordResetRequestAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
final PasswordManagementProperties pm = casProperties.getAuthn().getPm();
final HttpServletRequest request = WebUtils.getHttpServletRequest(requestContext);
final String token = request.getParameter(PARAMETER_NAME_TOKEN);
if (StringUtils.isBlank(token)) {
LOGGER.error("Password reset token is missing");
return error();
}
final String username = passwordManagementService.parseToken(token);
if (StringUtils.isBlank(username)) {
LOGGER.error("Password reset token could not be verified");
return error();
}
if (pm.getReset().isSecurityQuestionsEnabled()) {
final Map<String, String> questions = passwordManagementService.getSecurityQuestions(username);
if (questions.isEmpty()) {
LOGGER.warn("No security questions could be found for [{}]", username);
return error();
}
requestContext.getFlowScope().put("questions", new HashSet<>(questions.keySet()));
} else {
LOGGER.debug("Security questions are not enabled");
}
requestContext.getFlowScope().put("token", token);
requestContext.getFlowScope().put("username", username);
requestContext.getFlowScope().put("questionsEnabled", pm.getReset().isSecurityQuestionsEnabled());
if (pm.getReset().isSecurityQuestionsEnabled()) {
return success();
}
return new EventFactorySupport().event(this, "questionsDisabled");
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class CheckWebAuthenticationRequestAction method doExecute.
@Override
protected Event doExecute(final RequestContext context) throws Exception {
final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
LOGGER.debug("Checking request content type [{}] against [{}]", request.getContentType(), this.contentType);
if (this.contentType.equalsIgnoreCase(request.getContentType())) {
LOGGER.debug("Authentication request via type [{}] is not web-based", this.contentType);
return new EventFactorySupport().no(this);
}
LOGGER.debug("Authenticated request is identified as web-based via type [{}]", request.getContentType());
return new EventFactorySupport().yes(this);
}
Aggregations