Search in sources :

Example 1 with ValidationResponseType

use of org.apereo.cas.validation.ValidationResponseType in project cas by apereo.

the class WebApplicationServiceFactory method determineWebApplicationFormat.

/**
     * Determine web application format boolean.
     *
     * @param request               the request
     * @param webApplicationService the web application service
     * @return the service itself.
     */
private AbstractWebApplicationService determineWebApplicationFormat(final HttpServletRequest request, final AbstractWebApplicationService webApplicationService) {
    final String format = request != null ? request.getParameter(CasProtocolConstants.PARAMETER_FORMAT) : null;
    try {
        if (StringUtils.isNotBlank(format)) {
            final ValidationResponseType formatType = ValidationResponseType.valueOf(format.toUpperCase());
            webApplicationService.setFormat(formatType);
        }
    } catch (final Exception e) {
        LOGGER.error("Format specified in the request [{}] is not recognized", format);
    }
    return webApplicationService;
}
Also used : ValidationResponseType(org.apereo.cas.validation.ValidationResponseType)

Example 2 with ValidationResponseType

use of org.apereo.cas.validation.ValidationResponseType in project cas by apereo.

the class AbstractServiceValidateController method getModelAndView.

private ModelAndView getModelAndView(final HttpServletRequest request, final boolean isSuccess, final WebApplicationService service) {
    ValidationResponseType type = service != null ? service.getFormat() : ValidationResponseType.XML;
    final String format = request.getParameter(CasProtocolConstants.PARAMETER_FORMAT);
    if (!StringUtils.isEmpty(format)) {
        try {
            type = ValidationResponseType.valueOf(format.toUpperCase());
        } catch (final Exception e) {
            LOGGER.warn(e.getMessage(), e);
        }
    }
    if (type == ValidationResponseType.JSON) {
        return new ModelAndView(this.jsonView);
    }
    return new ModelAndView(isSuccess ? this.successView : this.failureView);
}
Also used : ValidationResponseType(org.apereo.cas.validation.ValidationResponseType) ModelAndView(org.springframework.web.servlet.ModelAndView) 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)

Aggregations

ValidationResponseType (org.apereo.cas.validation.ValidationResponseType)2 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)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 ModelAndView (org.springframework.web.servlet.ModelAndView)1