protected String encodeAndFinalizeToken(final JwtClaims claims, final IdTokenGenerationContext context) throws Throwable {
        LOGGER.debug("Received claims for the ID token [{}] as [{}]", context.getAccessToken(), claims);
        val idTokenResult = getConfigurationContext().getIdTokenSigningAndEncryptionService().encode(context.getRegisteredService(), claims);
        context.getAccessToken().setIdToken(idTokenResult);
        if (context.getResponseType() != OAuth20ResponseTypes.ID_TOKEN && context.getAccessToken().getExpiresIn() > 0) {
            LOGGER.debug("Updating access token [{}] in ticket registry with ID token [{}]", context.getAccessToken().getId(), idTokenResult);
            getConfigurationContext().getTicketRegistry().updateTicket(context.getAccessToken());
        }
        return idTokenResult;
    }
This is {@link BaseIdTokenGeneratorService}.

@author Misagh Moayyed
@since 6.0.0
support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/ticket/idtoken/BaseIdTokenGeneratorService.java