ClaimAccessor mixin

Typed reading of a claim map: text, booleans, lists and times.

The ID token, the user info and the OIDC user mix it in; read claims of your own with the same getters:

final tenant = user.getClaimAsString('tenant');
final groups = user.getClaimAsStringList('groups') ?? const [];

Spring (Java): ClaimAccessor.

Properties

claims → Map<String, Object?>
The claims, by name; cannot be modified.
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

getClaimAsBoolean(String name) → bool?
The claim name as a boolean: true / false or the strings "true" / "false"; null when absent or anything else.
getClaimAsInstant(String name) → DateTime?
The claim name as a time: seconds since 1970 (a NumericDate), in UTC; null when absent or not a number.
getClaimAsMap(String name) → Map<String, Object?>?
The claim name as a JSON object; null when absent or not an object.
getClaimAsString(String name) → String?
The claim name as text (toString() of a number); null when absent.
getClaimAsStringList(String name) → List<String>?
The claim name as a list of text: a single string gives a list of one; null when absent.
hasClaim(String name) → bool
Whether the claim name is present (even with a null value).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited