Module tools.jackson.databind
Class ApprovedBaseTypeValidator
java.lang.Object
tools.jackson.databind.jsontype.PolymorphicTypeValidator
tools.jackson.databind.jsontype.PolymorphicTypeValidator.Base
tools.jackson.databind.jsontype.impl.ApprovedBaseTypeValidator
- All Implemented Interfaces:
Serializable
PolymorphicTypeValidator used when the configured validator has approved
all subtypes of a polymorphic base type (by returning
PolymorphicTypeValidator.Validity.ALLOWED from validateBaseType(tools.jackson.databind.DatabindContext, tools.jackson.databind.JavaType)).
Like LaissezFaireSubTypeValidator it allows all subtypes of that base type,
but retains the configured validator so that classes named as type parameters
of a generic type id (like "java.util.HashMap<a.b.Gadget,java.lang.String>")
can still be validated: approval of the base type does not extend to them.- Since:
- 3.1.8
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.jsontype.PolymorphicTypeValidator
PolymorphicTypeValidator.Base, PolymorphicTypeValidator.Validity -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAccessor for the configured validator, to use for validating type parameters of generic type ids.validateBaseType(DatabindContext ctxt, JavaType baseType) Method called when a property with polymorphic value is encountered, and aTypeResolverBuilderis needed.validateSubClassName(DatabindContext ctxt, JavaType baseType, String subClassName) validateSubType(DatabindContext ctxt, JavaType baseType, JavaType subType) Method called after class name has been resolved to actual type, in cases where previous call toPolymorphicTypeValidator.validateSubClassName(tools.jackson.databind.DatabindContext, tools.jackson.databind.JavaType, java.lang.String)returnedPolymorphicTypeValidator.Validity.INDETERMINATE.Methods inherited from class tools.jackson.databind.jsontype.PolymorphicTypeValidator
isArrayTypeAllowedExplicitly
-
Constructor Details
-
ApprovedBaseTypeValidator
-
-
Method Details
-
getTypeParameterValidator
Accessor for the configured validator, to use for validating type parameters of generic type ids. -
validateBaseType
Description copied from class:PolymorphicTypeValidatorMethod called when a property with polymorphic value is encountered, and aTypeResolverBuilderis needed. Intent is to allow early determination of cases where subtyping is completely denied (for example for security reasons), or, conversely, allowed for allow subtypes (when base type guarantees that all subtypes are known to be safe). Check can be thought of as both optimization (for latter case) and eager-fail (for former case) to give better feedback.- Overrides:
validateBaseTypein classPolymorphicTypeValidator.Base- Parameters:
ctxt- Context for resolution: typically will beDeserializationContextbaseType- Nominal base type used for polymorphic handling: subtypes MUST be instances of this type and assignment compatibility is verified by Jackson core- Returns:
- Determination of general validity of all subtypes of given base type; if
PolymorphicTypeValidator.Validity.ALLOWEDreturned, all subtypes will automatically be accepted without further checks; isPolymorphicTypeValidator.Validity.DENIEDreturned no subtyping allowed at all (caller will usually throw an exception); otherwise (returnPolymorphicTypeValidator.Validity.INDETERMINATE) per sub-type validation calls are made for each new subclass encountered.
-
validateSubClassName
public PolymorphicTypeValidator.Validity validateSubClassName(DatabindContext ctxt, JavaType baseType, String subClassName) Description copied from class:PolymorphicTypeValidatorMethod called after intended class name for subtype has been read (and in case of minimal class name, expanded to fully-qualified class name) but before attempt is made to look up actualClassorJavaType. Validator may be able to determine validity of eventual type (and returnPolymorphicTypeValidator.Validity.ALLOWEDorPolymorphicTypeValidator.Validity.DENIED) or, if not able to, can defer validation to actual resolved type by returningPolymorphicTypeValidator.Validity.INDETERMINATE.Validator may also choose to indicate denial by throwing a
DatabindException(such asInvalidTypeIdException)- Overrides:
validateSubClassNamein classPolymorphicTypeValidator.Base- Parameters:
ctxt- Context for resolution: typically will beDeserializationContextbaseType- Nominal base type used for polymorphic handling: subtypes MUST be instances of this type and assignment compatibility is verified by Jackson coresubClassName- Name of class that will be resolved toClassif (and only if) validity check is not denied.- Returns:
- Determination of validity of given class name, as a subtype of given base type:
should NOT return
null
-
validateSubType
public PolymorphicTypeValidator.Validity validateSubType(DatabindContext ctxt, JavaType baseType, JavaType subType) Description copied from class:PolymorphicTypeValidatorMethod called after class name has been resolved to actual type, in cases where previous call toPolymorphicTypeValidator.validateSubClassName(tools.jackson.databind.DatabindContext, tools.jackson.databind.JavaType, java.lang.String)returnedPolymorphicTypeValidator.Validity.INDETERMINATE. Validator should be able to determine validity and return appropriatePolymorphicTypeValidator.Validityvalue, although it may alsoValidator may also choose to indicate denial by throwing a
DatabindException(such asInvalidTypeIdException)- Overrides:
validateSubTypein classPolymorphicTypeValidator.Base- Parameters:
ctxt- Context for resolution: typically will beDeserializationContextbaseType- Nominal base type used for polymorphic handling: subtypes MUST be instances of this type and assignment compatibility has been verified by Jackson coresubType- Resolved subtype to validate- Returns:
- Determination of validity of given class name, as a subtype of given base type:
should NOT return
null
-