@Audit(action = AuditableActions.OAUTH2_AUTHORIZATION_RESPONSE,
        actionResolverName = AuditActionResolvers.OAUTH2_AUTHORIZATION_RESPONSE_ACTION_RESOLVER,
        resourceResolverName = AuditResourceResolvers.OAUTH2_AUTHORIZATION_RESPONSE_RESOURCE_RESOLVER)
    @Override
    public ModelAndView build(final AccessTokenRequestContext tokenRequestContext) throws Throwable {
        val authentication = tokenRequestContext.getAuthentication();
        val factory = (OAuth20CodeFactory) configurationContext.getTicketFactory().get(OAuth20Code.class);
        val code = factory.create(tokenRequestContext.getService(), authentication,
            tokenRequestContext.getTicketGrantingTicket(), tokenRequestContext.getScopes(),
            tokenRequestContext.getCodeChallenge(), tokenRequestContext.getCodeChallengeMethod(),
            tokenRequestContext.getClientId(), tokenRequestContext.getClaims(),
            tokenRequestContext.getResponseType(), tokenRequestContext.getGrantType());
        LOGGER.debug("Generated OAuth code: [{}]", code);
        val addedCode = configurationContext.getTicketRegistry().addTicket(code);
        Objects.requireNonNull(addedCode, () -> "Could not add OAuth code %s to the registry.".formatted(code.getId()));
        
        val ticketGrantingTicket = tokenRequestContext.getTicketGrantingTicket();
        Optional.ofNullable(ticketGrantingTicket).ifPresent(tgt -> FunctionUtils.doAndHandle(ticket -> {
            configurationContext.getTicketRegistry().updateTicket(ticket);
        }, (CheckedFunction<Throwable, Ticket>) throwable -> {
            LOGGER.error("Unable to update ticket-granting-ticket [{}]", ticketGrantingTicket, throwable);
            return null;
        }).accept(tgt));
        return buildCallbackViewViaRedirectUri(tokenRequestContext, addedCode);
    }
This is {@link OAuth20AuthorizationCodeAuthorizationResponseBuilder}.

@author Misagh Moayyed
@since 5.2.0
support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/web/response/callback/OAuth20AuthorizationCodeAuthorizationResponseBuilder.java