Class Constraints


  • public final class Constraints
    extends Object
    Constraints defined for JWT validation. Constraint evaluation results in a promise of a Result.
    • Method Detail

      • isEqualTo

        public static <T> JwtClaimConstraint<T> isEqualTo​(T expected)
        Returns empty if the value is equal to the one expected and fulfill the Violation 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 a Violation corresponding to this constraint.
      • contains

        public static <T> JwtClaimConstraint<Collection<T>> contains​(T expected)
        Returns empty 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 a Violation corresponding to this constraint.
      • containsOnly

        public static <T> JwtClaimConstraint<Collection<T>> containsOnly​(T expected)
        Returns empty 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 a Violation corresponding to this constraint.
      • isNotNull

        public static JwtClaimConstraint<JsonValue> isNotNull()
        Returns empty if the value is present.
        Returns:
        empty if the value is present in the list or a Violation corresponding to this constraint.
      • hasClaims

        public static JwtConstraint hasClaims()
        Returns empty if the JWT does contain claims.
        Returns:
        empty if the JWT does contain claims or a Violation corresponding to this constraint.
      • hasValidSignature

        public static JwtConstraint hasValidSignature​(JwsSignatureVerifier verifier)
        Validates the signature of this SignedJwt.
        Parameters:
        verifier - The JwsSignatureVerifier used to verify the signature.
        Returns:
        empty if the JWT has a valid signature or a Violation corresponding to this constraint.