use of org.apereo.cas.interrupt.InterruptResponse in project cas by apereo.
the class FinalizeInterruptFlowAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
final RegisteredService registeredService = WebUtils.getRegisteredService(requestContext);
final InterruptResponse response = InterruptUtils.getInterruptFrom(requestContext);
if (response.isBlock()) {
if (registeredService != null && registeredService.getAccessStrategy().getUnauthorizedRedirectUrl() != null) {
final String url = registeredService.getAccessStrategy().getUnauthorizedRedirectUrl().toURL().toExternalForm();
requestContext.getExternalContext().requestExternalRedirect(url);
requestContext.getExternalContext().recordResponseComplete();
return no();
}
throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, "Denied");
}
return success();
}
use of org.apereo.cas.interrupt.InterruptResponse in project cas by apereo.
the class InquireInterruptAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
final Authentication authentication = WebUtils.getAuthentication(requestContext);
final Service service = WebUtils.getService(requestContext);
final RegisteredService registeredService = WebUtils.getRegisteredService(requestContext);
final InterruptResponse response = this.interruptInquirer.inquire(authentication, registeredService, service);
if (response == null || !response.isInterrupt()) {
return no();
}
InterruptUtils.putInterruptIn(requestContext, response);
WebUtils.putPrincipal(requestContext, authentication.getPrincipal());
return yes();
}
use of org.apereo.cas.interrupt.InterruptResponse in project cas by apereo.
the class InterruptSingleSignOnParticipationStrategyTests method verifyStrategyWithInterruptDisabled.
@Test
public void verifyStrategyWithInterruptDisabled() {
final InterruptSingleSignOnParticipationStrategy s = new InterruptSingleSignOnParticipationStrategy(mock(ServicesManager.class), true, true);
final MockRequestContext ctx = new MockRequestContext();
final InterruptResponse response = new InterruptResponse();
response.setSsoEnabled(false);
InterruptUtils.putInterruptIn(ctx, response);
assertFalse(s.isParticipating(ctx));
}
Aggregations