Class AllowListDeserializingConverter

java.lang.Object
org.springframework.integration.support.converter.AllowListDeserializingConverter
All Implemented Interfaces:
Converter<byte[],Object>

public class AllowListDeserializingConverter extends Object implements Converter<byte[],Object>
A Converter that delegates to a Deserializer to convert data in a byte array to an object. By default, if using a DefaultDeserializer all classes/packages are deserialized. If you receive data from untrusted sources, consider adding trusted classes/packages using setAllowedPatterns(String...) or addAllowedPatterns(String...).

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
  • Constructor Details

  • Method Details

    • setAllowedPatterns

      public void setAllowedPatterns(String... allowedPatterns)
      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.foo.*, *.MyClass.
      Parameters:
      allowedPatterns - the patterns.
    • addAllowedPatterns

      public void addAllowedPatterns(String... patterns)
      Add package/class patterns to the allowed list.
      Parameters:
      patterns - the patterns to add.
      See Also:
    • convert

      public Object convert(byte[] source)
      Specified by:
      convert in interface Converter<byte[],Object>
    • deserialize

      protected Object deserialize(ByteArrayInputStream inputStream) throws IOException
      Throws:
      IOException
    • checkAllowList

      protected void checkAllowList(Class<?> clazz)