code: @SneakyThrows
      protected String encryptToken(final String encryptionAlg,
                                    final String encryptionEncoding,
                                    final String keyIdHeaderValue,
                                    final Key publicKey,
                                    final String payload) {
          val jwe = new JsonWebEncryption();
          jwe.setAlgorithmHeaderValue(encryptionAlg);
          jwe.setEncryptionMethodHeaderParameter(encryptionEncoding);
          jwe.setKey(publicKey);
          jwe.setKeyIdHeaderValue(keyIdHeaderValue);
          jwe.setContentTypeHeaderValue("JWT");
          jwe.setPayload(payload);
          return jwe.getCompactSerialization();
      }
docs: Create json web encryption json web encryption.
  
  @param encryptionAlg      the encryption alg
  @param encryptionEncoding the encryption encoding
  @param keyIdHeaderValue   the key id header value
  @param publicKey          the public key
  @param payload            the payload
  @return the json web encryption