use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class ValidatePasswordResetTokenAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
try {
val transientTicket = requestContext.getRequestParameters().get(PasswordManagementWebflowUtils.REQUEST_PARAMETER_NAME_PASSWORD_RESET_TOKEN);
if (StringUtils.isNotBlank(transientTicket)) {
val tst = centralAuthenticationService.getTicket(transientTicket, TransientSessionTicket.class);
val token = tst.getProperties().get(PasswordManagementWebflowUtils.FLOWSCOPE_PARAMETER_NAME_TOKEN).toString();
val username = passwordManagementService.parseToken(token);
if (StringUtils.isBlank(username)) {
throw new IllegalArgumentException("Password reset token could not be verified to determine username");
}
}
return null;
} catch (final Exception e) {
LoggingUtils.warn(LOGGER, e);
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_INVALID_PASSWORD_RESET_TOKEN);
}
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class LoadSurrogatesListAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
try {
if (WebUtils.hasSurrogateAuthenticationRequest(requestContext)) {
WebUtils.removeSurrogateAuthenticationRequest(requestContext);
LOGGER.trace("Attempting to load surrogates...");
if (loadSurrogates(requestContext)) {
return new Event(this, CasWebflowConstants.TRANSITION_ID_SURROGATE_VIEW);
}
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_SKIP_SURROGATE);
}
val currentCredential = WebUtils.getCredential(requestContext);
if (currentCredential instanceof SurrogateUsernamePasswordCredential) {
val authenticationResultBuilder = WebUtils.getAuthenticationResultBuilder(requestContext);
val credential = (SurrogateUsernamePasswordCredential) currentCredential;
val registeredService = WebUtils.getRegisteredService(requestContext);
val result = surrogatePrincipalBuilder.buildSurrogateAuthenticationResult(authenticationResultBuilder, currentCredential, credential.getSurrogateUsername(), registeredService);
result.ifPresent(builder -> WebUtils.putAuthenticationResultBuilder(builder, requestContext));
}
return success();
} catch (final Exception e) {
requestContext.getMessageContext().addMessage(new MessageBuilder().error().source("surrogate").code("screen.surrogates.account.selection.error").defaultText("Unable to accept or authorize selection").build());
LoggingUtils.error(LOGGER, e);
return error(e);
}
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class WebAuthnValidateSessionCredentialTokenAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext);
val token = request.getParameter("token");
if (StringUtils.isBlank(token)) {
LOGGER.warn("Missing web authn token from the request");
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE);
}
LOGGER.debug("Received web authn token [{}]", token);
val credential = new WebAuthnCredential(token);
WebUtils.putCredential(requestContext, credential);
val session = sessionManager.getSession(WebAuthnCredential.from(credential));
if (session.isEmpty()) {
LOGGER.warn("Unable to locate existing session from the current token [{}]", token);
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE);
}
val result = webAuthnCredentialRepository.getUsernameForUserHandle(session.get());
if (result.isEmpty()) {
LOGGER.warn("Unable to locate user based on the given user handle");
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE);
}
val username = result.get();
val authentication = DefaultAuthenticationBuilder.newInstance().addCredential(credential).setPrincipal(principalFactory.createPrincipal(username)).build();
LOGGER.warn("Finalized authentication attempt based on [{}]", authentication);
WebUtils.putAuthentication(authentication, requestContext);
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_FINALIZE);
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class WebAuthnAccountCheckRegistrationAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
val authentication = WebUtils.getAuthentication(requestContext);
val principal = resolvePrincipal(authentication.getPrincipal());
LOGGER.trace("Checking registration record for [{}]", principal.getId());
val registrations = webAuthnCredentialRepository.getRegistrationsByUsername(principal.getId());
if (!registrations.isEmpty()) {
return success();
}
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_REGISTER);
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class AllSpnegoKnownClientSystemsFilterActionTests method ensureAltRemoteIpHeaderShouldBeChecked.
@Test
public void ensureAltRemoteIpHeaderShouldBeChecked() {
final BaseSpnegoKnownClientSystemsFilterAction action = new BaseSpnegoKnownClientSystemsFilterAction("^74\\.125\\..+", "alternateRemoteIp", 120);
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr("555.555.555.555");
req.addHeader("alternateRemoteIp", 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());
}
Aggregations