org.keycloak.validate.validators

## Class UriValidator

- java.lang.Object
- - org.keycloak.validate.validators.UriValidator

- All Implemented Interfaces:
    ConfiguredProvider, Provider, ProviderFactory<Validator>, SimpleValidator, Validator, ValidatorFactory

      public class UriValidator
      extends Object
      implements SimpleValidator, ConfiguredProvider

  URI validation - accepts `URI`, `URL` and single String. Null input is valid, use other validators (like `NotBlankValidator` or `NotEmptyValidator` to force field as required.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `DEFAULT_ALLOW_FRAGMENT`
    `static Set<String>` | `DEFAULT_ALLOWED_SCHEMES`
    `static boolean` | `DEFAULT_REQUIRE_VALID_URL`
    `static String` | `ID`
    `static UriValidator` | `INSTANCE`
    `static String` | `KEY_ALLOW_FRAGMENT`
    `static String` | `KEY_ALLOWED_SCHEMES`
    `static String` | `KEY_REQUIRE_VALID_URL`
    `static String` | `MESSAGE_INVALID_FRAGMENT`
    `static String` | `MESSAGE_INVALID_SCHEME`
    `static String` | `MESSAGE_INVALID_URI`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UriValidator()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<ProviderConfigProperty>` | `getConfigProperties()`
    `String` | `getHelpText()`
    `String` | `getId()`
    `ValidationContext` | `validate(Object input, String inputHint, ValidationContext context, ValidatorConfig config)` Validates the given `input` with an additional `inputHint` and `config`.
    `boolean` | `validateUri(URI uri, Set<String> allowedSchemes, boolean allowFragment, boolean requireValidUrl)`
    `boolean` | `validateUri(URI uri, String inputHint, ValidationContext context, Set<String> allowedSchemes, boolean allowFragment, boolean requireValidUrl)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.keycloak.validate.SimpleValidator

      `close, create, init, postInit`

    - ### Methods inherited from interface org.keycloak.validate.Validator

      `validate, validate, validate, validate, validate, validate`

    - ### Methods inherited from interface org.keycloak.validate.ValidatorFactory

      `validateConfig`

    - ### Methods inherited from interface org.keycloak.provider.ProviderFactory

      `order`

- - ### Field Detail

    - #### INSTANCE

          public static final UriValidator INSTANCE

    - #### KEY_ALLOWED_SCHEMES

          public static final String KEY_ALLOWED_SCHEMES

      See Also:
        Constant Field Values

    - #### KEY_ALLOW_FRAGMENT

          public static final String KEY_ALLOW_FRAGMENT

      See Also:
        Constant Field Values

    - #### KEY_REQUIRE_VALID_URL

          public static final String KEY_REQUIRE_VALID_URL

      See Also:
        Constant Field Values

    - #### DEFAULT_ALLOWED_SCHEMES

          public static final Set<String> DEFAULT_ALLOWED_SCHEMES

    - #### MESSAGE_INVALID_URI

          public static final String MESSAGE_INVALID_URI

      See Also:
        Constant Field Values

    - #### MESSAGE_INVALID_SCHEME

          public static final String MESSAGE_INVALID_SCHEME

      See Also:
        Constant Field Values

    - #### MESSAGE_INVALID_FRAGMENT

          public static final String MESSAGE_INVALID_FRAGMENT

      See Also:
        Constant Field Values

    - #### DEFAULT_ALLOW_FRAGMENT

          public static boolean DEFAULT_ALLOW_FRAGMENT

    - #### DEFAULT_REQUIRE_VALID_URL

          public static boolean DEFAULT_REQUIRE_VALID_URL

    - #### ID

          public static final String ID

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### UriValidator

          public UriValidator()

  - ### Method Detail

    - #### getId

          public String getId()

      Specified by:
        `getId` in interface `ProviderFactory<Validator>`

    - #### validate

          public ValidationContext validate(Object input,
                                            String inputHint,
                                            ValidationContext context,
                                            ValidatorConfig config)

      Description copied from interface: `Validator`
      Validates the given `input` with an additional `inputHint` and `config`.
      Specified by:
        `validate` in interface `Validator`
      Parameters:
        `input` - the value to validate
        `inputHint` - an optional input hint to guide the validation
        `context` - the validation context
        `config` - parameterization for the current validation
      Returns:
        the validation context with the outcome of the validation

    - #### validateUri

          public boolean validateUri(URI uri,
                                     Set<String> allowedSchemes,
                                     boolean allowFragment,
                                     boolean requireValidUrl)

    - #### validateUri

          public boolean validateUri(URI uri,
                                     String inputHint,
                                     ValidationContext context,
                                     Set<String> allowedSchemes,
                                     boolean allowFragment,
                                     boolean requireValidUrl)
                              throws MalformedURLException

      Throws:
        `MalformedURLException`

    - #### getHelpText

          public String getHelpText()

      Specified by:
        `getHelpText` in interface `ConfiguredProvider`

    - #### getConfigProperties

          public List<ProviderConfigProperty> getConfigProperties()

      Specified by:
        `getConfigProperties` in interface `ConfiguredProvider`

Copyright © 2021 JBoss by Red Hat. All rights reserved.