use of org.springframework.webflow.execution.RequestContext in project cas by apereo.
the class ServiceThemeResolverTests method verifyGetServiceThemeDoesNotExist.
@Test
public void verifyGetServiceThemeDoesNotExist() {
final RegexRegisteredService r = new RegexRegisteredService();
r.setTheme("myTheme");
r.setId(1000);
r.setName("Test Service");
r.setServiceId("myServiceId");
this.servicesManager.save(r);
final MockHttpServletRequest request = new MockHttpServletRequest();
final RequestContext ctx = mock(RequestContext.class);
final MutableAttributeMap scope = new LocalAttributeMap();
scope.put("service", RegisteredServiceTestUtils.getService(r.getServiceId()));
when(ctx.getFlowScope()).thenReturn(scope);
RequestContextHolder.setRequestContext(ctx);
request.addHeader(WebUtils.USER_AGENT_HEADER, MOZILLA);
assertEquals(DEFAULT_THEME_NAME, this.serviceThemeResolver.resolveThemeName(request));
}
use of org.springframework.webflow.execution.RequestContext in project cas by apereo.
the class CasWebflowContextConfigurationTests method verifyFlowExecutorByClient.
@Test
public void verifyFlowExecutorByClient() {
final RequestContext ctx = getMockRequestContext();
final LocalAttributeMap map = new LocalAttributeMap<>();
flowExecutorViaClientFlowExecution.launchExecution("login", map, ctx.getExternalContext());
}
use of org.springframework.webflow.execution.RequestContext in project cas by apereo.
the class Pac4jWebflowConfigurer method createStopWebflowViewState.
private void createStopWebflowViewState(final Flow flow) {
final ViewState state = createViewState(flow, DelegatedClientAuthenticationAction.STOP_WEBFLOW, DelegatedClientAuthenticationAction.VIEW_ID_STOP_WEBFLOW);
state.getEntryActionList().add(new AbstractAction() {
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
final HttpServletRequest request = WebUtils.getHttpServletRequest(requestContext);
final HttpServletResponse response = WebUtils.getHttpServletResponse(requestContext);
final Optional<ModelAndView> mv = DelegatedClientAuthenticationAction.hasDelegationRequestFailed(request, response.getStatus());
mv.ifPresent(modelAndView -> modelAndView.getModel().forEach((k, v) -> requestContext.getFlowScope().put(k, v)));
return null;
}
});
}
use of org.springframework.webflow.execution.RequestContext in project cas by apereo.
the class AzureAuthenticatorAuthenticationHandler method doAuthentication.
@Override
protected HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException {
try {
final AzureAuthenticatorTokenCredential c = (AzureAuthenticatorTokenCredential) credential;
final RequestContext context = RequestContextHolder.getRequestContext();
final Principal principal = WebUtils.getAuthentication(context).getPrincipal();
LOGGER.debug("Received principal id [{}]", principal.getId());
final PFAuthParams params = authenticationRequestBuilder.build(principal, c);
final PFAuthResult r = azureAuthenticatorInstance.authenticate(params);
if (r.getAuthenticated()) {
return createHandlerResult(c, principalFactory.createPrincipal(principal.getId()), null);
}
LOGGER.error("Authentication failed. Call status: [{}]-[{}]. Error: [{}]", r.getCallStatus(), r.getCallStatusString(), r.getMessageError());
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
throw new FailedLoginException("Failed to authenticate user");
}
use of org.springframework.webflow.execution.RequestContext in project cas by apereo.
the class VerifySecurityQuestionsAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
final HttpServletRequest request = WebUtils.getHttpServletRequest(requestContext);
final String username = requestContext.getFlowScope().getString("username");
final PasswordManagementProperties pm = casProperties.getAuthn().getPm();
if (!pm.getReset().isSecurityQuestionsEnabled()) {
LOGGER.debug("Security questions are not enabled");
return success();
}
final Map<String, String> questions = passwordManagementService.getSecurityQuestions(username);
final AtomicInteger i = new AtomicInteger(0);
final long c = questions.values().stream().filter(v -> {
final String answer = request.getParameter("q" + i.getAndIncrement());
return answer.equals(v);
}).count();
if (c == questions.size()) {
return success();
}
return error();
}
Aggregations