public String build(final RegisteredService registeredService,
                        final JWTClaimsSet claimsSet) {

        RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(registeredService);

        val jwtJson = claimsSet.toString();
        LOGGER.debug("Generated JWT [{}]", jwtJson);

        LOGGER.trace("Locating service specific signing and encryption keys for service [{}]", registeredService.getName());
        if (registeredServiceCipherExecutor.supports(registeredService)) {
            LOGGER.trace("Encoding JWT based on keys provided by service [{}]", registeredService.getServiceId());
            return registeredServiceCipherExecutor.encode(jwtJson, Optional.of(registeredService));
        }

        if (defaultTokenCipherExecutor.isEnabled()) {
            LOGGER.trace("Encoding JWT based on default global keys for service [{}]", registeredService.getName());
            return defaultTokenCipherExecutor.encode(jwtJson);
        }
        val token = buildPlain(claimsSet, Optional.of(registeredService));
        LOGGER.trace("Generating plain JWT as the ticket: [{}]", token);
        return token;
    }
Build JWT.

@param registeredService the registered service
@param claimsSet         the claims set
@return the string
support/cas-server-support-token-core-api/src/main/java/org/apereo/cas/token/JwtBuilder.java