Index: 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/ClaimJwtException.java =================================================================== diff -u -rca3e06f3b65d2880d69fd5278773c5c71e1ca3e7 -rb673aa90094faa6f77a76c311d738710d7cf323a --- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/ClaimJwtException.java (.../ClaimJwtException.java) (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7) +++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/ClaimJwtException.java (.../ClaimJwtException.java) (revision b673aa90094faa6f77a76c311d738710d7cf323a) @@ -16,82 +16,35 @@ package io.jsonwebtoken; /** - * ClaimJwtException is a subclass of the {@link JwtException} that is thrown after a validation of an JWT claim failed. + * ClaimJwtException is a subclass of the {@link JwtException} that is thrown after a validation of an JTW 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 -rca3e06f3b65d2880d69fd5278773c5c71e1ca3e7 -rb673aa90094faa6f77a76c311d738710d7cf323a --- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/Claims.java (.../Claims.java) (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7) +++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/Claims.java (.../Claims.java) (revision b673aa90094faa6f77a76c311d738710d7cf323a) @@ -17,89 +17,94 @@ import java.util.Date; import java.util.Map; -import java.util.Set; /** - * A JWT Claims set. + * A JWT Claims set. * - *
This is an immutable JSON map with convenient type-safe getters for JWT standard claim names.
+ *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.
* - *Additionally, this interface also extends Map<String, Object>
, so you can use standard
- * {@code Map} accessor/iterator methods as desired, for example:
Because this interface extends {@code Map<String, Object>}, if you would like to add your own properties, + * you simply use map methods, for example:
* - *+ *- * claims.get("someKey");
+ * claims.{@link Map#put(Object, Object) put}("someKey", "someValue"); + ** - *
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"
- */
- String ISSUER = "iss";
+ /** JWT {@code Issuer} claims parameter name: "iss"
*/
+ public static final String ISSUER = "iss";
- /**
- * JWT {@code Subject} claims parameter name: "sub"
- */
- String SUBJECT = "sub";
+ /** JWT {@code Subject} claims parameter name: "sub"
*/
+ public static final String SUBJECT = "sub";
- /**
- * JWT {@code Audience} claims parameter name: "aud"
- */
- String AUDIENCE = "aud";
+ /** JWT {@code Audience} claims parameter name: "aud"
*/
+ public static final String AUDIENCE = "aud";
- /**
- * JWT {@code Expiration} claims parameter name: "exp"
- */
- String EXPIRATION = "exp";
+ /** JWT {@code Expiration} claims parameter name: "exp"
*/
+ public static final String EXPIRATION = "exp";
- /**
- * JWT {@code Not Before} claims parameter name: "nbf"
- */
- String NOT_BEFORE = "nbf";
+ /** JWT {@code Not Before} claims parameter name: "nbf"
*/
+ public static final String NOT_BEFORE = "nbf";
- /**
- * JWT {@code Issued At} claims parameter name: "iat"
- */
- String ISSUED_AT = "iat";
+ /** JWT {@code Issued At} claims parameter name: "iat"
*/
+ public static final String ISSUED_AT = "iat";
- /**
- * JWT {@code JWT ID} claims parameter name: "jti"
- */
- String ID = "jti";
+ /** JWT {@code JWT ID} claims parameter name: "jti"
*/
+ public static final 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();
/**
- * Returns the JWT
+ * {@inheritDoc}
+ */
+ @Override //only for better/targeted JavaDoc
+ Claims setIssuer(String iss);
+
+ /**
+ * 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();
/**
- * Returns the JWT
+ * {@inheritDoc}
+ */
+ @Override //only for better/targeted JavaDoc
+ Claims setSubject(String sub);
+
+ /**
+ * Returns the JWT
* aud
(audience) value or {@code null} if not present.
*
* @return the JWT {@code aud} value or {@code null} if not present.
*/
- Setexp
(expiration) timestamp or {@code null} if not present.
*
* A JWT obtained after this timestamp should not be used.
@@ -109,7 +114,13 @@ Date getExpiration(); /** - * Returns the JWT + * {@inheritDoc} + */ + @Override //only for better/targeted JavaDoc + Claims setExpiration(Date exp); + + /** + * Returns the JWT *nbf
(not before) timestamp or {@code null} if not present.
*
* A JWT obtained before this timestamp should not be used.
@@ -119,7 +130,13 @@ Date getNotBefore(); /** - * Returns the JWT + * {@inheritDoc} + */ + @Override //only for better/targeted JavaDoc + Claims setNotBefore(Date nbf); + + /** + * 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.
@@ -129,7 +146,13 @@ Date getIssuedAt(); /** - * Returns the JWTs + * {@inheritDoc} + */ + @Override //only for better/targeted JavaDoc + Claims setIssuedAt(Date iat); + + /** + * 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 @@ -139,28 +162,30 @@ * * @return the JWT {@code jti} value or {@code null} if not present. */ - @Override - // just for JavaDoc specific to the JWT spec String getId(); /** - * Returns the JWTs claim ({@code claimName}) value as a {@code requiredType} instance, or {@code null} if not - * present. + * {@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. * *
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 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
+ * 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
* 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 Jwts.ZIP#DEF DEFLATE} and {@link Jwts.ZIP#GZIP GZIP} algorithms by default - you do not need to
+ * {@link CompressionCodecs#DEFLATE DEFLATE}
+ * and {@link CompressionCodecs#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 can implement
+ * However, if you want to use a compression algorithm other than {@code DEF} or {@code GZIP}, you must implement
* your own {@link CompressionCodecResolver} and specify that when
- * {@link io.jsonwebtoken.JwtBuilder#compressWith(io.jsonwebtoken.io.CompressionAlgorithm) building} and
- * {@link io.jsonwebtoken.JwtParserBuilder#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 Jwts.ZIP#DEF DEF} code is JWA standards-compliant. If you're concerned about compatibility, the {@link #DEFLATE DEFLATE} code is JWA standards-compliant. This is an immutable JSON map with convenient type-safe getters for JWT standard header parameter names. 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. Because this interface extends Because this interface extends {@code Map<String, Object>}, if you would like to add your own properties,
+ * you simply use map methods, for example: 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. Security It is easiest to create a {@code Header} instance by calling one of the
+ * {@link Jwts#header() JWTs.header()} factory methods. 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. The 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. 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. the type of the JWS payload, either a byte[] or a {@link Claims} instance.
+ * @param the type of the JWS body contents, either a String or a {@link Claims} instance.
+ *
* @since 0.1
*/
-public interface Jws 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.
+ * @param the type of the JWT body contents, either a String 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. Content Type Recommendation The payload* and claims* properties are mutually exclusive - only one of the two may be used. 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. Content Type Recommendation The payload and claims properties are mutually exclusive - only one of the two may be used. 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 This method will automatically remove any instead of this: if desired. 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 This method will automatically remove any instead of this: if desired. 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. 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: instead of this: if desired. A JWT obtained after this timestamp should not be used. This is a convenience wrapper for: 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: instead of this: if desired. A JWT obtained before this timestamp should not be used. This is a convenience wrapper for: 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: instead of this: if desired. The value is the timestamp when the JWT was created. This is a convenience wrapper for: 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: 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 wrapper for: 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: instead of this: if desired. 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}. 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: Recommended Signature Algorithm The recommended signature algorithm used with a given key is chosen based on the following: Notes: instead of this: if desired. 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. 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. 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}. 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, SecureDigestAlgorithm)}. 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
@@ -764,20 +402,21 @@
* {@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 with(HS256, myPassword)} - which is
+ * use raw password strings as the key argument - for example {@code signWith(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 all parties accessing the
+ * parse that JWS token. When using compression for JWS tokens, be sure that that all parties accessing the
* JWS token support compression for JWS. 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) claim. A {@code null} value will remove the property from the JSON Claims map.
+ * Sets the JWT
+ * iss
(issuer) value. A {@code null} value will remove the property from the JSON 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
- * iss
(issuer) claim. A {@code null} value will remove the property from the JSON Claims map.
+ * Sets the JWT
+ * sub
(subject) value. A {@code null} value will remove the property from the JSON 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
- * sub
(subject) claim. A {@code null} value will remove the property from the JSON Claims map.
+ * Sets the JWT
+ * aud
(audience) value. A {@code null} value will remove the property from the JSON 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);
/**
- * Configures the JWT
- * aud
(audience) Claim
- * set, quietly ignoring any null, empty, whitespace-only, or existing value already in the set.
+ * Sets the JWT
+ * exp
(expiration) timestamp. A {@code null} value will remove the property from the JSON map.
*
- *
- *
- * @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.
- *
* exp
(expiration) timestamp claim. A {@code null} value will remove the property from the
- * JSON Claims map.
+ * Sets the JWT
+ * nbf
(not before) timestamp. A {@code null} value will remove the property from the JSON map.
*
- * nbf
(not before) 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.
+ * Sets the JWT
+ * iat
(issued at) timestamp. A {@code null} value will remove the property from the JSON map.
*
- * iat
(issued at) 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.
+ * Sets the JWT
+ * jti
(JWT ID) value. A {@code null} value will remove the property from the JSON 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 -rca3e06f3b65d2880d69fd5278773c5c71e1ca3e7 -rb673aa90094faa6f77a76c311d738710d7cf323a
--- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/CompressionCodec.java (.../CompressionCodec.java) (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7)
+++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/CompressionCodec.java (.../CompressionCodec.java) (revision b673aa90094faa6f77a76c311d738710d7cf323a)
@@ -15,56 +15,41 @@
*/
package io.jsonwebtoken;
-import io.jsonwebtoken.io.CompressionAlgorithm;
-
/**
* Compresses and decompresses byte arrays according to a compression algorithm.
*
- * zip
header value.zip
header value.
+ * 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.
+ * @return the compression algorithm name to use as the JWT's {@code zip} header value.
*/
- @SuppressWarnings("DeprecatedIsStillUsed")
- @Deprecated
String getAlgorithmName();
/**
- * Compresses the specified byte array, returning the compressed byte array result.
+ * Compresses the specified byte array according to the compression {@link #getAlgorithmName() algorithm}.
*
- * @param content bytes to compress
+ * @param payload bytes to compress
* @return compressed bytes
- * @throws CompressionException if the specified byte array cannot be compressed.
+ * @throws CompressionException if the specified byte array cannot be compressed according to the compression
+ * {@link #getAlgorithmName() algorithm}.
*/
- @Deprecated
- byte[] compress(byte[] content) throws CompressionException;
+ byte[] compress(byte[] payload) throws CompressionException;
/**
- * Decompresses the specified compressed byte array, returning the decompressed byte array result. The
- * specified byte array must already be in compressed form.
+ * 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}.
*
* @param compressed compressed bytes
* @return decompressed bytes
- * @throws CompressionException if the specified byte array cannot be decompressed.
+ * @throws CompressionException if the specified byte array cannot be decompressed according to the compression
+ * {@link #getAlgorithmName() algorithm}.
*/
- @Deprecated
byte[] decompress(byte[] compressed) throws CompressionException;
-}
+}
\ No newline at end of file
Index: 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/CompressionCodecResolver.java
===================================================================
diff -u -rca3e06f3b65d2880d69fd5278773c5c71e1ca3e7 -rb673aa90094faa6f77a76c311d738710d7cf323a
--- 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/CompressionCodecResolver.java (.../CompressionCodecResolver.java) (revision ca3e06f3b65d2880d69fd5278773c5c71e1ca3e7)
+++ 3rdParty_sources/jsonwebtoken/io/jsonwebtoken/CompressionCodecResolver.java (.../CompressionCodecResolver.java) (revision b673aa90094faa6f77a76c311d738710d7cf323a)
@@ -20,21 +20,17 @@
* 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.get("someKey");
+ * header.{@link Map#put(Object, Object) put}("headerParamName", "headerParamValue");
+ *
*
- * Creation
*
- * "JWT"
- *
- * @deprecated since 0.12.0 - this constant is never used within the JJWT codebase.
- */
- @Deprecated
- String JWT_TYPE = "JWT";
+ /** JWT {@code Type} (typ) value: "JWT"
*/
+ public static final String JWT_TYPE = "JWT";
- /**
- * JWT {@code Type} header parameter name: "typ"
- * @deprecated since 0.12.0 in favor of {@link #getType()}.
- */
- @Deprecated
- String TYPE = "typ";
+ /** JWT {@code Type} header parameter name: "typ"
*/
+ public static final String TYPE = "typ";
- /**
- * 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 Content Type} header parameter name: "cty"
*/
+ public static final String CONTENT_TYPE = "cty";
- /**
- * 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";
+ /** JWT {@code Compression Algorithm} header parameter name: "zip"
*/
+ public static final String COMPRESSION_ALGORITHM = "zip";
- /**
- * JWT {@code Compression Algorithm} header parameter name: "zip"
- * @deprecated since 0.12.0 in favor of {@link #getCompressionAlgorithm()}
- */
+ /** JJWT legacy/deprecated compression algorithm header parameter name: "calg"
+ * @deprecated use {@link #COMPRESSION_ALGORITHM} instead. */
@Deprecated
- String COMPRESSION_ALGORITHM = "zip";
+ public static final String DEPRECATED_COMPRESSION_ALGORITHM = "calg";
/**
- * JJWT legacy/deprecated compression algorithm header parameter name: "calg"
+ * Returns the
+ * typ
(type) header value or {@code null} if not present.
*
- * @deprecated use {@link #COMPRESSION_ALGORITHM} instead.
+ * @return the {@code typ} header value or {@code null} if not present.
*/
- @Deprecated
- String DEPRECATED_COMPRESSION_ALGORITHM = "calg";
+ String getType();
/**
- * Returns the
- * typ
(Type) header value or {@code null} if not present.
+ * Sets the JWT
+ * typ
(Type) header value. A {@code null} value will remove the property from the JSON map.
*
- * @return the {@code typ} 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.
*/
- String getType();
+ T setType(String typ);
/**
- * 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.
*
- *
- *
+ * 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 parameter value or {@code null} if not present.
+ * Returns the JWT zip
(Compression Algorithm) header 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.
+ * alg
- *
- * @deprecated since 0.12.0 in favor of {@link #getAlgorithm()}
- */
- @Deprecated
- String ALGORITHM = "alg";
+ /** JWS {@code Algorithm} header parameter name: "alg"
*/
+ public static final String ALGORITHM = "alg";
- /**
- * 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 JWT Set URL} header parameter name: "jku"
*/
+ public static final String JWK_SET_URL = "jku";
- /**
- * 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 JSON Web Key} header parameter name: "jwk"
*/
+ public static final String JSON_WEB_KEY = "jwk";
- /**
- * 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 Key ID} header parameter name: "kid"
*/
+ public static final String KEY_ID = "kid";
- /**
- * 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 URL} header parameter name: "x5u"
*/
+ public static final String X509_URL = "x5u";
- /**
- * 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 Chain} header parameter name: "x5c"
*/
+ public static final 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";
+
/**
- * JWS X.509 Certificate SHA-1 Thumbprint Header name: the string literal x5t
+ * Returns the JWS
+ * alg
(algorithm) header value or {@code null} if not present.
*
- * @deprecated since 0.12.0 in favor of {@link #getX509Sha1Thumbprint()}
+ * x5t#S256
+ * Sets the JWT
+ * alg
(Algorithm) header value. A {@code null} value will remove the property from the JSON map.
*
- * @deprecated since 0.12.0 in favor of {@link #getX509Sha256Thumbprint()}
+ * crit
+ * Returns the JWS
+ * kid
(Key ID) header value or {@code null} if not present.
*
- * @deprecated since 0.12.0 in favor of {@link #getCritical()}
+ * kid
(Key ID) header value. A {@code null} value will remove the property from the JSON map.
*
- * @return {@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.
*/
- @SuppressWarnings("DeprecatedIsStillUsed")
- @Deprecated
- JwtBuilder setHeader(Map
+ * Applies the specified name/value pairs to the header. If a header does not yet exist at the time this method
+ * is called, one will be created automatically before applying the name/value pairs.
*
* @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.
*/
- @SuppressWarnings("DeprecatedIsStillUsed")
- @Deprecated
- JwtBuilder setHeaderParams(Map
+ * Applies the specified name/value pair to the header. If a header does not yet exist at the time this method
+ * is called, one will be created automatically before applying the name/value pair.
*
* @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);
/**
- * Since JJWT 0.12.0, this is an alias for {@link #content(String)}. This method will be removed
- * before the 1.0 release.
+ * 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.
*
- * @param payload the string used to set UTF-8-encoded bytes as the JWT payload.
+ *
+ *
- * {@link #content(byte[]) content}(payload.getBytes(StandardCharsets.UTF_8))
+ * Sets the JWT payload to be a JSON Claims instance populated by the specified name/value pairs. If you do not
+ * want the JWT body to be JSON and instead want it to be a plaintext string, use the {@link #setPayload(String)}
+ * method instead.
*
- *
- * {@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.
*
- *
+ *
- * {@link #content(String) content(content)}.{@link #header()}.{@link HeaderMutator#contentType(String) contentType(cty)}.{@link BuilderHeader#and() and()}
+ * String jwt = Jwts.builder().setIssuer("Joe").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:
+ * Claims claims = Jwts.claims().setIssuer("Joe");
+ * String jwt = Jwts.builder().setClaims(claims).compact();
+ *
+ *
- *
- *
- * 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.
*
- *
+ *
- * {@link #content(byte[]) content(content)}.{@link #header()}.{@link HeaderMutator#contentType(String) contentType(cty)}.{@link BuilderHeader#and() and()}
+ * String jwt = Jwts.builder().setSubject("Me").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"".
+ * Claims claims = Jwts.claims().setSubject("Me");
+ * String jwt = Jwts.builder().setClaims(claims).compact();
+ *
+ * /
' 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
+ * @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
*/
- JwtBuilder claim(String name, Object value);
+ @Override
+ //only for better/targeted JavaDoc
+ JwtBuilder setSubject(String sub);
/**
- * 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(Object, Object) add(name, value)}.{@link BuilderClaims#and() and()}
+ * Sets the JWT Claims
+ *
- * {@link #claims()}.{@link MapMutator#add(Map) add(claims)}.{@link BuilderClaims#and() and()}
aud
(audience) value. A {@code null} value will remove the property from the Claims.
*
- * iss
(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()}
+ * String jwt = Jwts.builder().setAudience("You").compact();
+ *
*
- * @param iss the JWT {@code iss} value or {@code null} to remove the property from the Claims map.
- * @return the builder instance for method chaining.
- */
- @Override
- // for better/targeted JavaDoc
- JwtBuilder issuer(String iss);
-
- /**
- * Sets the JWT Claims
- * sub
(subject) claim. A {@code null} value will remove the property from the Claims.
- * This is a convenience wrapper for:
- *
+ *
- * {@link #claims()}.{@link ClaimsMutator#subject(String) subject(sub)}.{@link BuilderClaims#and() and()}
+ * Claims claims = Jwts.claims().setAudience("You");
+ * String jwt = Jwts.builder().setClaims(claims).compact();
+ *
+ * exp
(expiration) claim. A {@code null} value will remove the property from the Claims.
+ * Sets the JWT Claims
+ * exp
(expiration) value. 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) claim. A {@code null} value will remove the property from the Claims.
+ * Sets the JWT Claims
+ * nbf
(not before) value. 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) claim. A {@code null} value will remove the property from the Claims.
+ * Sets the JWT Claims
+ * iat
(issued at) value. 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) claim. A {@code null} value will remove the property from the Claims.
+ * Sets the JWT Claims
+ * jti
(JWT ID) value. 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();
+ *
*
- *
- *
- *
- *
- *
- *
- * 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}
- *
- *
+ *
+ * Claims claims = Jwts.claims().put("aName", "aValue");
+ * String jwt = Jwts.builder().setClaims(claims).compact();
+ *
+ * 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.with(key); //or {@link #signWith(Key, SignatureAlgorithm)}
+ * jwtBuilder.signWith(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
*
- *