protected ModelAndView buildAuthorizationForRequest(
        final OAuthRegisteredService registeredService,
        final JEEContext context, final Service service,
        final Authentication authentication) {

        val registeredBuilders = getConfigurationContext().getOauthAuthorizationResponseBuilders().getObject();

        val authzRequest = registeredBuilders
            .stream()
            .filter(BeanSupplier::isNotProxy)
            .sorted(OrderComparator.INSTANCE)
            .map(builder -> toAuthorizationRequest(registeredService, context, service, authentication, builder))
            .filter(Objects::nonNull)
            .filter(Optional::isPresent)
            .findFirst()
            .orElseThrow(() -> new IllegalArgumentException("Unable to build authorization request"))
            .orElseThrow()
            .build();

        val payload = Optional.ofNullable(authzRequest.getAccessTokenRequest())
            .orElseGet(Unchecked.supplier(() -> prepareAccessTokenRequestContext(authzRequest,
                registeredService, context, service, authentication)));

        val result = registeredBuilders
            .stream()
            .filter(BeanSupplier::isNotProxy)
            .sorted(OrderComparator.INSTANCE)
            .filter(builder -> builder.supports(authzRequest))
            .findFirst()
            .map(Unchecked.function(builder -> {
                if (authzRequest.isSingleSignOnSessionRequired() && payload.getTicketGrantingTicket() == null
                    && !OAuth20Utils.isStatelessAuthentication(payload.getUserProfile())) {
                    val message = String.format("Missing ticket-granting-ticket for client id [%s] and service [%s]",
                        authzRequest.getClientId(), registeredService.getName());
                    LOGGER.error(message);
                    return OAuth20Utils.produceErrorView(new PreventedException(message));
                }
                return builder.build(payload);
            }))
            .orElseGet(() -> OAuth20Utils.produceErrorView(new PreventedException("Could not build the callback response")));

        if (LoggingUtils.isProtocolMessageLoggerEnabled()) {
            val protocolContext = Map.<String, Object>of("Service", service.getId(), "Client ID", payload.getClientId(),
                "Response Mode", payload.getResponseMode(), "Response Type", payload.getResponseType(),
                "Redirect URI", payload.getRedirectUri());
            LoggingUtils.protocolMessage("OAuth/OpenID Connect Authorization Response",
                protocolContext,
                result.getModel().isEmpty() ? StringUtils.EMPTY : JsonUtils.render(result.getModel()));
            configurationContext.getApplicationContext().publishEvent(
                new OAuth20AuthorizationResponseEvent(this, ClientInfoHolder.getClientInfo(), protocolContext));
        }
        return result;
    }
Handle request post.

@param request  the request
@param response the response
@return the model and view
@throws Throwable the throwable
support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/web/endpoints/OAuth20AuthorizeEndpointController.java