public interface Header<T extends Header<T>> extends Map<String,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.
Modifier and Type | Field and Description |
---|---|
static String |
COMPRESSION_ALGORITHM
JWT
Compression Algorithm header parameter name: "zip" |
static String |
CONTENT_TYPE
JWT
Content Type header parameter name: "cty" |
static String |
DEPRECATED_COMPRESSION_ALGORITHM
Deprecated.
use
COMPRESSION_ALGORITHM instead. |
static String |
JWT_TYPE
JWT
Type (typ) value: "JWT" |
static String |
TYPE
JWT
Type header parameter name: "typ" |
Modifier and Type | Method and Description |
---|---|
String |
getCompressionAlgorithm()
Returns the JWT
calg (Compression Algorithm) header value or null if not present. |
String |
getContentType()
Returns the
cty (Content Type) header value or null if not present. |
String |
getType()
Returns the
typ (type) header value or null if not present. |
T |
setCompressionAlgorithm(String calg)
Sets the JWT
calg (Compression Algorithm) header parameter value. |
T |
setContentType(String cty)
Sets the JWT
cty (Content Type) header parameter value. |
T |
setType(String typ)
Sets the JWT
typ (Type) header value. |
static final String JWT_TYPE
Type
(typ) value: "JWT"
static final String TYPE
Type
header parameter name: "typ"
static final String CONTENT_TYPE
Content Type
header parameter name: "cty"
static final String COMPRESSION_ALGORITHM
Compression Algorithm
header parameter name: "zip"
@Deprecated static final String DEPRECATED_COMPRESSION_ALGORITHM
COMPRESSION_ALGORITHM
instead."calg"
String getType()
typ
(type) header value or null
if not present.typ
header value or null
if not present.T setType(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.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(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.String getCompressionAlgorithm()
calg
(Compression Algorithm) header value or null
if not present.calg
header parameter value or null
if not present.T setCompressionAlgorithm(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.Copyright © 2018. All rights reserved.