JwtPayload

Immutable representation of a JWT payload (claims set) as defined in RFC 7519.

The payload is backed by a JsonObject and also stored in its base64url-encoded form so that the compact serialization can be reproduced exactly. Registered claim names (e.g. iss, sub, aud, exp) are accessible through named properties on Builder; arbitrary custom claims can be read with getClaim and getClaimOrNull.

See also

Types

Link copied to clipboard
class Builder

Builder for constructing a JwtPayload with standard and custom claims.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Returns the aud (audience) claim value as a set of strings.

Link copied to clipboard

Returns the aud (audience) claim value as a set of strings, or null if the claim is absent.

Link copied to clipboard

Returns the exp (expiration time) claim value as an Instant.

Link copied to clipboard

Returns the exp (expiration time) claim value as an Instant, or null if the claim is absent.

Link copied to clipboard

Returns the iat (issued at) claim value as an Instant.

Link copied to clipboard

Returns the iat (issued at) claim value as an Instant, or null if the claim is absent.

Link copied to clipboard

Returns the iss (issuer) claim value.

Link copied to clipboard

Returns the iss (issuer) claim value, or null if the claim is absent.

Link copied to clipboard

Returns the jti (JWT ID) claim value.

Link copied to clipboard

Returns the jti (JWT ID) claim value, or null if the claim is absent.

Link copied to clipboard

Returns the nbf (not before) claim value as an Instant.

Link copied to clipboard

Returns the nbf (not before) claim value as an Instant, or null if the claim is absent.

Link copied to clipboard

Returns the sub (subject) claim value.

Link copied to clipboard

Returns the sub (subject) claim value, or null if the claim is absent.

Functions

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

Returns the value of the named claim, deserialized using the given serializer.

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

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

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

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

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

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

Link copied to clipboard
fun hasClaim(name: String): Boolean

Returns true if a claim with the given name exists in the payload.

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