use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class SpnegoKnownClientSystemsFilterActionTests method ensureRemoteIpShouldNotBeChecked.
@Test
public void ensureRemoteIpShouldNotBeChecked() throws Exception {
val action = new BaseSpnegoKnownClientSystemsFilterAction(RegexUtils.createPattern("^192\\.158\\..+"), StringUtils.EMPTY, 0);
val ctx = new MockRequestContext();
val req = new MockHttpServletRequest();
req.setRemoteAddr("193.158.5.781");
val extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
val 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 AuthenticationExceptionHandlerAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
val currentEvent = requestContext.getCurrentEvent();
LOGGER.debug("Located current event [{}]", currentEvent);
val error = currentEvent.getAttributes().get(CasWebflowConstants.TRANSITION_ID_ERROR, Exception.class);
if (error != null) {
LOGGER.debug("Located error attribute [{}] with message [{}] from the current event", error.getClass(), error.getMessage());
val event = handle(error, requestContext);
LOGGER.debug("Final event id resolved from the error is [{}]", event);
return new EventFactorySupport().event(this, event, currentEvent.getAttributes());
}
return error();
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class AcceptableUsagePolicyVerifyAction method verify.
/**
* Verify whether the policy is accepted.
*
* @param context the context
* @return {@link CasWebflowConstants#TRANSITION_ID_AUP_ACCEPTED} if policy is
* accepted. {@link CasWebflowConstants#TRANSITION_ID_AUP_MUST_ACCEPT} otherwise.
*/
private Event verify(final RequestContext context) {
val authentication = WebUtils.getAuthentication(context);
val res = ObjectUtils.defaultIfNull(repository.verify(context), AcceptableUsagePolicyStatus.skipped(authentication.getPrincipal()));
WebUtils.putPrincipal(context, res.getPrincipal());
WebUtils.putAcceptableUsagePolicyStatusIntoFlowScope(context, res);
val eventFactorySupport = new EventFactorySupport();
val registeredService = WebUtils.getRegisteredService(context);
if (registeredService != null) {
val service = WebUtils.getService(context);
val audit = AuditableContext.builder().service(service).authentication(authentication).registeredService(registeredService).build();
val accessResult = registeredServiceAccessStrategyEnforcer.execute(audit);
accessResult.throwExceptionIfNeeded();
val aupEnabled = registeredService.getAcceptableUsagePolicy() != null && registeredService.getAcceptableUsagePolicy().isEnabled();
if (!aupEnabled) {
return eventFactorySupport.event(this, CasWebflowConstants.TRANSITION_ID_AUP_ACCEPTED);
}
}
switch(res.getStatus()) {
case TRUE:
return eventFactorySupport.event(this, CasWebflowConstants.TRANSITION_ID_AUP_ACCEPTED);
case FALSE:
return eventFactorySupport.event(this, CasWebflowConstants.TRANSITION_ID_AUP_MUST_ACCEPT);
case UNDEFINED:
default:
return eventFactorySupport.event(this, CasWebflowConstants.TRANSITION_ID_SKIP);
}
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class AcceptableUsagePolicyVerifyServiceAction method verify.
/**
* Verify whether the policy is accepted.
*
* @param context the context
* @return success if policy is accepted. {@link CasWebflowConstants#TRANSITION_ID_AUP_MUST_ACCEPT} otherwise.
*/
private Event verify(final RequestContext context) {
val registeredService = WebUtils.getRegisteredService(context);
if (registeredService != null) {
val authentication = WebUtils.getAuthentication(context);
val service = WebUtils.getService(context);
val eventFactorySupport = new EventFactorySupport();
val audit = AuditableContext.builder().service(service).authentication(authentication).registeredService(registeredService).build();
val accessResult = registeredServiceAccessStrategyEnforcer.execute(audit);
accessResult.throwExceptionIfNeeded();
val aupEnabled = registeredService.getAcceptableUsagePolicy() != null && registeredService.getAcceptableUsagePolicy().isEnabled();
val res = ObjectUtils.defaultIfNull(aupEnabled ? repository.verify(context) : null, AcceptableUsagePolicyStatus.skipped(authentication.getPrincipal()));
if (res.isDenied()) {
return eventFactorySupport.event(this, CasWebflowConstants.TRANSITION_ID_AUP_MUST_ACCEPT);
}
}
return null;
}
use of org.springframework.webflow.action.EventFactorySupport in project cas by apereo.
the class SelectiveMultifactorAuthenticationProviderWebflowEventResolverTests method verifyOperation.
@Test
public void verifyOperation() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val service = RegisteredServiceTestUtils.getRegisteredService();
servicesManager.save(service);
WebUtils.putRegisteredService(context, service);
WebUtils.putAuthentication(RegisteredServiceTestUtils.getAuthentication(), context);
WebUtils.putServiceIntoFlowScope(context, RegisteredServiceTestUtils.getService());
val targetResolver = new DefaultTargetStateResolver(TestMultifactorAuthenticationProvider.ID);
val transition = new Transition(new DefaultTransitionCriteria(new LiteralExpression(TestMultifactorAuthenticationProvider.ID)), targetResolver);
context.getRootFlow().getGlobalTransitionSet().add(transition);
val provider = TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
val resolvedEvents = CollectionUtils.wrapHashSet(new EventFactorySupport().event(this, provider.getId()));
WebUtils.putResolvedEventsAsAttribute(context, resolvedEvents);
val result = selectiveAuthenticationProviderWebflowEventResolver.resolve(context);
assertNotNull(result);
assertNotNull(WebUtils.getResolvedMultifactorAuthenticationProviders(context));
assertEquals(provider.getId(), result.iterator().next().getId());
}
Aggregations