Search in sources :

Example 1 with InterruptResponse

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();
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) UnauthorizedServiceException(org.apereo.cas.services.UnauthorizedServiceException) InterruptResponse(org.apereo.cas.interrupt.InterruptResponse)

Example 2 with InterruptResponse

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();
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) Authentication(org.apereo.cas.authentication.Authentication) Service(org.apereo.cas.authentication.principal.Service) RegisteredService(org.apereo.cas.services.RegisteredService) InterruptResponse(org.apereo.cas.interrupt.InterruptResponse)

Example 3 with InterruptResponse

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));
}
Also used : ServicesManager(org.apereo.cas.services.ServicesManager) MockRequestContext(org.springframework.webflow.test.MockRequestContext) InterruptResponse(org.apereo.cas.interrupt.InterruptResponse) Test(org.junit.Test)

Aggregations

InterruptResponse (org.apereo.cas.interrupt.InterruptResponse)3 RegisteredService (org.apereo.cas.services.RegisteredService)2 Authentication (org.apereo.cas.authentication.Authentication)1 Service (org.apereo.cas.authentication.principal.Service)1 ServicesManager (org.apereo.cas.services.ServicesManager)1 UnauthorizedServiceException (org.apereo.cas.services.UnauthorizedServiceException)1 Test (org.junit.Test)1 MockRequestContext (org.springframework.webflow.test.MockRequestContext)1