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);
}
}
Aggregations