code: public String build(final JwtRequest payload) {
          val serviceAudience = payload.getServiceAudience();
          val claims = new JWTClaimsSet.Builder()
              .audience(serviceAudience)
              .issuer(casSeverPrefix)
              .jwtID(payload.getJwtId())
              .issueTime(payload.getIssueDate())
              .subject(payload.getSubject());
  
          payload.getAttributes().forEach(claims::claim);
          claims.expirationTime(payload.getValidUntilDate());
  
          val claimsSet = claims.build();
          val object = claimsSet.toJSONObject();
  
          val jwtJson = object.toJSONString();
          LOGGER.debug("Generated JWT [{}]", JsonValue.readJSON(jwtJson).toString(Stringify.FORMATTED));
  
          LOGGER.trace("Locating service [{}] in service registry", serviceAudience);
          val registeredService = this.servicesManager.findServiceBy(serviceAudience);
          RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(registeredService);
  
          LOGGER.trace("Locating service specific signing and encryption keys for [{}] in service registry", serviceAudience);
          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 [{}]", serviceAudience);
              return defaultTokenCipherExecutor.encode(jwtJson);
          }
          val header = new PlainHeader.Builder()
              .type(JOSEObjectType.JWT)
              .build();
          val token = new PlainJWT(header, claimsSet).serialize();
          LOGGER.trace("Generating plain JWT as the ticket: [{}]", token);
          return token;
      }
docs: Build JWT.
  
  @param payload the payload
  @return the jwt