Class ServerCustomFieldSerializer<T>
- Type Parameters:
T
- the type of the object being serialized
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
deserializeInstance
(com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader streamReader, T instance, Type[] expectedParameterTypes, com.google.gwt.user.server.rpc.impl.DequeMap<TypeVariable<?>, Type> resolvedTypes) Deserializes the content of the object from theServerSerializationStreamReader
, with type checking.instantiateInstance
(com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader streamReader) Instantiates an object from theServerSerializationStreamReader
, without type checking.instantiateInstance
(com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader streamReader, Type[] expectedParameterTypes, com.google.gwt.user.server.rpc.impl.DequeMap<TypeVariable<?>, Type> resolvedTypes) Instantiates an object from theServerSerializationStreamReader
, with type checking.Methods inherited from class com.google.gwt.user.client.rpc.CustomFieldSerializer
deserializeInstance, hasCustomInstantiateInstance, instantiateInstance, serializeInstance
-
Constructor Details
-
ServerCustomFieldSerializer
public ServerCustomFieldSerializer()
-
-
Method Details
-
deserializeInstance
public abstract void deserializeInstance(com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader streamReader, T instance, Type[] expectedParameterTypes, com.google.gwt.user.server.rpc.impl.DequeMap<TypeVariable<?>, Type> resolvedTypes) throws SerializationExceptionDeserializes the content of the object from theServerSerializationStreamReader
, with type checking. The calling code has verified that the instance this method is deserializing is of the correct type for the RPC call. However, is has not verified the objects that this deserializer will read. It is this method's responsibility to verify the types of objects that it reads. Failure to do so leaves the server vulnerable to an attacker who replaces deserialized data in the RPC message with data that takes an exponential time to deserialize or otherwise causes problems. In practice, any call to ServerSerilizationStreamReader.readObject() should use the type checking version, passing in the expected type of the object to be read. For classes that deserialize objects of generic types, the expectedParameterTypes array provides the type bound to each type generic parameter defined by the instance. See the built-in GWT server custom field serializers for examples.- Parameters:
streamReader
- theServerSerializationStreamReader
to read the object's content frominstance
- the object instance to deserializeexpectedParameterTypes
- the types we expect for any generic parameters used by this class, in the order in which they appear in the instance.getTypeParameters()resolvedTypes
- map from generic types to actual types- Throws:
SerializationException
- if the deserialization operation is not successful
-
instantiateInstance
public T instantiateInstance(com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader streamReader) throws SerializationException Instantiates an object from theServerSerializationStreamReader
, without type checking.- Parameters:
streamReader
- theServerSerializationStreamReader
to read the object's content from- Returns:
- an object that has been loaded from the
ServerSerializationStreamReader
- Throws:
SerializationException
- if the instantiation operation is not successful
-
instantiateInstance
public T instantiateInstance(com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader streamReader, Type[] expectedParameterTypes, com.google.gwt.user.server.rpc.impl.DequeMap<TypeVariable<?>, Type> resolvedTypes) throws SerializationExceptionInstantiates an object from theServerSerializationStreamReader
, with type checking.Most of the time, this can be left unimplemented and the framework will instantiate the instance itself. This is typically used when the object being deserialized is immutable, hence it has to be created with its state already set.
If this is overridden, the
CustomFieldSerializer.hasCustomInstantiateInstance()
method must returntrue
in order for the framework to know to call it. The calling code has verified that the instance this method is instantiating is of the correct type for the RPC call. However, is has not verified the objects that this instantiator will read. It is this method's responsibility to verify the types of objects that it reads. Failure to do so leaves the server vulnerable to an attacker who replaces deserialized data in the RPC message with data that takes an exponential time to instantiate or otherwise causes problems. In practice, any call to ServerSerilizationStreamReader.readObject() should use the type checking version, passing in the expected type of the object to be read. For classes that instantiate objects of generic types, the expectedParameterTypes array provides the type bound to each type generic parameter defined by the instance. See the built-in GWT server custom field serializers for examples.- Parameters:
streamReader
- theServerSerializationStreamReader
to read the object's content fromexpectedParameterTypes
- the types we expect for any generic parameters used by this class, in the order returned by instance.getTypeParameters()resolvedTypes
- map from generic types to actual types- Returns:
- an object that has been loaded from the
ServerSerializationStreamReader
- Throws:
SerializationException
- if the instantiation operation is not successful
-