Package org.forgerock.openig.tools.jwt
Class Constraints
- java.lang.Object
-
- org.forgerock.openig.tools.jwt.Constraints
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> JwtClaimConstraint<Collection<T>>
contains(T expected)
Returnsempty
if the list contains the expected value.static <T> JwtClaimConstraint<Collection<T>>
containsOnly(T expected)
Returnsempty
if the list contains only the expected value.static JwtConstraint
hasClaims()
Returnsempty
if the JWT does contain claims.static JwtConstraint
hasValidSignature(JwsSignatureVerifier verifier)
Validates the signature of thisSignedJwt
.static <T> JwtClaimConstraint<T>
isEqualTo(T expected)
Returnsempty
if the value is equal to the one expected and fulfill theViolation
with the custom error message.static JwtClaimConstraint<Instant>
isInTheFuture()
Returns aJwtClaimConstraint
that will succeed if the timestamp is after the given date, otherwise it will fail.static JwtClaimConstraint<Instant>
isInThePast()
Returns aJwtClaimConstraint
that will succeed if the timestamp is before the given date, otherwise it will fail.static JwtClaimConstraint<JsonValue>
isNotNull()
Returnsempty
if the value is present.
-
-
-
Method Detail
-
isEqualTo
public static <T> JwtClaimConstraint<T> isEqualTo(T expected)
Returnsempty
if the value is equal to the one expected and fulfill theViolation
with the custom error message.- Type Parameters:
T
- The type on which the constraint applies.- Parameters:
expected
- The expected value.- Returns:
empty
if the value is equal to the one expected or aViolation
corresponding to this constraint.
-
contains
public static <T> JwtClaimConstraint<Collection<T>> contains(T expected)
Returnsempty
if the list contains the expected value.- Type Parameters:
T
- The type on which the constraint applies.- Parameters:
expected
- The expected value.- Returns:
empty
if the value is contained in the list or aViolation
corresponding to this constraint.
-
containsOnly
public static <T> JwtClaimConstraint<Collection<T>> containsOnly(T expected)
Returnsempty
if the list contains only the expected value.- Type Parameters:
T
- The type on which the constraint applies.- Parameters:
expected
- The expected value.- Returns:
empty
if the value is contained in the singletonlist or aViolation
corresponding to this constraint.
-
isInTheFuture
public static JwtClaimConstraint<Instant> isInTheFuture()
Returns aJwtClaimConstraint
that will succeed if the timestamp is after the given date, otherwise it will fail. This method uses the skew allowance hold by theJwtValidationContext
.- Returns:
- a
JwtClaimConstraint
that will succeed if the timestamp is after the given date, otherwise it will fail.
-
isInThePast
public static JwtClaimConstraint<Instant> isInThePast()
Returns aJwtClaimConstraint
that will succeed if the timestamp is before the given date, otherwise it will fail. This method uses the skew allowance hold by theJwtValidationContext
.- Returns:
- a
JwtClaimConstraint
that will succeed if the timestamp is before the given date, otherwise it will fail.
-
isNotNull
public static JwtClaimConstraint<JsonValue> isNotNull()
Returnsempty
if the value is present.- Returns:
empty
if the value is present in the list or aViolation
corresponding to this constraint.
-
hasClaims
public static JwtConstraint hasClaims()
Returnsempty
if the JWT does contain claims.- Returns:
empty
if the JWT does contain claims or aViolation
corresponding to this constraint.
-
hasValidSignature
public static JwtConstraint hasValidSignature(JwsSignatureVerifier verifier)
Validates the signature of thisSignedJwt
.- Parameters:
verifier
- TheJwsSignatureVerifier
used to verify the signature.- Returns:
empty
if the JWT has a valid signature or aViolation
corresponding to this constraint.
-
-