Search in sources :

Example 1 with AbstractTicketValidationException

use of org.apereo.cas.ticket.AbstractTicketValidationException in project cas by apereo.

the class AbstractServiceValidateController method handleRequestInternal.

@Override
public ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    val service = serviceValidateConfigurationContext.getArgumentExtractor().extractService(request);
    val serviceTicketId = Optional.ofNullable(service).map(WebApplicationService::getArtifactId).orElse(null);
    if (service == null || StringUtils.isBlank(serviceTicketId)) {
        LOGGER.warn("Could not identify service and/or service ticket for service: [{}]", service);
        return generateErrorView(CasProtocolConstants.ERROR_CODE_INVALID_REQUEST, StringUtils.EMPTY, request, service);
    }
    try {
        prepareForTicketValidation(request, service, serviceTicketId);
        return handleTicketValidation(request, response, service, serviceTicketId);
    } catch (final AbstractTicketValidationException e) {
        val code = e.getCode();
        val description = getTicketValidationErrorDescription(code, new Object[] { serviceTicketId, e.getService().getId(), service.getId() }, request);
        return generateErrorView(code, description, request, service);
    } catch (final AbstractTicketException e) {
        val description = getTicketValidationErrorDescription(e.getCode(), new Object[] { serviceTicketId }, request);
        return generateErrorView(e.getCode(), description, request, service);
    } catch (final UnauthorizedProxyingException e) {
        val description = getTicketValidationErrorDescription(CasProtocolConstants.ERROR_CODE_UNAUTHORIZED_SERVICE_PROXY, new Object[] { service.getId() }, request);
        return generateErrorView(CasProtocolConstants.ERROR_CODE_UNAUTHORIZED_SERVICE_PROXY, description, request, service);
    } catch (final UnauthorizedServiceException | PrincipalException e) {
        return generateErrorView(CasProtocolConstants.ERROR_CODE_UNAUTHORIZED_SERVICE, null, request, service);
    } catch (final Exception e) {
        LoggingUtils.warn(LOGGER, e);
        return generateErrorView(CasProtocolConstants.ERROR_CODE_INVALID_REQUEST, StringUtils.EMPTY, request, service);
    }
}
Also used : lombok.val(lombok.val) AbstractTicketValidationException(org.apereo.cas.ticket.AbstractTicketValidationException) PrincipalException(org.apereo.cas.authentication.PrincipalException) UnauthorizedServiceException(org.apereo.cas.services.UnauthorizedServiceException) AbstractTicketException(org.apereo.cas.ticket.AbstractTicketException) UnauthorizedProxyingException(org.apereo.cas.services.UnauthorizedProxyingException) PrincipalException(org.apereo.cas.authentication.PrincipalException) AbstractTicketValidationException(org.apereo.cas.ticket.AbstractTicketValidationException) AuthenticationException(org.apereo.cas.authentication.AuthenticationException) UnauthorizedServiceException(org.apereo.cas.services.UnauthorizedServiceException) InvalidTicketException(org.apereo.cas.ticket.InvalidTicketException) UnsatisfiedAuthenticationContextTicketValidationException(org.apereo.cas.ticket.UnsatisfiedAuthenticationContextTicketValidationException) AbstractTicketException(org.apereo.cas.ticket.AbstractTicketException) UnauthorizedProxyingException(org.apereo.cas.services.UnauthorizedProxyingException) UnauthorizedServiceTicketValidationException(org.apereo.cas.validation.UnauthorizedServiceTicketValidationException)

Aggregations

lombok.val (lombok.val)1 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)1 PrincipalException (org.apereo.cas.authentication.PrincipalException)1 UnauthorizedProxyingException (org.apereo.cas.services.UnauthorizedProxyingException)1 UnauthorizedServiceException (org.apereo.cas.services.UnauthorizedServiceException)1 AbstractTicketException (org.apereo.cas.ticket.AbstractTicketException)1 AbstractTicketValidationException (org.apereo.cas.ticket.AbstractTicketValidationException)1 InvalidTicketException (org.apereo.cas.ticket.InvalidTicketException)1 UnsatisfiedAuthenticationContextTicketValidationException (org.apereo.cas.ticket.UnsatisfiedAuthenticationContextTicketValidationException)1 UnauthorizedServiceTicketValidationException (org.apereo.cas.validation.UnauthorizedServiceTicketValidationException)1