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.
By default, only the AllowListDeserializingConverter.DEFAULT_ALLOWED_PATTERNS are allowed.
Use addAllowedPatterns(String...) to trust additional classes/packages,
or setAllowedPatterns(String...) to replace the defaults.
- Since:
- 2.0
- Author:
- Mark Fisher, Gary Russell, Artem Bilan, Uwez Khan, Hyun Lee, Glenn Renfro
-
Field Summary
Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
logger -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance which allows only theAllowListDeserializingConverter.DEFAULT_ALLOWED_PATTERNSfor deserialization. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllowedPatterns(String... allowedPatterns) Add package/class patterns to the allowed list, in addition to the existing ones (by default theAllowListDeserializingConverter.DEFAULT_ALLOWED_PATTERNS).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 org.springframework.http.converter.AbstractHttpMessageConverter
addDefaultHeaders, canRead, canRead, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, supportsRepeatableWrites, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.http.converter.HttpMessageConverter
canWriteRepeatedly, getSupportedMediaTypes
-
Constructor Details
-
SerializingHttpMessageConverter
public SerializingHttpMessageConverter()Create a new instance which allows only theAllowListDeserializingConverter.DEFAULT_ALLOWED_PATTERNSfor deserialization.
-
-
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. The provided patterns replace the existing ones, including theAllowListDeserializingConverter.DEFAULT_ALLOWED_PATTERNS. Primitives,Stringand arrays of allowed types are always allowed.- Parameters:
allowedPatterns- the patterns.- Since:
- 5.5.22
-
addAllowedPatterns
Add package/class patterns to the allowed list, in addition to the existing ones (by default theAllowListDeserializingConverter.DEFAULT_ALLOWED_PATTERNS).- Parameters:
allowedPatterns- the patterns to add.- Since:
- 5.5.22
-
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
-