@Override
    public String build(final String serviceTicketId, final WebApplicationService webApplicationService) throws Throwable {
        val assertion = FunctionUtils.doUnchecked(() -> ticketValidator.validate(serviceTicketId, webApplicationService.getId()));
        val attributes = new LinkedHashMap(assertion.getAttributes());
        attributes.putAll(assertion.getPrincipal().getAttributes());

        LOGGER.trace("Assertion attributes received are [{}]", attributes);
        val registeredService = servicesManager.findServiceBy(webApplicationService);
        RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(registeredService);

        val finalAttributes = ProtocolAttributeEncoder.decodeAttributes(attributes, registeredService, webApplicationService);
        LOGGER.debug("Final attributes decoded are [{}]", finalAttributes);

        val expirationPolicy = ticketFactory.get(ServiceTicket.class).getExpirationPolicyBuilder();
        val dateTime = ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(getTimeToLive(expirationPolicy, registeredService));
        val validUntilDate = DateTimeUtils.dateOf(dateTime);
        val builder = JwtBuilder.JwtRequest.builder();
        val request = builder
            .registeredService(Optional.of(registeredService))
            .serviceAudience(Set.of(webApplicationService.getId()))
            .issueDate(new Date())
            .jwtId(serviceTicketId)
            .subject(assertion.getPrincipal().getId())
            .validUntilDate(validUntilDate)
            .attributes(finalAttributes)
            .issuer(casProperties.getServer().getPrefix())
            .build();
        LOGGER.debug("Building JWT using [{}]", request);
        return jwtBuilder.build(request);
    }
This is {@link JwtTicketBuilder}.

@author Misagh Moayyed
@since 5.2.0
support/cas-server-support-token-core-api/src/main/java/org/apereo/cas/token/JwtTicketBuilder.java