Class Jwt.FieldValidator

  • All Implemented Interfaces:
    Validator<Jwt>
    Enclosing class:
    Jwt

    public static final class Jwt.FieldValidator
    extends Object
    implements Validator<Jwt>
    Validator of a string field obtained from a JWT.
    • Method Detail

      • create

        public static Jwt.FieldValidator create​(Function<Jwt,​Optional<String>> fieldAccessor,
                                                String name,
                                                String expectedValue)
        A generic optional field validator based on a function to get the field.
        Parameters:
        fieldAccessor - function to extract field from JWT
        name - descriptive name of the field
        expectedValue - value to expect
        Returns:
        validator instance
      • create

        public static Jwt.FieldValidator create​(Function<Jwt,​Optional<String>> fieldAccessor,
                                                String name,
                                                String expectedValue,
                                                boolean mandatory)
        A generic field validator based on a function to get the field.
        Parameters:
        fieldAccessor - function to extract field from JWT
        name - descriptive name of the field
        expectedValue - value to expect
        mandatory - true for mandatory, false for optional
        Returns:
        validator instance
      • createForHeader

        public static Jwt.FieldValidator createForHeader​(String fieldKey,
                                                         String name,
                                                         String expectedValue)
        An optional header field validator.
        Parameters:
        fieldKey - name of the header claim
        name - descriptive name of the field
        expectedValue - value to expect
        Returns:
        validator instance
      • createForHeader

        public static Jwt.FieldValidator createForHeader​(String fieldKey,
                                                         String name,
                                                         String expectedValue,
                                                         boolean mandatory)
        A header field validator.
        Parameters:
        fieldKey - name of the header claim
        name - descriptive name of the field
        expectedValue - value to expect
        mandatory - whether the field is mandatory or optional
        Returns:
        validator instance
      • createForPayload

        public static Jwt.FieldValidator createForPayload​(String fieldKey,
                                                          String name,
                                                          String expectedValue)
        An optional payload field validator.
        Parameters:
        fieldKey - name of the payload claim
        name - descriptive name of the field
        expectedValue - value to expect
        Returns:
        validator instance
      • createForPayload

        public static Jwt.FieldValidator createForPayload​(String fieldKey,
                                                          String name,
                                                          String expectedValue,
                                                          boolean mandatory)
        A payload field validator.
        Parameters:
        fieldKey - name of the payload claim
        name - descriptive name of the field
        expectedValue - value to expect
        mandatory - whether the field is mandatory or optional
        Returns:
        validator instance