public interface Header<T extends Header<T>>
extends java.util.Map<java.lang.String,java.lang.Object>
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 Map<String, Object>
, if you would like to add your own properties,
you simply use map methods, for example:
header.put
("headerParamName", "headerParamValue");
It is easiest to create a Header
instance by calling one of the
JWTs.header()
factory methods.
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
COMPRESSION_ALGORITHM
JWT
Compression Algorithm header parameter name: "zip" |
static java.lang.String |
CONTENT_TYPE
JWT
Content Type header parameter name: "cty" |
static java.lang.String |
DEPRECATED_COMPRESSION_ALGORITHM
已过时。
use
COMPRESSION_ALGORITHM instead. |
static java.lang.String |
JWT_TYPE
JWT
Type (typ) value: "JWT" |
static java.lang.String |
TYPE
JWT
Type header parameter name: "typ" |
限定符和类型 | 方法和说明 |
---|---|
java.lang.String |
getCompressionAlgorithm()
Returns the JWT
calg (Compression Algorithm) header value or null if not present. |
java.lang.String |
getContentType()
Returns the
cty (Content Type) header value or null if not present. |
java.lang.String |
getType()
Returns the
typ (type) header value or null if not present. |
T |
setCompressionAlgorithm(java.lang.String calg)
Sets the JWT
calg (Compression Algorithm) header parameter value. |
T |
setContentType(java.lang.String cty)
Sets the JWT
cty (Content Type) header parameter value. |
T |
setType(java.lang.String typ)
Sets the JWT
typ (Type) header value. |
static final java.lang.String JWT_TYPE
Type
(typ) value: "JWT"
static final java.lang.String TYPE
Type
header parameter name: "typ"
static final java.lang.String CONTENT_TYPE
Content Type
header parameter name: "cty"
static final java.lang.String COMPRESSION_ALGORITHM
Compression Algorithm
header parameter name: "zip"
@Deprecated static final java.lang.String DEPRECATED_COMPRESSION_ALGORITHM
COMPRESSION_ALGORITHM
instead."calg"
java.lang.String getType()
typ
(type) header value or null
if not present.typ
header value or null
if not present.T setType(java.lang.String typ)
typ
(Type) header value. A null
value will remove the property from the JSON map.typ
- the JWT JOSE typ
header value or null
to remove the property from the JSON map.Header
instance for method chaining.java.lang.String getContentType()
cty
(Content Type) header value or null
if not present.
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
JWT
, to indicate that a Nested JWT is carried in this JWT. While media type names are not
case-sensitive, it is RECOMMENDED that JWT
always be spelled using uppercase characters for
compatibility with legacy implementations. See
JWT Appendix A.2 for
an example of a Nested JWT.
typ
header parameter value or null
if not present.T setContentType(java.lang.String cty)
cty
(Content Type) header parameter value. A null
value will remove the property from
the JSON map.
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
JWT
, to indicate that a Nested JWT is carried in this JWT. While media type names are not
case-sensitive, it is RECOMMENDED that JWT
always be spelled using uppercase characters for
compatibility with legacy implementations. See
JWT Appendix A.2 for
an example of a Nested JWT.
cty
- the JWT JOSE cty
header value or null
to remove the property from the JSON map.java.lang.String getCompressionAlgorithm()
calg
(Compression Algorithm) header value or null
if not present.calg
header parameter value or null
if not present.T setCompressionAlgorithm(java.lang.String calg)
calg
(Compression Algorithm) header parameter value. A null
value will remove
the property from the JSON map.
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.
calg
- the JWT compression algorithm calg
value or null
to remove the property from the JSON map.