Class SerializingHttpMessageConverter
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<Serializable>
org.springframework.integration.http.converter.SerializingHttpMessageConverter
- All Implemented Interfaces:
HttpMessageConverter<Serializable>
An
HttpMessageConverter implementation for
Serializable instances.
Incoming requests are deserialized through an AllowListDeserializingConverter.
For backward compatibility no class restriction is applied by default; when this
converter is used to read requests from untrusted sources, configure an allowlist of
trusted classes/packages via setAllowedPatterns(String...) or
addAllowedPatterns(String...) to guard against unsafe Java deserialization.
- Since:
- 2.0
- Author:
- Mark Fisher, Gary Russell, Artem Bilan, Uwez Khan
-
Field Summary
Fields inherited from class AbstractHttpMessageConverter
logger -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of theSerializingHttpMessageConverter. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllowedPatterns(String... allowedPatterns) Add package/class patterns to the allowed list.booleanreadInternal(Class<? extends Serializable> clazz, HttpInputMessage inputMessage) voidsetAllowedPatterns(String... allowedPatterns) Set simple patterns for allowable packages/classes for deserialization.booleanprotected voidwriteInternal(Serializable object, HttpOutputMessage outputMessage) Methods inherited from class AbstractHttpMessageConverter
addDefaultHeaders, canRead, canRead, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, supportsRepeatableWrites, writeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HttpMessageConverter
canWriteRepeatedly, getSupportedMediaTypes
-
Constructor Details
-
SerializingHttpMessageConverter
public SerializingHttpMessageConverter()Creates a new instance of theSerializingHttpMessageConverter.
-
-
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.foo.*,*.MyClass. The basic types (String,Number, arrays and primitives) are always allowed. When no patterns are configured, all classes are deserialized (the previous, unrestricted behavior).- Parameters:
allowedPatterns- the patterns.- Since:
- 5.5.22
-
addAllowedPatterns
Add package/class patterns to the allowed list.- Parameters:
allowedPatterns- the patterns to add.- Since:
- 5.5.22
- See Also:
-
supports
- Specified by:
supportsin classAbstractHttpMessageConverter<Serializable>
-
canWrite
- Specified by:
canWritein interfaceHttpMessageConverter<Serializable>- Overrides:
canWritein classAbstractHttpMessageConverter<Serializable>
-
readInternal
public Serializable readInternal(Class<? extends Serializable> clazz, HttpInputMessage inputMessage) throws IOException - Specified by:
readInternalin classAbstractHttpMessageConverter<Serializable>- Throws:
IOException
-
writeInternal
protected void writeInternal(Serializable object, HttpOutputMessage outputMessage) throws IOException - Specified by:
writeInternalin classAbstractHttpMessageConverter<Serializable>- Throws:
IOException
-