Index: 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/ClaimJwtException.java =================================================================== diff -u -rdd64f16fdf89f789b8c2179d421290dcabf15835 -rca3e06f3b65d2880d69fd5278773c5c71e1ca3e7 --- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/ClaimJwtException.java (.../ClaimJwtException.java) (revision dd64f16fdf89f789b8c2179d421290dcabf15835) +++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/ClaimJwtException.java (.../ClaimJwtException.java) (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7) @@ -16,35 +16,82 @@ package io.jsonwebtoken; /** - * ClaimJwtException is a subclass of the {@link JwtException} that is thrown after a validation of an JTW claim failed. + * ClaimJwtException is a subclass of the {@link JwtException} that is thrown after a validation of an JWT claim failed. * * @since 0.5 */ public abstract class ClaimJwtException extends JwtException { + /** + * Deprecated as this is an implementation detail accidentally exposed in the JJWT 0.5 public API. It is no + * longer referenced anywhere in JJWT's implementation and will be removed in a future release. + * + * @deprecated will be removed in a future release. + */ + @Deprecated public static final String INCORRECT_EXPECTED_CLAIM_MESSAGE_TEMPLATE = "Expected %s claim to be: %s, but was: %s."; + + /** + * Deprecated as this is an implementation detail accidentally exposed in the JJWT 0.5 public API. It is no + * longer referenced anywhere in JJWT's implementation and will be removed in a future release. + * + * @deprecated will be removed in a future release. + */ + @Deprecated public static final String MISSING_EXPECTED_CLAIM_MESSAGE_TEMPLATE = "Expected %s claim to be: %s, but was not present in the JWT claims."; + /** + * The header associated with the Claims that failed validation. + */ private final Header header; + /** + * The Claims that failed validation. + */ private final Claims claims; + /** + * Creates a new instance with the specified header, claims and exception message. + * + * @param header the header inspected + * @param claims the claims obtained + * @param message the exception message + */ protected ClaimJwtException(Header header, Claims claims, String message) { super(message); this.header = header; this.claims = claims; } + /** + * Creates a new instance with the specified header, claims and exception message as a result of encountering + * the specified {@code cause}. + * + * @param header the header inspected + * @param claims the claims obtained + * @param message the exception message + * @param cause the exception that caused this ClaimJwtException to be thrown. + */ protected ClaimJwtException(Header header, Claims claims, String message, Throwable cause) { super(message, cause); this.header = header; this.claims = claims; } + /** + * Returns the {@link Claims} that failed validation. + * + * @return the {@link Claims} that failed validation. + */ public Claims getClaims() { return claims; } + /** + * Returns the header associated with the {@link #getClaims() claims} that failed validation. + * + * @return the header associated with the {@link #getClaims() claims} that failed validation. + */ public Header getHeader() { return header; } Index: 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/Claims.java =================================================================== diff -u -r0761df64c22d4bca1649836fda23e4526282498b -rca3e06f3b65d2880d69fd5278773c5c71e1ca3e7 --- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/Claims.java (.../Claims.java) (revision 0761df64c22d4bca1649836fda23e4526282498b) +++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/Claims.java (.../Claims.java) (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7) @@ -17,94 +17,89 @@ import java.util.Date; import java.util.Map; +import java.util.Set; /** - * A JWT Claims set. + * A JWT Claims set. * - *
This is ultimately a JSON map and any values can be added to it, but JWT standard names are provided as - * type-safe getters and setters for convenience.
+ *This is an immutable JSON map with convenient type-safe getters for JWT standard claim names.
* - *Because this interface extends {@code Map<String, Object>}, if you would like to add your own properties, - * you simply use map methods, for example:
+ *Additionally, this interface also extends Map<String, Object>
, so you can use standard
+ * {@code Map} accessor/iterator methods as desired, for example:
- * claims.{@link Map#put(Object, Object) put}("someKey", "someValue"); - *+ *
* - *+ * claims.get("someKey");
However, because {@code Claims} instances are immutable, calling any of the map mutation methods + * (such as {@code Map.}{@link Map#put(Object, Object) put}, etc) will result in a runtime exception. The + * {@code Map} interface is implemented specifically for the convenience of working with existing Map-based utilities + * and APIs.
* - *It is easiest to create a {@code Claims} instance by calling one of the - * {@link Jwts#claims() JWTs.claims()} factory methods.
- * * @since 0.1 */ -public interface Claims extends Map"iss"
*/
- public static final String ISSUER = "iss";
+ /**
+ * JWT {@code Issuer} claims parameter name: "iss"
+ */
+ String ISSUER = "iss";
- /** JWT {@code Subject} claims parameter name: "sub"
*/
- public static final String SUBJECT = "sub";
+ /**
+ * JWT {@code Subject} claims parameter name: "sub"
+ */
+ String SUBJECT = "sub";
- /** JWT {@code Audience} claims parameter name: "aud"
*/
- public static final String AUDIENCE = "aud";
+ /**
+ * JWT {@code Audience} claims parameter name: "aud"
+ */
+ String AUDIENCE = "aud";
- /** JWT {@code Expiration} claims parameter name: "exp"
*/
- public static final String EXPIRATION = "exp";
+ /**
+ * JWT {@code Expiration} claims parameter name: "exp"
+ */
+ String EXPIRATION = "exp";
- /** JWT {@code Not Before} claims parameter name: "nbf"
*/
- public static final String NOT_BEFORE = "nbf";
+ /**
+ * JWT {@code Not Before} claims parameter name: "nbf"
+ */
+ String NOT_BEFORE = "nbf";
- /** JWT {@code Issued At} claims parameter name: "iat"
*/
- public static final String ISSUED_AT = "iat";
+ /**
+ * JWT {@code Issued At} claims parameter name: "iat"
+ */
+ String ISSUED_AT = "iat";
- /** JWT {@code JWT ID} claims parameter name: "jti"
*/
- public static final String ID = "jti";
+ /**
+ * JWT {@code JWT ID} claims parameter name: "jti"
+ */
+ String ID = "jti";
/**
- * Returns the JWT
+ * Returns the JWT
* iss
(issuer) value or {@code null} if not present.
*
* @return the JWT {@code iss} value or {@code null} if not present.
*/
String getIssuer();
/**
- * {@inheritDoc}
- */
- @Override //only for better/targeted JavaDoc
- Claims setIssuer(String iss);
-
- /**
- * Returns the JWT
+ * Returns the JWT
* sub
(subject) value or {@code null} if not present.
*
* @return the JWT {@code sub} value or {@code null} if not present.
*/
String getSubject();
/**
- * {@inheritDoc}
- */
- @Override //only for better/targeted JavaDoc
- Claims setSubject(String sub);
-
- /**
- * Returns the JWT
+ * Returns the JWT
* aud
(audience) value or {@code null} if not present.
*
* @return the JWT {@code aud} value or {@code null} if not present.
*/
- String getAudience();
+ Setexp
(expiration) timestamp or {@code null} if not present.
*
* A JWT obtained after this timestamp should not be used.
@@ -114,13 +109,7 @@ Date getExpiration(); /** - * {@inheritDoc} - */ - @Override //only for better/targeted JavaDoc - Claims setExpiration(Date exp); - - /** - * Returns the JWT + * Returns the JWT *nbf
(not before) timestamp or {@code null} if not present.
*
* A JWT obtained before this timestamp should not be used.
@@ -130,13 +119,7 @@ Date getNotBefore(); /** - * {@inheritDoc} - */ - @Override //only for better/targeted JavaDoc - Claims setNotBefore(Date nbf); - - /** - * Returns the JWT + * Returns the JWT *iat
(issued at) timestamp or {@code null} if not present.
*
* If present, this value is the timestamp when the JWT was created.
@@ -146,13 +129,7 @@ Date getIssuedAt(); /** - * {@inheritDoc} - */ - @Override //only for better/targeted JavaDoc - Claims setIssuedAt(Date iat); - - /** - * Returns the JWTs + * Returns the JWTs *jti
(JWT ID) value or {@code null} if not present.
*
* This value is a CaSe-SenSiTiVe unique identifier for the JWT. If available, this value is expected to be @@ -162,30 +139,28 @@ * * @return the JWT {@code jti} value or {@code null} if not present. */ + @Override + // just for JavaDoc specific to the JWT spec String getId(); /** - * {@inheritDoc} - */ - @Override //only for better/targeted JavaDoc - Claims setId(String jti); - - /** - * Returns the JWTs claim ({@code claimName}) value as a type {@code requiredType}, or {@code null} if not present. + * Returns the JWTs claim ({@code claimName}) value as a {@code requiredType} instance, or {@code null} if not + * present. * *
JJWT only converts simple String, Date, Long, Integer, Short and Byte types automatically. Anything more
- * complex is expected to be already converted to your desired type by the JSON
- * {@link io.jsonwebtoken.io.Deserializer Deserializer} implementation. You may specify a custom Deserializer for a
- * JwtParser with the desired conversion configuration via the {@link JwtParserBuilder#deserializeJsonWith} method.
- * See custom JSON processor for more
+ * complex is expected to be already converted to your desired type by the JSON parser. You may specify a custom
+ * JSON processor using the {@code JwtParserBuilder}'s
+ * {@link JwtParserBuilder#json(io.jsonwebtoken.io.Deserializer) json(Deserializer)} method. See the JJWT
+ * documentation on custom JSON processors for more
* information. If using Jackson, you can specify custom claim POJO types as described in
* custom claim types.
*
- * @param claimName name of claim
+ * @param claimName name of claim
* @param requiredType the type of the value expected to be returned
- * @param When finished, the {@code audience} collection's {@link AudienceCollection#and() and()} method may be used
+ * to continue configuration. For example: A JWT obtained after this timestamp should not be used. A JWT obtained after this timestamp should not be used. A JWT obtained before this timestamp should not be used. A JWT obtained before this timestamp should not be used. The value is the timestamp when the JWT was created. The value is the timestamp when the JWT was created. This value is a CaSe-SenSiTiVe unique identifier for the JWT. If specified, this value MUST be assigned in a
* manner that ensures that there is a negligible probability that the same value will be accidentally
* assigned to a different data object. The ID can be used to prevent the JWT from being replayed. This value is a CaSe-SenSiTiVe unique identifier for the JWT. If specified, this value MUST be assigned in a
+ * manner that ensures that there is a negligible probability that the same value will be accidentally
+ * assigned to a different data object. The ID can be used to prevent the JWT from being replayed. Because this interface extends {@link NestedCollection}, the {@link #and()} method may be used to continue
+ * parent configuration. For example: the type of ClaimsMutator to return for method chaining.
+ * @see #single(String)
+ * @since 0.12.0
+ */
+ interface AudienceCollection extends NestedCollection "zip" identifier {@code CompressionCodec} extends {@code Identifiable}; the value returned from
+ * {@link Identifiable#getId() getId()} will be used as the JWT
+ * JJWT's default {@link JwtParser} implementation supports both the
- * {@link CompressionCodecs#DEFLATE DEFLATE}
- * and {@link CompressionCodecs#GZIP GZIP} algorithms by default - you do not need to
+ * {@link Jwts.ZIP#DEF DEFLATE} and {@link Jwts.ZIP#GZIP GZIP} algorithms by default - you do not need to
* specify a {@code CompressionCodecResolver} in these cases. However, if you want to use a compression algorithm other than {@code DEF} or {@code GZIP}, you must implement
+ * However, if you want to use a compression algorithm other than {@code DEF} or {@code GZIP}, you can implement
* your own {@link CompressionCodecResolver} and specify that when
- * {@link io.jsonwebtoken.JwtBuilder#compressWith(CompressionCodec) building} and
- * {@link io.jsonwebtoken.JwtParser#setCompressionCodecResolver(CompressionCodecResolver) parsing} JWTs. Compatibility Warning This is not a standard JWA compression algorithm. Be sure to use this only when you are confident
* that all parties accessing the token support the gzip algorithm. If you're concerned about compatibility, the {@link #DEFLATE DEFLATE} code is JWA standards-compliant. If you're concerned about compatibility, the {@link Jwts.ZIP#DEF DEF} code is JWA standards-compliant. This is ultimately a JSON map and any values can be added to it, but JWT JOSE standard names are provided as
- * type-safe getters and setters for convenience. This is an immutable JSON map with convenient type-safe getters for JWT standard header parameter names. Because this interface extends {@code Map<String, Object>}, if you would like to add your own properties,
- * you simply use map methods, for example: Because this interface extends However, because {@code Header} instances are immutable, calling any of the map mutation methods
+ * (such as {@code Map.}{@link Map#put(Object, Object) put}, etc) will result in a runtime exception. It is easiest to create a {@code Header} instance by calling one of the
- * {@link Jwts#header() JWTs.header()} factory methods. Security The {@code Header} interface itself makes no implications of integrity protection via either digital signatures or
+ * encryption. Instead, {@link JwsHeader} and {@link JweHeader} represent this information for respective
+ * {@link Jws} and {@link Jwe} instances. In the normal case where nested signing or encryption operations are not employed (i.e. a compact
- * serialization JWT), the use of this header parameter is NOT RECOMMENDED. In the case that nested
- * signing or encryption is employed, this Header Parameter MUST be present; in this case, the value MUST be
- * {@code JWT}, to indicate that a Nested JWT is carried in this JWT. While media type names are not
- * case-sensitive, it is RECOMMENDED that {@code JWT} always be spelled using uppercase characters for
- * compatibility with legacy implementations. See
- * JWT Appendix A.2 for
- * an example of a Nested JWT. The To keep messages compact in common situations, it is RECOMMENDED that producers omit an
+ * In the normal case where nested signing or encryption operations are not employed (i.e. a compact
- * serialization JWT), the use of this header parameter is NOT RECOMMENDED. In the case that nested
- * signing or encryption is employed, this Header Parameter MUST be present; in this case, the value MUST be
- * {@code JWT}, to indicate that a Nested JWT is carried in this JWT. While media type names are not
- * case-sensitive, it is RECOMMENDED that {@code JWT} always be spelled using uppercase characters for
- * compatibility with legacy implementations. See
- * JWT Appendix A.2 for
- * an example of a Nested JWT. Compatibility Note While the JWT family of specifications only defines the
- * The compression algorithm is NOT part of the JWT specification
- * and must be used carefully since, is not expected that other libraries (including previous versions of this one)
- * be able to deserialize a compressed JTW body correctly. Compact Media Type Identifier This method will automatically remove any JJWT performs the reverse during JWT parsing: {@link Header#getContentType()} will automatically prepend the
+ * {@code application/} prefix if the parsed {@code cty} value does not contain a ' The following table indicates how various JWT or JWK {@link #getId() getId()} values are used. The JWE {@code enc} (encryption algorithm) Header Parameter identifies the content encryption algorithm
+ * used to perform authenticated encryption on the plaintext to produce the ciphertext and the JWE
+ * {@code Authentication Tag}. Note that there is no corresponding 'setter' method for this 'getter' because JJWT users set this value by
+ * supplying an {@link AeadAlgorithm} to a {@link JwtBuilder} via one of its
+ * {@link JwtBuilder#encryptWith(SecretKey, AeadAlgorithm) encryptWith(SecretKey, AeadAlgorithm)} or
+ * {@link JwtBuilder#encryptWith(Key, KeyAlgorithm, AeadAlgorithm) encryptWith(Key, KeyAlgorithm, AeadAlgorithm)}
+ * methods. JJWT will then set this {@code enc} header value automatically to the {@code AeadAlgorithm}'s
+ * {@link AeadAlgorithm#getId() getId()} value during encryption. Note that there is no corresponding 'setter' method for this 'getter' because JJWT users set this value by
+ * supplying an ECDH-ES {@link KeyAlgorithm} to a {@link JwtBuilder} via its
+ * {@link JwtBuilder#encryptWith(Key, KeyAlgorithm, AeadAlgorithm) encryptWith(Key, KeyAlgorithm, AeadAlgorithm)}
+ * method. The ECDH-ES {@code KeyAlgorithm} implementation will then set this {@code epk} header value
+ * automatically when producing the encryption key. Note that there is no corresponding 'setter' method for this 'getter' because JJWT users set this value by
+ * supplying an AES GCM Wrap {@link KeyAlgorithm} to a {@link JwtBuilder} via its
+ * {@link JwtBuilder#encryptWith(Key, KeyAlgorithm, AeadAlgorithm) encryptWith(Key, KeyAlgorithm, AeadAlgorithm)}
+ * method. The AES GCM Wrap {@code KeyAlgorithm} implementation will then set this {@code iv} header value
+ * automatically when producing the encryption key. Note that there is no corresponding 'setter' method for this 'getter' because JJWT users set this value by
+ * supplying an AES GCM Wrap {@link KeyAlgorithm} to a {@link JwtBuilder} via its
+ * {@link JwtBuilder#encryptWith(Key, KeyAlgorithm, AeadAlgorithm) encryptWith(Key, KeyAlgorithm, AeadAlgorithm)}
+ * method. The AES GCM Wrap {@code KeyAlgorithm} implementation will then set this {@code tag} header value
+ * automatically when producing the encryption key. Note that there is no corresponding 'setter' method for this 'getter' because JJWT users set this value by
+ * supplying a password-based {@link KeyAlgorithm} to a {@link JwtBuilder} via its
+ * {@link JwtBuilder#encryptWith(Key, KeyAlgorithm, AeadAlgorithm) encryptWith(Key, KeyAlgorithm, AeadAlgorithm)}
+ * method. The password-based {@code KeyAlgorithm} implementation will then set this {@code p2s} header value
+ * automatically when producing the encryption key. If not {@code null}, this is a convenience method that calls the equivalent of the following: If not {@code null}, this is a convenience method that calls the equivalent of the following: Minimum Count {@code IllegalArgumentException} will be thrown during encryption if a specified {@code count} is
+ * less than 1000 (one thousand), which is the
+ * minimum number recommended by the
+ * JWA specification. Anything less is susceptible to security attacks so the default PBKDF2
+ * {@code KeyAlgorithm} implementations reject such values. the type of the JWS payload, either a byte[] or a {@link Claims} instance.
* @since 0.1
*/
-public interface Jws extends Jwt extends ProtectedJwt The algorithm header parameter identifies the cryptographic algorithm used to secure the JWS. Consider
- * using {@link io.jsonwebtoken.SignatureAlgorithm#forName(String) SignatureAlgorithm.forName} to convert this
- * string value to a type-safe enum instance. The algorithm header parameter identifies the cryptographic algorithm used to secure the JWS. Consider
- * using a type-safe {@link io.jsonwebtoken.SignatureAlgorithm SignatureAlgorithm} instance and using its
- * {@link io.jsonwebtoken.SignatureAlgorithm#getValue() value} as the argument to this method. The keyId header parameter is a hint indicating which key was used to secure the JWS. This parameter allows
- * originators to explicitly signal a change of key to recipients. The structure of the keyId value is
- * unspecified. When used with a JWK, the keyId value is used to match a JWK {@code keyId} parameter value. The keyId header parameter is a hint indicating which key was used to secure the JWS. This parameter allows
- * originators to explicitly signal a change of key to recipients. The structure of the keyId value is
- * unspecified. When used with a JWK, the keyId value is used to match a JWK {@code keyId} parameter value. the type of the JWT payload, either a content byte array or a {@link Claims} instance.
* @since 0.1
*/
-public interface Jwt If you do not want to replace the existing header and only want to append to it,
+ * call The payload and claims properties are mutually exclusive - only one of the two may be used. The payload and claims properties are mutually exclusive - only one of the two may be used. Content Type Recommendation Unless you are confident that the JWT recipient will always know to convert the payload bytes
+ * to a UTF-8 string without additional metadata, it is strongly recommended to use the
+ * {@link #content(String, String)} method instead of this one. That method ensures that a JWT recipient can
+ * inspect the {@code cty} header to know how to handle the payload bytes without ambiguity. Mutually Exclusive Claims and Content This method is mutually exclusive of the {@link #claim(String, Object)} and {@link #claims()}
+ * methods. Either {@code claims} or {@code content} method variants may be used, but not both. If you want the
+ * JWT payload to be JSON claims, use the {@link #claim(String, Object)} or {@link #claims()} methods instead. The payload* and claims* properties are mutually exclusive - only one of the two may be used. Content Type Recommendation Unless you are confident that the JWT recipient will always know how to use the payload bytes
+ * without additional metadata, it is strongly recommended to also set the
+ * {@link Header#getContentType() contentType} header. For example: This ensures a JWT recipient can inspect the {@code cty} header to know how to handle the payload bytes
+ * without ambiguity. Mutually Exclusive Claims and Content This method is mutually exclusive of the {@link #claim(String, Object)} and {@link #claims()}
+ * methods. Either {@code claims} or {@code content} method variants may be used, but not both. If you want the
+ * JWT payload to be JSON claims, use the {@link #claim(String, Object)} or {@link #claims()} methods instead. The payload and claims properties are mutually exclusive - only one of the two may be used. Content Type Recommendation Unless you are confident that the JWT recipient will always know how to use the payload bytes
+ * without additional metadata, it is strongly recommended to also set the
+ * {@link HeaderMutator#contentType(String) contentType} header. For example: This ensures a JWT recipient can inspect the {@code cty} header to know how to handle the payload bytes
+ * without ambiguity. Mutually Exclusive Claims and Content This method is mutually exclusive of the {@link #claim(String, Object)} and {@link #claims()}
+ * methods. Either {@code claims} or {@code content} method variants may be used, but not both. If you want the
+ * JWT payload to be JSON claims, use the {@link #claim(String, Object)} or {@link #claims()} methods instead. This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
- * the Claims {@link Claims#setIssuer(String) issuer} field with the specified value. This allows you to write
- * code like this: Compact Media Type Identifier instead of this: if desired. This method will automatically remove any JJWT performs the reverse during JWT parsing: {@link Header#getContentType()} will automatically prepend the
+ * {@code application/} prefix if the parsed {@code cty} value does not contain a ' Mutually Exclusive Claims and Content This method is mutually exclusive of the {@link #claim(String, Object)} and {@link #claims()}
+ * methods. Either {@code claims} or {@code content} method variants may be used, but not both. If you want the
+ * JWT payload to be JSON claims, use the {@link #claim(String, Object)} or {@link #claims()} methods instead. This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
- * the Claims {@link Claims#setSubject(String) subject} field with the specified value. This allows you to write
- * code like this: Compact Media Type Identifier instead of this: if desired. This method will automatically remove any JJWT performs the reverse during JWT parsing: {@link Header#getContentType()} will automatically prepend the
+ * {@code application/} prefix if the parsed {@code cty} value does not contain a ' Mutually Exclusive Claims and Content This method is mutually exclusive of the {@link #claim(String, Object)} and {@link #claims()}
+ * methods. Either {@code claims} or {@code content} method variants may be used, but not both. If you want the
+ * JWT payload to be JSON claims, use the {@link #claim(String, Object)} or {@link #claims()} methods instead. Compact Media Type Identifier This method will automatically remove any JJWT performs the reverse during JWT parsing: {@link Header#getContentType()} will automatically prepend the
+ * {@code application/} prefix if the parsed {@code cty} value does not contain a ' Mutually Exclusive Claims and Content This method is mutually exclusive of the {@link #claim(String, Object)} and {@link #claims()}
+ * methods. Either {@code claims} or {@code content} method variants may be used, but not both. If you want the
+ * JWT payload to be JSON claims, use the {@link #claim(String, Object)} or {@link #claims()} methods instead. The {@code content} and {@code claims} properties are mutually exclusive - only one of the two variants
+ * may be used. The content and claims properties are mutually exclusive - only one of the two may be used. This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
- * the Claims {@link Claims#setAudience(String) audience} field with the specified value. This allows you to write
- * code like this: The content and claims properties are mutually exclusive - only one of the two may be used. instead of this: if desired. A JWT obtained after this timestamp should not be used. This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
- * the Claims {@link Claims#setExpiration(java.util.Date) expiration} field with the specified value. This allows
- * you to write code like this: This is a convenience wrapper for: instead of this: if desired. A JWT obtained before this timestamp should not be used. This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
- * the Claims {@link Claims#setNotBefore(java.util.Date) notBefore} field with the specified value. This allows
- * you to write code like this: This is a convenience wrapper for: instead of this: if desired. The value is the timestamp when the JWT was created. This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
- * the Claims {@link Claims#setIssuedAt(java.util.Date) issuedAt} field with the specified value. This allows
- * you to write code like this: This is a convenience wrapper for: instead of this: if desired. The value is a CaSe-SenSiTiVe unique identifier for the JWT. If specified, this value MUST be assigned in a
* manner that ensures that there is a negligible probability that the same value will be accidentally
* assigned to a different data object. The ID can be used to prevent the JWT from being replayed. This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
- * the Claims {@link Claims#setId(String) id} field with the specified value. This allows
- * you to write code like this: This is a convenience wrapper for: instead of this: if desired. This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set the
- * named property on the Claims instance using the Claims {@link Claims#put(Object, Object) put} method. This allows
- * you to write code like this: If you are looking to invoke this method with a byte array that you are confident may be used for HMAC-SHA
+ * algorithms, consider using {@link Keys Keys}.{@link Keys#hmacShaKeyFor(byte[]) hmacShaKeyFor(bytes)} to
+ * convert the byte array into a valid {@code Key}. Recommended Signature Algorithm instead of this: if desired. The recommended signature algorithm used with a given key is chosen based on the following: Notes: This implementation does not use the {@link Jwts.SIG#PS256 PS256},
+ * {@link Jwts.SIG#PS384 PS384}, or {@link Jwts.SIG#PS512 PS512} RSA variants for any
+ * specified {@link RSAKey} because the the {@link Jwts.SIG#RS256 RS256},
+ * {@link Jwts.SIG#RS384 RS384}, and {@link Jwts.SIG#RS512 RS512} algorithms are
+ * available in the JDK by default while the {@code PS}* variants require either JDK 11 or an additional JCA
+ * Provider (like BouncyCastle). If you wish to use a {@code PS}* variant with your key, use the
+ * {@link #signWith(Key, SecureDigestAlgorithm)} method instead. If you are looking to invoke this method with a byte array that you are confident may be used for HMAC-SHA
- * algorithms, consider using {@link Keys Keys}.{@link Keys#hmacShaKeyFor(byte[]) hmacShaKeyFor(bytes)} to
- * convert the byte array into a valid {@code Key}. Finally, this method will throw an {@link InvalidKeyException} for any key that does not match the
+ * heuristics and requirements documented above, since that inevitably means the Key is either insufficient,
+ * unsupported, or explicitly disallowed by the JWT specification. Deprecation Notice: Deprecated as of 0.10.0 Use {@link Keys Keys}.{@link Keys#hmacShaKeyFor(byte[]) hmacShaKeyFor(bytes)} to
- * obtain the {@code Key} and then invoke {@link #signWith(Key)} or {@link #signWith(Key, SignatureAlgorithm)}. This method will be removed in the 1.0 release. This is a convenience method: the string argument is first BASE64-decoded to a byte array and this resulting
* byte array is used to invoke {@link #signWith(SignatureAlgorithm, byte[])}. Deprecation Notice: Deprecated as of 0.10.0, will be removed in the 1.0 release. This method has been deprecated because the {@code key} argument for this method can be confusing: keys for
* cryptographic operations are always binary (byte arrays), and many people were confused as to how bytes were
@@ -402,21 +764,20 @@
* {@code String base64EncodedSecretKey = base64Encode(secretKeyBytes);} However, a non-trivial number of JJWT users were confused by the method signature and attempted to
- * use raw password strings as the key argument - for example {@code signWith(HS256, myPassword)} - which is
+ * use raw password strings as the key argument - for example {@code with(HS256, myPassword)} - which is
* almost always incorrect for cryptographic hashes and can produce erroneous or insecure results. See this
*
* StackOverflow answer explaining why raw (non-base64-encoded) strings are almost always incorrect for
* signature operations. To perform the correct logic with base64EncodedSecretKey strings with JJWT >= 0.10.0, you may do this:
+ * To perform the correct logic with base64EncodedSecretKey strings with JJWT >= 0.10.0, you may do this: This method will be removed in the 1.0 release. Deprecation Notice This has been deprecated since 0.12.0. Use
+ * {@link #signWith(Key, SecureDigestAlgorithm)} instead. Standard JWA algorithms
+ * are represented as instances of this new interface in the {@link Jwts.SIG}
+ * algorithm registry. Signs the constructed JWT with the specified key using the specified algorithm, producing a JWS. It is typically recommended to call the {@link #signWith(Key)} instead for simplicity.
* However, this method can be useful if the recommended algorithm heuristics do not meet your needs or if
* you want explicit control over the signature algorithm used with the specified key. The {@link Jwts.SIG} registry makes available all standard signature
+ * algorithms defined in the JWA specification. It is typically recommended to call the {@link #signWith(Key)} instead for simplicity.
+ * However, this method can be useful if the recommended algorithm heuristics do not meet your needs or if
+ * you want explicit control over the signature algorithm used with the specified key. This method is a convenience method that delegates to
+ * {@link #encryptWith(Key, KeyAlgorithm, AeadAlgorithm) encryptWith(Key, KeyAlgorithm, AeadAlgorithm)}
+ * based on the {@code key} argument: This behavior can be illustrated by the following pseudocode, a rough example of what happens during
+ * {@link #compact() compact}ion: Most application developers will reference one of the JWA
+ * {@link Jwts.KEY standard key algorithms} and {@link Jwts.ENC standard encryption algorithms}
+ * when invoking this method, but custom implementations are also supported. If your compact JWTs are large, and you want to reduce their total size during network transmission, this
* can be useful. For example, when embedding JWTs in URLs, some browsers may not support URLs longer than a
* certain length. Using compression can help ensure the compact JWT fits within that length. However, NOTE: Compatibility Warning The JWT family of specifications defines compression only for JWE (Json Web Encryption)
+ * The JWT family of specifications defines compression only for JWE (JSON Web Encryption)
* tokens. Even so, JJWT will also support compression for JWS tokens as well if you choose to use it.
* However, be aware that if you use compression when creating a JWS token, other libraries may not be able to
- * parse that JWS token. When using compression for JWS tokens, be sure that that all parties accessing the
+ * parse that JWS token Compression when creating JWE tokens however should be universally accepted for any
* library that supports JWE. JJWT uses a spec-compliant encoder that works on all supported JDK versions, but you may call this method
* to specify a different encoder if you desire. JJWT uses a spec-compliant encoder that works on all supported JDK versions, but you may call this method
+ * to specify a different stream encoder if desired. This value may only be {@code false} for JWSs (signed JWTs). It may not be used for standard
+ * (unprotected) JWTs or encrypted JWTs (JWEs). The builder will throw an exception during {@link #compact()} if
+ * {@code false} and a JWS is not being created. If this method is not called, JJWT will use whatever serializer it can find at runtime, checking for the
* presence of well-known implementations such Jackson, Gson, and org.json. If one of these is not found
* in the runtime classpath, an exception will be thrown when the {@link #compact()} method is invoked.iss
(issuer) value. A {@code null} value will remove the property from the JSON map.
+ * Sets the JWT
+ * iss
(issuer) claim. A {@code null} value will remove the property from the JSON Claims map.
*
* @param iss the JWT {@code iss} value or {@code null} to remove the property from the JSON map.
* @return the {@code Claims} instance for method chaining.
+ * @deprecated since 0.12.0 in favor of the shorter and more modern builder-style named
+ * {@link #issuer(String)}. This method will be removed before the JJWT 1.0 release.
*/
+ @Deprecated
T setIssuer(String iss);
/**
- * Sets the JWT
- * sub
(subject) value. A {@code null} value will remove the property from the JSON map.
+ * Sets the JWT
+ * iss
(issuer) claim. A {@code null} value will remove the property from the JSON Claims map.
*
+ * @param iss the JWT {@code iss} value or {@code null} to remove the property from the JSON map.
+ * @return the {@code Claims} instance for method chaining.
+ * @since 0.12.0
+ */
+ T issuer(String iss);
+
+ /**
+ * Sets the JWT
+ * sub
(subject) claim. A {@code null} value will remove the property from the JSON Claims map.
+ *
* @param sub the JWT {@code sub} value or {@code null} to remove the property from the JSON map.
* @return the {@code Claims} instance for method chaining.
+ * @deprecated since 0.12.0 in favor of the shorter and more modern builder-style named
+ * {@link #subject(String)}. This method will be removed before the JJWT 1.0 release.
*/
+ @Deprecated
T setSubject(String sub);
/**
- * Sets the JWT
- * aud
(audience) value. A {@code null} value will remove the property from the JSON map.
+ * Sets the JWT
+ * sub
(subject) claim. A {@code null} value will remove the property from the JSON Claims map.
*
+ * @param sub the JWT {@code sub} value or {@code null} to remove the property from the JSON map.
+ * @return the {@code Claims} instance for method chaining.
+ * @since 0.12.0
+ */
+ T subject(String sub);
+
+ /**
+ * Sets the JWT aud
(audience)
+ * claim as a single String, NOT a String array. This method exists only for producing
+ * JWTs sent to legacy recipients that are unable to interpret the {@code aud} value as a JSON String Array; it is
+ * strongly recommended to avoid calling this method whenever possible and favor the
+ * {@link #audience()}.{@link AudienceCollection#add(Object) add(String)} and
+ * {@link AudienceCollection#add(Collection) add(Collection)} methods instead, as they ensure a single
+ * deterministic data type for recipients.
+ *
* @param aud the JWT {@code aud} value or {@code null} to remove the property from the JSON map.
* @return the {@code Claims} instance for method chaining.
+ * @deprecated since 0.12.0 in favor of {@link #audience()}. This method will be removed before
+ * the JJWT 1.0 release.
*/
+ @Deprecated
T setAudience(String aud);
/**
- * Sets the JWT
- * exp
(expiration) timestamp. A {@code null} value will remove the property from the JSON map.
+ * Configures the JWT
+ * aud
(audience) Claim
+ * set, quietly ignoring any null, empty, whitespace-only, or existing value already in the set.
*
+ *
+ *
+ * @return the {@link AudienceCollection AudienceCollection} to use for {@code aud} configuration.
+ * @see AudienceCollection AudienceCollection
+ * @see AudienceCollection#single(String) AudienceCollection.single(String)
+ * @since 0.12.0
+ */
+ AudienceCollection
+ * Jwts.builder() // or Jwts.claims()
+ *
+ * .audience().add("anAudience").and() // return parent
+ *
+ * .subject("Joe") // resume configuration...
+ * // etc...
+ *
exp
(expiration) timestamp claim. A {@code null} value will remove the property from the
+ * JSON Claims map.
+ *
* nbf
(not before) timestamp. A {@code null} value will remove the property from the JSON map.
+ * Sets the JWT
+ * exp
(expiration) timestamp claim. A {@code null} value will remove the property from the
+ * JSON Claims map.
*
+ * nbf
(not before) timestamp claim. A {@code null} value will remove the property from the
+ * JSON Claims map.
+ *
* iat
(issued at) timestamp. A {@code null} value will remove the property from the JSON map.
+ * Sets the JWT
+ * nbf
(not before) timestamp claim. A {@code null} value will remove the property from the
+ * JSON Claims map.
*
+ * iat
(issued at) timestamp claim. A {@code null} value will remove the property from the
+ * JSON Claims map.
+ *
* jti
(JWT ID) value. A {@code null} value will remove the property from the JSON map.
+ * Sets the JWT
+ * iat
(issued at) timestamp claim. A {@code null} value will remove the property from the
+ * JSON Claims map.
*
+ * jti
(JWT ID) claim. A {@code null} value will remove the property from the JSON Claims map.
+ *
* jti
(JWT ID) claim. A {@code null} value will remove the property from the JSON Claims map.
+ *
+ *
+ *
+ * @param
+ * Jwts.builder() // or Jwts.claims()
+ *
+ * .audience().add("anAudience").and() // return parent
+ *
+ * .subject("Joe") // resume parent configuration...
+ * // etc...
aud
(audience)
+ * Claim as a single String, NOT a String array. This method exists only for producing
+ * JWTs sent to legacy recipients that are unable to interpret the {@code aud} value as a JSON String Array;
+ * it is strongly recommended to avoid calling this method whenever possible and favor the
+ * {@link #add(Object) add(String)} or {@link #add(Collection)} methods instead, as they ensure a single
+ * deterministic data type for recipients.
+ *
+ * @param aud the value to use as the {@code aud} Claim single-String value (and not an array of Strings), or
+ * {@code null}, empty or whitespace to remove the property from the JSON map.
+ * @return the instance for method chaining
+ * @since 0.12.0
+ * @deprecated This is technically not deprecated because the JWT RFC mandates support for single string values,
+ * but it is marked as deprecated to discourage its use when possible.
+ */
+ // DO NOT REMOVE EVER. This is a required RFC feature, but marked as deprecated to discourage its use
+ @Deprecated
+ P single(String aud);
+ }
}
Index: 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/CompressionCodec.java
===================================================================
diff -u -r0761df64c22d4bca1649836fda23e4526282498b -rca3e06f3b65d2880d69fd5278773c5c71e1ca3e7
--- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/CompressionCodec.java (.../CompressionCodec.java) (revision 0761df64c22d4bca1649836fda23e4526282498b)
+++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/CompressionCodec.java (.../CompressionCodec.java) (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7)
@@ -15,41 +15,56 @@
*/
package io.jsonwebtoken;
+import io.jsonwebtoken.io.CompressionAlgorithm;
+
/**
* Compresses and decompresses byte arrays according to a compression algorithm.
*
- * @see CompressionCodecs#DEFLATE
- * @see CompressionCodecs#GZIP
+ * zip
header value.zip
header value.
*
- * @return the compression algorithm name to use as the JWT's {@code zip} header value.
+ * @return the algorithm name to use as the JWT
+ * zip
header value.
+ * @deprecated since 0.12.0 in favor of {@link #getId()} to ensure congruence with
+ * all other identifiable algorithms.
*/
+ @SuppressWarnings("DeprecatedIsStillUsed")
+ @Deprecated
String getAlgorithmName();
/**
- * Compresses the specified byte array according to the compression {@link #getAlgorithmName() algorithm}.
+ * Compresses the specified byte array, returning the compressed byte array result.
*
- * @param payload bytes to compress
+ * @param content bytes to compress
* @return compressed bytes
- * @throws CompressionException if the specified byte array cannot be compressed according to the compression
- * {@link #getAlgorithmName() algorithm}.
+ * @throws CompressionException if the specified byte array cannot be compressed.
*/
- byte[] compress(byte[] payload) throws CompressionException;
+ @Deprecated
+ byte[] compress(byte[] content) throws CompressionException;
/**
- * Decompresses the specified compressed byte array according to the compression
- * {@link #getAlgorithmName() algorithm}. The specified byte array must already be in compressed form
- * according to the {@link #getAlgorithmName() algorithm}.
+ * Decompresses the specified compressed byte array, returning the decompressed byte array result. The
+ * specified byte array must already be in compressed form.
*
* @param compressed compressed bytes
* @return decompressed bytes
- * @throws CompressionException if the specified byte array cannot be decompressed according to the compression
- * {@link #getAlgorithmName() algorithm}.
+ * @throws CompressionException if the specified byte array cannot be decompressed.
*/
+ @Deprecated
byte[] decompress(byte[] compressed) throws CompressionException;
-}
\ No newline at end of file
+}
Index: 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/CompressionCodecResolver.java
===================================================================
diff -u -r0761df64c22d4bca1649836fda23e4526282498b -rca3e06f3b65d2880d69fd5278773c5c71e1ca3e7
--- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/CompressionCodecResolver.java (.../CompressionCodecResolver.java) (revision 0761df64c22d4bca1649836fda23e4526282498b)
+++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/CompressionCodecResolver.java (.../CompressionCodecResolver.java) (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7)
@@ -20,17 +20,21 @@
* can use to decompress the JWT body.
*
* Compatibility Warning
+ *
+ * Map<String, Object>
, you can use standard {@code Map}
+ * accessor/iterator methods as desired, for example:
- * header.{@link Map#put(Object, Object) put}("headerParamName", "headerParamValue");
- *
+ *
*
- *
+ * header.get("someKey");
Creation
+ * "JWT"
*/
- public static final String JWT_TYPE = "JWT";
+ /**
+ * JWT {@code Type} (typ) value: "JWT"
+ *
+ * @deprecated since 0.12.0 - this constant is never used within the JJWT codebase.
+ */
+ @Deprecated
+ String JWT_TYPE = "JWT";
- /** JWT {@code Type} header parameter name: "typ"
*/
- public static final String TYPE = "typ";
+ /**
+ * JWT {@code Type} header parameter name: "typ"
+ * @deprecated since 0.12.0 in favor of {@link #getType()}.
+ */
+ @Deprecated
+ String TYPE = "typ";
- /** JWT {@code Content Type} header parameter name: "cty"
*/
- public static final String CONTENT_TYPE = "cty";
+ /**
+ * JWT {@code Content Type} header parameter name: "cty"
+ * @deprecated since 0.12.0 in favor of {@link #getContentType()}.
+ */
+ @Deprecated
+ String CONTENT_TYPE = "cty";
- /** JWT {@code Compression Algorithm} header parameter name: "zip"
*/
- public static final String COMPRESSION_ALGORITHM = "zip";
+ /**
+ * JWT {@code Algorithm} header parameter name: "alg"
.
+ *
+ * @see JWS Algorithm Header
+ * @see JWE Algorithm Header
+ * @deprecated since 0.12.0 in favor of {@link #getAlgorithm()}.
+ */
+ @Deprecated
+ String ALGORITHM = "alg";
- /** JJWT legacy/deprecated compression algorithm header parameter name: "calg"
- * @deprecated use {@link #COMPRESSION_ALGORITHM} instead. */
+ /**
+ * JWT {@code Compression Algorithm} header parameter name: "zip"
+ * @deprecated since 0.12.0 in favor of {@link #getCompressionAlgorithm()}
+ */
@Deprecated
- public static final String DEPRECATED_COMPRESSION_ALGORITHM = "calg";
+ String COMPRESSION_ALGORITHM = "zip";
/**
- * Returns the
- * typ
(type) header value or {@code null} if not present.
+ * JJWT legacy/deprecated compression algorithm header parameter name: "calg"
*
- * @return the {@code typ} header value or {@code null} if not present.
+ * @deprecated use {@link #COMPRESSION_ALGORITHM} instead.
*/
- String getType();
+ @Deprecated
+ String DEPRECATED_COMPRESSION_ALGORITHM = "calg";
/**
- * Sets the JWT
- * typ
(Type) header value. A {@code null} value will remove the property from the JSON map.
+ * Returns the
+ * typ
(Type) header value or {@code null} if not present.
*
- * @param typ the JWT JOSE {@code typ} header value or {@code null} to remove the property from the JSON map.
- * @return the {@code Header} instance for method chaining.
+ * @return the {@code typ} header value or {@code null} if not present.
*/
- T setType(String typ);
+ String getType();
/**
- * Returns the
- * cty
(Content Type) header value or {@code null} if not present.
+ * Returns the
+ * cty
(Content Type) header value or {@code null} if not present.
*
- * cty
(Content Type) Header Parameter is used by applications to declare the
+ * IANA MediaType of the content
+ * (the payload). This is intended for use by the application when more than
+ * one kind of object could be present in the Payload; the application can use this value to disambiguate among
+ * the different kinds of objects that might be present. It will typically not be used by applications when
+ * the kind of object is already known. This parameter is ignored by JWT implementations (like JJWT); any
+ * processing of this parameter is performed by the JWS application. Use of this Header Parameter is OPTIONAL.application/
prefix of a media type value in a {@code cty} Header Parameter when
+ * no other '/' appears in the media type value. A recipient using the media type value MUST
+ * treat it as if application/
were prepended to any {@code cty} value not containing a
+ * '/'. For instance, a {@code cty} value of example
SHOULD be used to
+ * represent the application/example
media type, whereas the media type
+ * application/example;part="1/2"
cannot be shortened to
+ * example;part="1/2"
.cty
(Content Type) header parameter value. A {@code null} value will remove the property from
- * the JSON map.
+ * Returns the JWT {@code alg} (Algorithm) header value or {@code null} if not present.
*
- *
+ *
*
- * @param cty the JWT JOSE {@code cty} header value or {@code null} to remove the property from the JSON map.
+ * @return the {@code alg} header value or {@code null} if not present. This will always be
+ * {@code non-null} on validly constructed JWT instances, but could be {@code null} during construction.
+ * @since 0.12.0
*/
- T setContentType(String cty);
+ String getAlgorithm();
/**
- * Returns the JWT alg
(Algorithm) header parameter identifies the cryptographic algorithm used to secure the
+ * JWS. Consider using {@link Jwts.SIG}.{@link io.jsonwebtoken.lang.Registry#get(Object) get(id)}
+ * to convert this string value to a type-safe {@code SecureDigestAlgorithm} instance.alg
(Algorithm) header parameter
+ * identifies the cryptographic key management algorithm used to encrypt or determine the value of the Content
+ * Encryption Key (CEK). The encrypted content is not usable if the alg
value does not represent a
+ * supported algorithm, or if the recipient does not have a key that can be used with that algorithm. Consider
+ * using {@link Jwts.KEY}.{@link io.jsonwebtoken.lang.Registry#get(Object) get(id)} to convert this string value
+ * to a type-safe {@link io.jsonwebtoken.security.KeyAlgorithm KeyAlgorithm} instance.zip
(Compression Algorithm) header value or {@code null} if not present.
+ * Returns the JWT zip
+ * (Compression Algorithm) header parameter value or {@code null} if not present.
*
+ * zip
header in the JWE
+ * (JSON Web Encryption) specification, JJWT will also support compression for JWS as well if you choose to use it.
+ * However, be aware that if you use compression when creating a JWS token, other libraries may not be able to
+ * parse the JWS. However, compression when creating JWE tokens should be universally accepted for any library
+ * that supports JWE.zip
(Compression Algorithm) header parameter value. A {@code null} value will remove
- * the property from the JSON map.
- *
+ *
+ *
+ * @param alg the {@code alg} header value
+ * @return this header for method chaining
+ * @since 0.12.0
+ *
+ T algorithm(String alg);
+ */
+
+ /**
+ * Sets the JWT
+ * alg
(Algorithm) header parameter
+ * identifies the cryptographic key management algorithm used to encrypt or determine the value of the Content
+ * Encryption Key (CEK). The encrypted content is not usable if the alg
value does not represent a
+ * supported algorithm, or if the recipient does not have a key that can be used with that algorithm.typ
(Type) header value. A {@code null} value will remove the property from the JSON map.
+ *
+ * @param typ the JWT JOSE {@code typ} header value or {@code null} to remove the property from the JSON map.
+ * @return the instance for method chaining.
+ */
+ T type(String typ);
+
+ /**
+ * Sets the compact
+ * cty
(Content Type) header parameter value, used by applications to declare the
+ * IANA MediaType of the JWT
+ * payload. A {@code null} value will remove the property from the JSON map.
+ *
+ * application/
prefix from the
+ * {@code cty} string if possible according to the rules defined in the last paragraph of
+ * RFC 7517, Section 4.1.10:
+ *
+ *
+ * To keep messages compact in common situations, it is RECOMMENDED that
+ * producers omit an "application/" prefix of a media type value in a
+ * "cty" Header Parameter when no other '/' appears in the media type
+ * value. A recipient using the media type value MUST treat it as if
+ * "application/" were prepended to any "cty" value not containing a
+ * '/'. For instance, a "cty" value of "example" SHOULD be used to
+ * represent the "application/example" media type, whereas the media
+ * type "application/example;part="1/2"" cannot be shortened to
+ * "example;part="1/2"".
/
' character (as
+ * mandated by the RFC language above). This ensures application developers can use and read standard IANA Media
+ * Type identifiers without needing JWT-specific prefix conditional logic in application code.
+ *
+ *
+ *
+ * @since 0.12.0
+ */
+public interface Identifiable {
+
+ /**
+ * Returns the unique string identifier of the associated object.
+ *
+ * @return the unique string identifier of the associated object.
+ */
+ String getId();
+}
Index: 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/IncorrectClaimException.java
===================================================================
diff -u -r0761df64c22d4bca1649836fda23e4526282498b -rca3e06f3b65d2880d69fd5278773c5c71e1ca3e7
--- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/IncorrectClaimException.java (.../IncorrectClaimException.java) (revision 0761df64c22d4bca1649836fda23e4526282498b)
+++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/IncorrectClaimException.java (.../IncorrectClaimException.java) (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7)
@@ -23,11 +23,30 @@
*/
public class IncorrectClaimException extends InvalidClaimException {
- public IncorrectClaimException(Header header, Claims claims, String message) {
- super(header, claims, message);
+ /**
+ * Creates a new instance with the specified header, claims and explanation message.
+ *
+ * @param header the header inspected
+ * @param claims the claims with the incorrect claim value
+ * @param claimName the name of the claim that could not be validated
+ * @param claimValue the value of the claim that could not be validated
+ * @param message the exception message
+ */
+ public IncorrectClaimException(Header header, Claims claims, String claimName, Object claimValue, String message) {
+ super(header, claims, claimName, claimValue, message);
}
- public IncorrectClaimException(Header header, Claims claims, String message, Throwable cause) {
- super(header, claims, message, cause);
+ /**
+ * Creates a new instance with the specified header, claims, explanation message and underlying cause.
+ *
+ * @param header the header inspected
+ * @param claims the claims with the incorrect claim value
+ * @param claimName the name of the claim that could not be validated
+ * @param claimValue the value of the claim that could not be validated
+ * @param message the exception message
+ * @param cause the underlying cause that resulted in this exception being thrown
+ */
+ public IncorrectClaimException(Header header, Claims claims, String claimName, Object claimValue, String message, Throwable cause) {
+ super(header, claims, claimName, claimValue, message, cause);
}
}
Index: 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/InvalidClaimException.java
===================================================================
diff -u -r0761df64c22d4bca1649836fda23e4526282498b -rca3e06f3b65d2880d69fd5278773c5c71e1ca3e7
--- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/InvalidClaimException.java (.../InvalidClaimException.java) (revision 0761df64c22d4bca1649836fda23e4526282498b)
+++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/InvalidClaimException.java (.../InvalidClaimException.java) (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7)
@@ -21,35 +21,66 @@
*
* @see IncorrectClaimException
* @see MissingClaimException
- *
* @since 0.6
*/
public class InvalidClaimException extends ClaimJwtException {
- private String claimName;
- private Object claimValue;
+ /**
+ * The name of the invalid claim.
+ */
+ private final String claimName;
- protected InvalidClaimException(Header header, Claims claims, String message) {
+ /**
+ * The claim value that could not be validated.
+ */
+ private final Object claimValue;
+
+ /**
+ * Creates a new instance with the specified header, claims and explanation message.
+ *
+ * @param header the header inspected
+ * @param claims the claims obtained
+ * @param claimName the name of the claim that could not be validated
+ * @param claimValue the value of the claim that could not be validated
+ * @param message the exception message
+ */
+ protected InvalidClaimException(Header header, Claims claims, String claimName, Object claimValue, String message) {
super(header, claims, message);
+ this.claimName = claimName;
+ this.claimValue = claimValue;
}
- protected InvalidClaimException(Header header, Claims claims, String message, Throwable cause) {
+ /**
+ * Creates a new instance with the specified header, claims, explanation message and underlying cause.
+ *
+ * @param header the header inspected
+ * @param claims the claims obtained
+ * @param claimName the name of the claim that could not be validated
+ * @param claimValue the value of the claim that could not be validated
+ * @param message the exception message
+ * @param cause the underlying cause that resulted in this exception being thrown
+ */
+ protected InvalidClaimException(Header header, Claims claims, String claimName, Object claimValue, String message, Throwable cause) {
super(header, claims, message, cause);
+ this.claimName = claimName;
+ this.claimValue = claimValue;
}
+ /**
+ * Returns the name of the invalid claim.
+ *
+ * @return the name of the invalid claim.
+ */
public String getClaimName() {
return claimName;
}
- public void setClaimName(String claimName) {
- this.claimName = claimName;
- }
-
+ /**
+ * Returns the claim value that could not be validated.
+ *
+ * @return the claim value that could not be validated.
+ */
public Object getClaimValue() {
return claimValue;
}
-
- public void setClaimValue(Object claimValue) {
- this.claimValue = claimValue;
- }
}
Index: 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/Jwe.java
===================================================================
diff -u
--- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/Jwe.java (revision 0)
+++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/Jwe.java (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2021 jsonwebtoken.io
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.jsonwebtoken;
+
+/**
+ * An encrypted JWT, called a "JWE", per the
+ * JWE (RFC 7516) Specification.
+ *
+ * @param payload type, either {@link Claims} or {@code byte[]} content.
+ * @since 0.12.0
+ */
+public interface Jwe extends ProtectedJwt
+ *
+ *
+ *
+ * JJWT Type
+ * How {@link #getId()} is Used
+ *
+ *
+ * {@link io.jsonwebtoken.Claims Claims}
+ * JWT's {@code jti} (JWT ID)
+ * claim.
+ *
+ *
+ * {@link io.jsonwebtoken.security.Jwk Jwk}
+ * JWK's {@code kid} (Key ID)
+ * parameter value.
+ *
+ *
+ * {@link io.jsonwebtoken.security.Curve Curve}
+ * JWK's {@code crv} (Curve)
+ * parameter value.
+ *
+ *
+ * {@link io.jsonwebtoken.io.CompressionAlgorithm CompressionAlgorithm}
+ * JWE protected header's
+ * {@code zip} (Compression Algorithm)
+ * parameter value.
+ *
+ *
+ * {@link io.jsonwebtoken.security.HashAlgorithm HashAlgorithm}
+ * Within a {@link io.jsonwebtoken.security.JwkThumbprint JwkThumbprint}'s URI value.
+ *
+ *
+ * {@link io.jsonwebtoken.security.MacAlgorithm MacAlgorithm}
+ * JWS protected header's
+ * {@code alg} (Algorithm) parameter value.
+ *
+ *
+ * {@link io.jsonwebtoken.security.SignatureAlgorithm SignatureAlgorithm}
+ * JWS protected header's
+ * {@code alg} (Algorithm) parameter value.
+ *
+ *
+ * {@link io.jsonwebtoken.security.KeyAlgorithm KeyAlgorithm}
+ * JWE protected header's
+ * {@code alg} (Key Management Algorithm)
+ * parameter value.
+ *
+ *
+ *
+ * {@link io.jsonwebtoken.security.AeadAlgorithm AeadAlgorithm}
+ * JWE protected header's
+ * {@code enc} (Encryption Algorithm)
+ * parameter value.
+ * apu
(Agreement PartyUInfo) Header Parameter
+ * @see Jwts.KEY#ECDH_ES
+ * @see Jwts.KEY#ECDH_ES_A128KW
+ * @see Jwts.KEY#ECDH_ES_A192KW
+ * @see Jwts.KEY#ECDH_ES_A256KW
+ */
+ byte[] getAgreementPartyUInfo();
+
+ /**
+ * Returns any information about the JWE recipient for use with key agreement algorithms, or {@code null} if not
+ * present.
+ *
+ * @return any information about the JWE recipient for use with key agreement algorithms, or {@code null} if not
+ * present.
+ * @see JWE apv
(Agreement PartyVInfo) Header Parameter
+ * @see Jwts.KEY#ECDH_ES
+ * @see Jwts.KEY#ECDH_ES_A128KW
+ * @see Jwts.KEY#ECDH_ES_A192KW
+ * @see Jwts.KEY#ECDH_ES_A256KW
+ */
+ byte[] getAgreementPartyVInfo();
+
+ /**
+ * Returns the 96-bit "iv"
+ * (Initialization Vector) generated during key encryption, or {@code null} if not present.
+ * Set by AES GCM {@link io.jsonwebtoken.security.KeyAlgorithm KeyAlgorithm} implementations.
+ *
+ * p2c
(PBES2 Count) Header Parameter
+ * @see Jwts.KEY#PBES2_HS256_A128KW
+ * @see Jwts.KEY#PBES2_HS384_A192KW
+ * @see Jwts.KEY#PBES2_HS512_A256KW
+ */
+ Integer getPbes2Count();
+
+ /**
+ * Returns the PBKDF2 {@code Salt Input} value necessary to derive the key used during JWE encryption, or
+ * {@code null} if not present.
+ *
+ * p2s
(PBES2 Salt Input) Header Parameter
+ * @see Jwts.KEY#PBES2_HS256_A128KW
+ * @see Jwts.KEY#PBES2_HS384_A192KW
+ * @see Jwts.KEY#PBES2_HS512_A256KW
+ */
+ byte[] getPbes2Salt();
+}
Index: 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/JweHeaderMutator.java
===================================================================
diff -u
--- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/JweHeaderMutator.java (revision 0)
+++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/JweHeaderMutator.java (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7)
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2021 jsonwebtoken.io
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.jsonwebtoken;
+
+import io.jsonwebtoken.security.KeyAlgorithm;
+
+/**
+ * Mutation (modifications) to a {@link JweHeader} instance.
+ *
+ * @param apu
(Agreement PartyUInfo) Header Parameter
+ * @see Jwts.KEY#ECDH_ES
+ * @see Jwts.KEY#ECDH_ES_A128KW
+ * @see Jwts.KEY#ECDH_ES_A192KW
+ * @see Jwts.KEY#ECDH_ES_A256KW
+ */
+ T agreementPartyUInfo(byte[] info);
+
+ /**
+ * Sets any information about the JWE producer for use with key agreement algorithms. A {@code null} value removes
+ * the property from the JSON map.
+ *
+ *
+ *
+ * @param info information about the JWE producer to use with key agreement algorithms.
+ * @return the header for method chaining.
+ * @see JWE
+ * {@link #agreementPartyUInfo(byte[]) agreementPartyUInfo}(info.getBytes(StandardCharsets.UTF_8))
apu
(Agreement PartyUInfo) Header Parameter
+ * @see Jwts.KEY#ECDH_ES
+ * @see Jwts.KEY#ECDH_ES_A128KW
+ * @see Jwts.KEY#ECDH_ES_A192KW
+ * @see Jwts.KEY#ECDH_ES_A256KW
+ */
+ T agreementPartyUInfo(String info);
+
+ /**
+ * Sets any information about the JWE recipient for use with key agreement algorithms. A {@code null} value removes
+ * the property from the JSON map.
+ *
+ * @param info information about the JWE recipient to use with key agreement algorithms.
+ * @return the header for method chaining.
+ * @see JWE apv
(Agreement PartyVInfo) Header Parameter
+ * @see Jwts.KEY#ECDH_ES
+ * @see Jwts.KEY#ECDH_ES_A128KW
+ * @see Jwts.KEY#ECDH_ES_A192KW
+ * @see Jwts.KEY#ECDH_ES_A256KW
+ */
+ T agreementPartyVInfo(byte[] info);
+
+ /**
+ * Sets any information about the JWE recipient for use with key agreement algorithms. A {@code null} value removes
+ * the property from the JSON map.
+ *
+ *
+ *
+ * @param info information about the JWE recipient to use with key agreement algorithms.
+ * @return the header for method chaining.
+ * @see JWE
+ * {@link #agreementPartyVInfo(byte[]) setAgreementPartVUInfo}(info.getBytes(StandardCharsets.UTF_8))
apv
(Agreement PartyVInfo) Header Parameter
+ * @see Jwts.KEY#ECDH_ES
+ * @see Jwts.KEY#ECDH_ES_A128KW
+ * @see Jwts.KEY#ECDH_ES_A192KW
+ * @see Jwts.KEY#ECDH_ES_A256KW
+ */
+ T agreementPartyVInfo(String info);
+
+ /**
+ * Sets the number of PBKDF2 iterations necessary to derive the key used during JWE encryption. If this value
+ * is not set when a password-based {@link KeyAlgorithm} is used, JJWT will automatically choose a suitable
+ * number of iterations based on
+ * OWASP PBKDF2 Iteration Recommendations.
+ *
+ * p2c
(PBES2 Count) Header Parameter
+ * @see Jwts.KEY#PBES2_HS256_A128KW
+ * @see Jwts.KEY#PBES2_HS384_A192KW
+ * @see Jwts.KEY#PBES2_HS512_A256KW
+ * @see OWASP PBKDF2 Iteration Recommendations
+ */
+ T pbes2Count(int count);
+}
Index: 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/Jws.java
===================================================================
diff -u -rdd64f16fdf89f789b8c2179d421290dcabf15835 -rca3e06f3b65d2880d69fd5278773c5c71e1ca3e7
--- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/Jws.java (.../Jws.java) (revision dd64f16fdf89f789b8c2179d421290dcabf15835)
+++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/Jws.java (.../Jws.java) (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7)
@@ -18,11 +18,49 @@
/**
* An expanded (not compact/serialized) Signed JSON Web Token.
*
- * @param the type of the JWS body contents, either a String or a {@link Claims} instance.
- *
+ * @param "alg"
*/
- public static final String ALGORITHM = "alg";
+ /**
+ * JWS Algorithm Header name: the string literal alg
+ *
+ * @deprecated since 0.12.0 in favor of {@link #getAlgorithm()}
+ */
+ @Deprecated
+ String ALGORITHM = "alg";
- /** JWS {@code JWT Set URL} header parameter name: "jku"
*/
- public static final String JWK_SET_URL = "jku";
+ /**
+ * JWS JWK Set URL Header name: the string literal jku
+ *
+ * @deprecated since 0.12.0 in favor of {@link #getJwkSetUrl()}
+ */
+ @Deprecated
+ String JWK_SET_URL = "jku";
- /** JWS {@code JSON Web Key} header parameter name: "jwk"
*/
- public static final String JSON_WEB_KEY = "jwk";
+ /**
+ * JWS JSON Web Key Header name: the string literal jwk
+ *
+ * @deprecated since 0.12.0 in favor of {@link #getJwk()}
+ */
+ @Deprecated
+ String JSON_WEB_KEY = "jwk";
- /** JWS {@code Key ID} header parameter name: "kid"
*/
- public static final String KEY_ID = "kid";
+ /**
+ * JWS Key ID Header name: the string literal kid
+ *
+ * @deprecated since 0.12.0 in favor of {@link #getKeyId()}
+ */
+ @Deprecated
+ String KEY_ID = "kid";
- /** JWS {@code X.509 URL} header parameter name: "x5u"
*/
- public static final String X509_URL = "x5u";
+ /**
+ * JWS X.509 URL Header name: the string literal x5u
+ *
+ * @deprecated since 0.12.0 in favor of {@link #getX509Url()}
+ */
+ @Deprecated
+ String X509_URL = "x5u";
- /** JWS {@code X.509 Certificate Chain} header parameter name: "x5c"
*/
- public static final String X509_CERT_CHAIN = "x5c";
+ /**
+ * JWS X.509 Certificate Chain Header name: the string literal x5c
+ *
+ * @deprecated since 0.12.0 in favor of {@link #getX509Chain()}
+ */
+ @Deprecated
+ String X509_CERT_CHAIN = "x5c";
- /** JWS {@code X.509 Certificate SHA-1 Thumbprint} header parameter name: "x5t"
*/
- public static final String X509_CERT_SHA1_THUMBPRINT = "x5t";
-
- /** JWS {@code X.509 Certificate SHA-256 Thumbprint} header parameter name: "x5t#S256"
*/
- public static final String X509_CERT_SHA256_THUMBPRINT = "x5t#S256";
-
- /** JWS {@code Critical} header parameter name: "crit"
*/
- public static final String CRITICAL = "crit";
-
/**
- * Returns the JWS
- * alg
(algorithm) header value or {@code null} if not present.
+ * JWS X.509 Certificate SHA-1 Thumbprint Header name: the string literal x5t
*
- * alg
(Algorithm) header value. A {@code null} value will remove the property from the JSON map.
+ * JWS X.509 Certificate SHA-256 Thumbprint Header name: the string literal x5t#S256
*
- * kid
(Key ID) header value or {@code null} if not present.
+ * JWS Critical Header name: the string literal crit
*
- * kid
(Key ID) header value. A {@code null} value will remove the property from the JSON map.
+ * Returns {@code true} if the payload is Base64Url-encoded per standard JWS rules, or {@code false} if the
+ * RFC 7797: JSON Web Signature (JWS) Unencoded Payload
+ * Option has been specified.
*
- *
+ *
+ * @return the {@link BuilderHeader} to use for header construction.
+ * @since 0.12.0
+ */
+ BuilderHeader header();
+
+ /**
+ * Per standard Java idiom 'setter' conventions, this method sets (and fully replaces) any existing header with the
+ * specified name/value pairs. This is a wrapper method for:
+ *
+ *
+ * String jwt = Jwts.builder()
+ *
+ * .header()
+ * .keyId("keyId")
+ * .add("aName", aValue)
+ * .add(myHeaderMap)
+ * // ... etc ...
+ * .{@link BuilderHeader#and() and()} //return back to the JwtBuilder
+ *
+ * .subject("Joe") // resume JwtBuilder calls
+ * // ... etc ...
+ * .compact();
+ *
+ *
+ * {@link #header()}.{@link MapMutator#empty() empty()}.{@link MapMutator#add(Map) add(map)}.{@link BuilderHeader#and() and()}
{@link #header()}.{@link io.jsonwebtoken.lang.MapMutator#add(Map) add(map)}.{@link BuilderHeader#and() and()}
instead.{@link #header()}.{@link MapMutator#empty() empty()}.{@link MapMutator#add(Map) add(map)}.{@link BuilderHeader#and() and()}
+ * (to replace all header parameters) or
+ * {@link #header()}.{@link MapMutator#add(Map) add(map)}.{@link BuilderHeader#and() and()}
+ * to only append the {@code map} entries. This method will be removed before the 1.0 release.
*/
- JwtBuilder setHeader(Map
*
* @param params the header name/value pairs to append to the header.
* @return the builder for method chaining.
+ * @deprecated since 0.12.0 in favor of
+ *
+ * {@link #header()}.{@link MapMutator#add(Map) add(map)}.{@link BuilderHeader#and() and()}
{@link #header()}.{@link MapMutator#add(Map) add(map)}.{@link BuilderHeader#and() and()}
.
+ * This method will be removed before the 1.0 release.
*/
- JwtBuilder setHeaderParams(Map
*
* @param name the header parameter name
* @param value the header parameter value
* @return the builder for method chaining.
+ * @deprecated since 0.12.0 in favor of
+ * {@link #header()}.{@link MapMutator#add(Object, Object) add(name, value)}.{@link BuilderHeader#and() and()}
+ * {@link #header()}.{@link MapMutator#add(Object, Object) add(name, value)}.{@link BuilderHeader#and() and()}
.
+ * This method will be removed before the 1.0 release.
*/
+ @SuppressWarnings("DeprecatedIsStillUsed")
+ @Deprecated
JwtBuilder setHeaderParam(String name, Object value);
/**
- * Sets the JWT's payload to be a plaintext (non-JSON) string. If you want the JWT body to be JSON, use the
- * {@link #setClaims(Claims)} or {@link #setClaims(java.util.Map)} methods instead.
+ * Since JJWT 0.12.0, this is an alias for {@link #content(String)}. This method will be removed
+ * before the 1.0 release.
*
- *
*
- * @param claims the JWT claims to be set as the JWT body.
+ *
+ * {@link #content(byte[]) content}(payload.getBytes(StandardCharsets.UTF_8))
*
- *
+ * {@link #content(InputStream) content}(new ByteArrayInputStream(content))
+ *
+ *
+ * content(bytes).{@link #header() header()}.{@link HeaderMutator#contentType(String) contentType(cty)}.{@link BuilderHeader#and() and()}
+ *
+ *
+ * content(in).{@link #header() header()}.{@link HeaderMutator#contentType(String) contentType(cty)}.{@link BuilderHeader#and() and()}
iss
(issuer) value. A {@code null} value will remove the property from the Claims.
+ * Sets the JWT payload to be the specified String's UTF-8 bytes, and also sets the
+ * {@link HeaderMutator#contentType(String) contentType} header value to a compact {@code cty} IANA Media Type
+ * identifier to indicate the data format of the resulting byte array. The JWT recipient can inspect the
+ * {@code cty} value to determine how to convert the byte array to the final content type as desired. This is a
+ * convenience method semantically equivalent to:
*
- *
*
- *
+ * {@link #content(String) content(content)}.{@link #header()}.{@link HeaderMutator#contentType(String) contentType(cty)}.{@link BuilderHeader#and() and()}
- * String jwt = Jwts.builder().setIssuer("Joe").compact();
- *
+ *
- * Claims claims = Jwts.claims().setIssuer("Joe");
- * String jwt = Jwts.builder().setClaims(claims).compact();
- *
- * application/
prefix from the
+ * {@code cty} string if possible according to the rules defined in the last paragraph of
+ * RFC 7517, Section 4.1.10:
+ *
+ *
+ * To keep messages compact in common situations, it is RECOMMENDED that
+ * producers omit an "application/" prefix of a media type value in a
+ * "cty" Header Parameter when no other '/' appears in the media type
+ * value. A recipient using the media type value MUST treat it as if
+ * "application/" were prepended to any "cty" value not containing a
+ * '/'. For instance, a "cty" value of "example" SHOULD be used to
+ * represent the "application/example" media type, whereas the media
+ * type "application/example;part="1/2"" cannot be shortened to
+ * "example;part="1/2"".
/
' character (as
+ * mandated by the RFC language above). This ensures application developers can use and read standard IANA Media
+ * Type identifiers without needing JWT-specific prefix conditional logic in application code.
+ * sub
(subject) value. A {@code null} value will remove the property from the Claims.
+ * Sets the JWT payload to be the specified byte array, and also sets the
+ * {@link HeaderMutator#contentType(String) contentType} header value to a compact {@code cty} IANA Media Type
+ * identifier to indicate the data format of the byte array. The JWT recipient can inspect the
+ * {@code cty} value to determine how to convert the byte array to the final content type as desired. This is a
+ * convenience method semantically equivalent to:
*
- *
*
- *
+ * {@link #content(byte[]) content(content)}.{@link #header()}.{@link HeaderMutator#contentType(String) contentType(cty)}.{@link BuilderHeader#and() and()}
- * String jwt = Jwts.builder().setSubject("Me").compact();
- *
+ *
- * Claims claims = Jwts.claims().setSubject("Me");
- * String jwt = Jwts.builder().setClaims(claims).compact();
- *
- * application/
prefix from the
+ * {@code cty} string if possible according to the rules defined in the last paragraph of
+ * RFC 7517, Section 4.1.10:
*
- * @param sub the JWT {@code sub} value or {@code null} to remove the property from the Claims map.
+ *
+ * To keep messages compact in common situations, it is RECOMMENDED that
+ * producers omit an "application/" prefix of a media type value in a
+ * "cty" Header Parameter when no other '/' appears in the media type
+ * value. A recipient using the media type value MUST treat it as if
+ * "application/" were prepended to any "cty" value not containing a
+ * '/'. For instance, a "cty" value of "example" SHOULD be used to
+ * represent the "application/example" media type, whereas the media
+ * type "application/example;part="1/2"" cannot be shortened to
+ * "example;part="1/2"".
/
' character (as
+ * mandated by the RFC language above). This ensures application developers can use and read standard IANA Media
+ * Type identifiers without needing JWT-specific prefix conditional logic in application code.
+ *
+ *
+ *
+ * {@link #content(InputStream) content(content)}.{@link #header()}.{@link HeaderMutator#contentType(String) contentType(cty)}.{@link BuilderHeader#and() and()}
application/
prefix from the
+ * {@code cty} string if possible according to the rules defined in the last paragraph of
+ * RFC 7517, Section 4.1.10:
+ *
+ *
+ * To keep messages compact in common situations, it is RECOMMENDED that
+ * producers omit an "application/" prefix of a media type value in a
+ * "cty" Header Parameter when no other '/' appears in the media type
+ * value. A recipient using the media type value MUST treat it as if
+ * "application/" were prepended to any "cty" value not containing a
+ * '/'. For instance, a "cty" value of "example" SHOULD be used to
+ * represent the "application/example" media type, whereas the media
+ * type "application/example;part="1/2"" cannot be shortened to
+ * "example;part="1/2"".
/
' character (as
+ * mandated by the RFC language above). This ensures application developers can use and read standard IANA Media
+ * Type identifiers without needing JWT-specific prefix conditional logic in application code.
+ *
+ *
+ * @return the {@link BuilderClaims} to use for Claims construction.
+ * @since 0.12.0
+ */
+ BuilderClaims claims();
+
+ /**
+ * Replaces the JWT Claims payload with the specified name/value pairs. This is an alias for:
+ *
+ * String jwt = Jwts.builder()
+ *
+ * .claims()
+ * .issuer("me")
+ * .subject("Joe")
+ * .audience().add("you").and()
+ * .add("customClaim", customValue)
+ * .add(myClaimsMap)
+ * // ... etc ...
+ * .{@link BuilderClaims#and() and()} //return back to the JwtBuilder
+ *
+ * .signWith(key) // resume JwtBuilder calls
+ * // ... etc ...
+ * .compact();
+ *
+ *
+ * {@link #claims()}.{@link MapMutator#empty() empty()}.{@link MapMutator#add(Map) add(claims)}.{@link BuilderClaims#and() and()}
+ *
+ *
+ * {@link #claims()}.{@link MapMutator#add(Map) add(claims)}.{@link BuilderClaims#and() and()}
{@link #claims()}.{@link BuilderClaims#add(Map) add(Map)}.{@link BuilderClaims#and() and()}
.
+ * This method will be removed before the 1.0 release.
+ */
+ @SuppressWarnings("DeprecatedIsStillUsed")
+ @Deprecated
+ JwtBuilder addClaims(Map
+ *
+ * @param name the JWT Claims property name
+ * @param value the value to set for the specified Claims property name
* @return the builder instance for method chaining.
* @since 0.2
*/
- @Override
- //only for better/targeted JavaDoc
- JwtBuilder setSubject(String sub);
+ JwtBuilder claim(String name, Object value);
/**
- * Sets the JWT Claims
- *
+ * {@link #claims()}.{@link MapMutator#add(Object, Object) add(name, value)}.{@link BuilderClaims#and() and()}
aud
(audience) value. A {@code null} value will remove the property from the Claims.
+ * Adds all given name/value pairs to the JSON Claims in the payload, overwriting any existing claims
+ * with the same names. If any name has a {@code null} or empty value, that claim will be removed from the
+ * Claims. This is a convenience alias for:
+ *
*
- *
+ * {@link #claims()}.{@link MapMutator#add(Map) add(claims)}.{@link BuilderClaims#and() and()}
- * String jwt = Jwts.builder().setAudience("You").compact();
- *
+ * @param claims the JWT Claims to be added to the JWT payload.
+ * @return the builder instance for method chaining
+ * @since 0.12.0
+ */
+ JwtBuilder claims(Mapiss
(issuer) claim. A {@code null} value will remove the property from the Claims.
+ * This is a convenience wrapper for:
+ *
*
- *
+ * {@link #claims()}.{@link ClaimsMutator#issuer(String) issuer(iss)}.{@link BuilderClaims#and() and()}
- * Claims claims = Jwts.claims().setAudience("You");
- * String jwt = Jwts.builder().setClaims(claims).compact();
- *
- * sub
(subject) claim. A {@code null} value will remove the property from the Claims.
+ * This is a convenience wrapper for:
+ *
*
- * @param aud the JWT {@code aud} value or {@code null} to remove the property from the Claims map.
+ * @param sub the JWT {@code sub} value or {@code null} to remove the property from the Claims map.
* @return the builder instance for method chaining.
- * @since 0.2
*/
@Override
- //only for better/targeted JavaDoc
- JwtBuilder setAudience(String aud);
+ // for better/targeted JavaDoc
+ JwtBuilder subject(String sub);
/**
- * Sets the JWT Claims
- *
+ * {@link #claims()}.{@link ClaimsMutator#subject(String) subject(sub)}.{@link BuilderClaims#and() and()}
exp
(expiration) value. A {@code null} value will remove the property from the Claims.
+ * Sets the JWT Claims
+ * exp
(expiration) claim. A {@code null} value will remove the property from the Claims.
*
*
*
- *
+ * {@link #claims()}.{@link ClaimsMutator#expiration(Date) expiration(exp)}.{@link BuilderClaims#and() and()}
- * String jwt = Jwts.builder().setExpiration(new Date(System.currentTimeMillis() + 3600000)).compact();
- *
- *
- *
- * Claims claims = Jwts.claims().setExpiration(new Date(System.currentTimeMillis() + 3600000));
- * String jwt = Jwts.builder().setClaims(claims).compact();
- *
- * nbf
(not before) value. A {@code null} value will remove the property from the Claims.
+ * Sets the JWT Claims
+ * nbf
(not before) claim. A {@code null} value will remove the property from the Claims.
*
*
*
- *
+ * {@link #claims()}.{@link ClaimsMutator#notBefore(Date) notBefore(nbf)}.{@link BuilderClaims#and() and()}
- * String jwt = Jwts.builder().setNotBefore(new Date()).compact();
- *
- *
- *
- * Claims claims = Jwts.claims().setNotBefore(new Date());
- * String jwt = Jwts.builder().setClaims(claims).compact();
- *
- * iat
(issued at) value. A {@code null} value will remove the property from the Claims.
+ * Sets the JWT Claims
+ * iat
(issued at) claim. A {@code null} value will remove the property from the Claims.
*
*
*
- *
+ * {@link #claims()}.{@link ClaimsMutator#issuedAt(Date) issuedAt(iat)}.{@link BuilderClaims#and() and()}
- * String jwt = Jwts.builder().setIssuedAt(new Date()).compact();
- *
- *
- *
- * Claims claims = Jwts.claims().setIssuedAt(new Date());
- * String jwt = Jwts.builder().setClaims(claims).compact();
- *
- * jti
(JWT ID) value. A {@code null} value will remove the property from the Claims.
+ * Sets the JWT Claims
+ * jti
(JWT ID) claim. A {@code null} value will remove the property from the Claims.
*
*
*
- *
+ * {@link #claims()}.{@link ClaimsMutator#id(String) id(jti)}.{@link BuilderClaims#and() and()}
- * String jwt = Jwts.builder().setId(UUID.randomUUID().toString()).compact();
- *
- *
- *
- * Claims claims = Jwts.claims().setId(UUID.randomUUID().toString());
- * String jwt = Jwts.builder().setClaims(claims).compact();
- *
- *
- * String jwt = Jwts.builder().claim("aName", "aValue").compact();
- *
+ *
- * Claims claims = Jwts.claims().put("aName", "aValue");
- * String jwt = Jwts.builder().setClaims(claims).compact();
- *
- *
+ *
+ *
+ *
+ *
+ *
+ * If the Key is a:
+ * And:
+ * With a key size of:
+ * The SignatureAlgorithm used will be:
+ *
+ *
+ * {@link SecretKey}
+ *
+ * {@link Key#getAlgorithm() getAlgorithm()}.equals("HmacSHA256")
1256 <= size <= 383 2
+ * {@link Jwts.SIG#HS256 HS256}
+ *
+ *
+ * {@link SecretKey}
+ *
+ * {@link Key#getAlgorithm() getAlgorithm()}.equals("HmacSHA384")
1384 <= size <= 511
+ * {@link Jwts.SIG#HS384 HS384}
+ *
+ *
+ * {@link SecretKey}
+ *
+ * {@link Key#getAlgorithm() getAlgorithm()}.equals("HmacSHA512")
1512 <= size
+ * {@link Jwts.SIG#HS512 HS512}
+ *
+ *
+ * {@link ECKey}
+ *
+ * instanceof {@link PrivateKey}
256 <= size <= 383 3
+ * {@link Jwts.SIG#ES256 ES256}
+ *
+ *
+ * {@link ECKey}
+ *
+ * instanceof {@link PrivateKey}
384 <= size <= 520 4
+ * {@link Jwts.SIG#ES384 ES384}
+ *
+ *
+ * {@link ECKey}
+ *
+ * instanceof {@link PrivateKey}
521 <= size 4
+ * {@link Jwts.SIG#ES512 ES512}
+ *
+ *
+ * {@link RSAKey}
+ *
+ * instanceof {@link PrivateKey}
2048 <= size <= 3071 5,6
+ * {@link Jwts.SIG#RS256 RS256}
+ *
+ *
+ * {@link RSAKey}
+ *
+ * instanceof {@link PrivateKey}
3072 <= size <= 4095 6
+ * {@link Jwts.SIG#RS384 RS384}
+ *
+ *
+ * {@link RSAKey}
+ *
+ * instanceof {@link PrivateKey}
4096 <= size 5
+ * {@link Jwts.SIG#RS512 RS512}
+ *
+ *
+ *
+ * EdECKey7
+ *
+ * instanceof {@link PrivateKey}
256 || 456
+ * {@link Jwts.SIG#EdDSA EdDSA}
+ *
+ *
*
- * @param name the JWT Claims property name
- * @param value the value to set for the specified Claims property name
- * @return the builder instance for method chaining.
- * @since 0.2
- */
- JwtBuilder claim(String name, Object value);
-
- /**
- * Signs the constructed JWT with the specified key using the key's
- * {@link SignatureAlgorithm#forSigningKey(Key) recommended signature algorithm}, producing a JWS. If the
- * recommended signature algorithm isn't sufficient for your needs, consider using
- * {@link #signWith(Key, SignatureAlgorithm)} instead.
+ * Deprecation Notice: Deprecated as of 0.10.0
+ * Deprecation Notice: Deprecated as of 0.10.0, will be removed in the 1.0 release.
+ *
- *
* byte[] keyBytes = {@link Decoders Decoders}.{@link Decoders#BASE64 BASE64}.{@link Decoder#decode(Object) decode(base64EncodedSecretKey)};
* Key key = {@link Keys Keys}.{@link Keys#hmacShaKeyFor(byte[]) hmacShaKeyFor(keyBytes)};
- * jwtBuilder.signWith(key); //or {@link #signWith(Key, SignatureAlgorithm)}
+ * jwtBuilder.with(key); //or {@link #signWith(Key, SignatureAlgorithm)}
*
+ *
+ *
+ * @param key the symmetric encryption key to use with the {@code enc} algorithm.
+ * @param enc the {@link AeadAlgorithm} algorithm used to encrypt the JWE, usually one of the JWA-standard
+ * algorithms accessible via {@link Jwts.ENC}.
+ * @return the JWE builder for method chaining.
+ * @see Jwts.ENC
+ */
+ JwtBuilder encryptWith(SecretKey key, AeadAlgorithm enc);
+
+ /**
+ * Encrypts the constructed JWT using the specified {@code enc} algorithm with the symmetric key produced by the
+ * {@code keyAlg} when invoked with the given {@code key}, producing a JWE.
+ *
+ *
+ *
+ * SecretKey encryptionKey = keyAlg.getEncryptionKey(key); // (1)
+ * byte[] jweCiphertext = enc.encrypt(payloadBytes, encryptionKey); // (2)
+ *
+ *
+ * Compatibility Warning
+ *