Package org.keycloak.validate.validators
Class UriValidator
java.lang.Object
org.keycloak.validate.AbstractSimpleValidator
org.keycloak.validate.validators.UriValidator
- All Implemented Interfaces:
ConfiguredProvider
,Provider
,ProviderFactory<Validator>
,SimpleValidator
,Validator
,ValidatorFactory
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
Modifier and TypeFieldDescriptionstatic final boolean
static final boolean
static final String
static final UriValidator
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class org.keycloak.validate.AbstractSimpleValidator
IGNORE_EMPTY_VALUE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doValidate
(Object input, String inputHint, ValidationContext context, ValidatorConfig config) Validate type, format, range of the value etc.getId()
protected boolean
skipValidation
(Object value, ValidatorConfig config) Decide if validation of individual value should be skipped or not.boolean
validateUri
(URI uri, String inputHint, ValidationContext context, Set<String> allowedSchemes, boolean allowFragment, boolean requireValidUrl) boolean
validateUri
(URI uri, Set<String> allowedSchemes, boolean allowFragment, boolean requireValidUrl) Methods inherited from class org.keycloak.validate.AbstractSimpleValidator
isIgnoreEmptyValuesConfigured, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.keycloak.provider.ConfiguredProvider
getConfig
Methods inherited from interface org.keycloak.provider.ProviderFactory
getConfigMetadata, order
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
Methods inherited from interface org.keycloak.validate.ValidatorFactory
validateConfig
-
Field Details
-
INSTANCE
-
KEY_ALLOWED_SCHEMES
- See Also:
-
KEY_ALLOW_FRAGMENT
- See Also:
-
KEY_REQUIRE_VALID_URL
- See Also:
-
DEFAULT_ALLOWED_SCHEMES
-
MESSAGE_INVALID_URI
- See Also:
-
MESSAGE_INVALID_SCHEME
- See Also:
-
MESSAGE_INVALID_FRAGMENT
- See Also:
-
DEFAULT_ALLOW_FRAGMENT
public static final boolean DEFAULT_ALLOW_FRAGMENT- See Also:
-
DEFAULT_REQUIRE_VALID_URL
public static final boolean DEFAULT_REQUIRE_VALID_URL- See Also:
-
ID
- See Also:
-
-
Constructor Details
-
UriValidator
public UriValidator()
-
-
Method Details
-
getId
- Specified by:
getId
in interfaceProviderFactory<Validator>
-
skipValidation
Description copied from class:AbstractSimpleValidator
Decide if validation of individual value should be skipped or not. It should be controlled byAbstractSimpleValidator.IGNORE_EMPTY_VALUE
configuration option, seeAbstractSimpleValidator.isIgnoreEmptyValuesConfigured(ValidatorConfig)
.- Specified by:
skipValidation
in classAbstractSimpleValidator
- Parameters:
value
- currently validated we make decision forconfig
- to look for options in- Returns:
- true if validation should be skipped for this value -
AbstractSimpleValidator.doValidate(Object, String, ValidationContext, ValidatorConfig)
is not called in this case. - See Also:
-
doValidate
protected void doValidate(Object input, String inputHint, ValidationContext context, ValidatorConfig config) Description copied from class:AbstractSimpleValidator
Validate type, format, range of the value etc. Always useValidationContext.addError(ValidationError)
to report error to the user! Can be called multiple time for one validation if input is Collection.- Specified by:
doValidate
in classAbstractSimpleValidator
- Parameters:
input
- to be validated, never nullcontext
- for the validation. Add errors into it.config
- of the validation if provided- See Also:
-
validateUri
-
validateUri
public boolean validateUri(URI uri, String inputHint, ValidationContext context, Set<String> allowedSchemes, boolean allowFragment, boolean requireValidUrl) throws MalformedURLException - Throws:
MalformedURLException
-
getHelpText
- Specified by:
getHelpText
in interfaceConfiguredProvider
-
getConfigProperties
- Specified by:
getConfigProperties
in interfaceConfiguredProvider
-