JwtHeader

Immutable representation of a JOSE header for a JWT, JWS, or JWE token.

The header is backed by a JsonObject and is also stored in its base64url-encoded form so that the compact serialization can be reproduced exactly. Standard parameters such as alg, enc, typ, cty, and kid are accessible via dedicated properties or helper functions; arbitrary custom parameters can be read with getHeader and getHeaderOrNull.

See also

Types

Link copied to clipboard
class Builder

Builder for constructing a JwtHeader with standard and extra parameters.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The algorithm (alg) header parameter identifying the cryptographic algorithm used.

Link copied to clipboard

Returns the cty (content type) header value.

Link copied to clipboard

Returns the cty (content type) header value, or null if the header is absent.

Link copied to clipboard

Returns the enc (encryption algorithm) header value.

Link copied to clipboard

Returns the enc (encryption algorithm) header value, or null if the header is absent.

Link copied to clipboard

Returns the kid (key ID) header value.

Link copied to clipboard

Returns the kid (key ID) header value, or null if the header is absent.

Link copied to clipboard

Returns the typ (token type) header value.

Link copied to clipboard

Returns the typ (token type) header value, or null if the header is absent.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
fun <T> getHeader(serializer: DeserializationStrategy<T>, name: String, jsonInstance: Json = Jwt.defaultJsonParser): T

Returns the value of the named header parameter deserialized using the given serializer.

Link copied to clipboard
inline fun <T> JwtHeader.getHeader(name: String, jsonInstance: Json = Jwt.defaultJsonParser): T

Returns the value of the named header, deserializing it to type T using a reified serializer.

Link copied to clipboard
fun <T> getHeaderOrNull(serializer: DeserializationStrategy<T>, name: String, jsonInstance: Json = Jwt.defaultJsonParser): T?

Returns the value of the named header parameter deserialized using the given serializer, or null if absent.

Link copied to clipboard
inline fun <T> JwtHeader.getHeaderOrNull(name: String, jsonInstance: Json = Jwt.defaultJsonParser): T?

Returns the value of the named header deserialized to type T, or null if the header is absent.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Returns true if a header parameter with the given name exists.

Link copied to clipboard
open override fun toString(): String