Class AllowListDeserializingConverter
java.lang.Object
org.springframework.integration.support.converter.AllowListDeserializingConverter
A
Converter that delegates to a
Deserializer to convert data in a byte
array to an object. By default, only the classes listed in DEFAULT_ALLOWED_PATTERNS
(plus primitives, String and arrays of any of these) are deserialized.
Use addAllowedPatterns(String...) to trust additional classes/packages,
or setAllowedPatterns(String...) to replace the defaults.
The "*" pattern allows all classes.
If a delegate deserializer is a DefaultDeserializer, only its ClassLoader
is used for a ConfigurableObjectInputStream logic.
- Since:
- 5.4
- Author:
- Gary Russell, Mark Fisher, Juergen Hoeller, Artem Bilan, Glenn Renfro
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe classes allowed for deserialization by default. -
Constructor Summary
ConstructorsConstructorDescriptionCreate aAllowListDeserializingConverterwith defaultObjectInputStreamconfiguration, using the "latest user-defined ClassLoader".AllowListDeserializingConverter(ClassLoader classLoader) AllowListDeserializingConverter(Deserializer<Object> deserializer) Create aAllowListDeserializingConverterthat delegates to the providedDeserializer. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllowedPatterns(String... patterns) Add package/class patterns to the allowed list, in addition to the existing ones (by default theDEFAULT_ALLOWED_PATTERNS).protected voidcheckAllowList(Class<?> clazz) convert(byte[] source) protected Objectdeserialize(ByteArrayInputStream inputStream) Return the current allowed patterns.voidsetAllowedPatterns(String... allowedPatterns) Set simple patterns for allowable packages/classes for deserialization.
-
Field Details
-
DEFAULT_ALLOWED_PATTERNS
-
-
Constructor Details
-
AllowListDeserializingConverter
public AllowListDeserializingConverter()Create aAllowListDeserializingConverterwith defaultObjectInputStreamconfiguration, using the "latest user-defined ClassLoader". -
AllowListDeserializingConverter
- Parameters:
classLoader- the class loader to use for deserialization.
-
AllowListDeserializingConverter
Create aAllowListDeserializingConverterthat delegates to the providedDeserializer.- Parameters:
deserializer- the deserializer to use.
-
-
Method Details
-
setAllowedPatterns
Set simple patterns for allowable packages/classes for deserialization. The patterns will be applied in order until a match is found. A class can be fully qualified, or a wildcard '*' is allowed at the beginning or end of the class name. Examples:com.example.*,*.MyClass. Replaces all the existing patterns, including theDEFAULT_ALLOWED_PATTERNS. UseaddAllowedPatterns(String...)to keep the defaults.- Parameters:
allowedPatterns- the patterns; must not be empty.
-
addAllowedPatterns
Add package/class patterns to the allowed list, in addition to the existing ones (by default theDEFAULT_ALLOWED_PATTERNS).- Parameters:
patterns- the patterns to add.- See Also:
-
getAllowedPatterns
-
convert
-
deserialize
- Throws:
IOException
-
checkAllowList
-