|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.representation.Variant
org.restlet.representation.RepresentationInfo
org.restlet.representation.Representation
org.restlet.representation.CharacterRepresentation
org.restlet.representation.WriterRepresentation
org.restlet.ext.xstream.XstreamRepresentation<T>
T
- The type to wrap.public class XstreamRepresentation<T>
Representation based on the XStream library. It can serialize and deserialize
automatically in XML. It also supports a bridge to JSON leveraging the
Jettison library.
SECURITY WARNING: XStream applies various techniques under the hood to ensure
it is able to handle all types of objects. This includes using undocumented
Java features and reflection. The XML generated by XStream includes all
information required to build objects of almost any type. This introduces a
potential security problem.
The XML provided to XStream for conversion to a Java object can be
manipulated to inject objects into the unmarshalled object graph, which were
not present at marshalling time. An attacker could exploit this to execute
arbitrary code or shell commands in the context of the server running the
XStream process.
You can configure the Xstream object used by this representation (cf
#createXstream()
or getXstream()
) and apply security
permissions. You can find more documentation about the security fix and how
to configure the XStream object from here: XStream security enhancements.
Field Summary |
---|
Fields inherited from class org.restlet.representation.Representation |
---|
UNKNOWN_SIZE |
Constructor Summary | |
---|---|
XstreamRepresentation(MediaType mediaType,
T object)
Constructor. |
|
XstreamRepresentation(Representation representation,
Class<T> targetClass)
Constructor. |
|
XstreamRepresentation(T object)
Constructor. |
Method Summary | |
---|---|
protected XStream |
createXstream(MediaType mediaType)
Creates an XStream object based on a media type. |
Class<? extends HierarchicalStreamDriver> |
getJsonDriverClass()
Returns the XStream JSON driver class. |
T |
getObject()
Returns the wrapped object, deserializing the representation with XStream if necessary. |
Class<? extends HierarchicalStreamDriver> |
getXmlDriverClass()
Returns the XStream XML driver class. |
XStream |
getXstream()
Returns the modifiable XStream object. |
void |
setJsonDriverClass(Class<? extends HierarchicalStreamDriver> jsonDriverClass)
Sets the XStream JSON driver class. |
void |
setXmlDriverClass(Class<? extends HierarchicalStreamDriver> xmlDriverClass)
Sets the XStream XML driver class. |
void |
setXstream(XStream xstream)
Sets the XStream object. |
void |
write(Writer writer)
|
Methods inherited from class org.restlet.representation.WriterRepresentation |
---|
getReader |
Methods inherited from class org.restlet.representation.CharacterRepresentation |
---|
getChannel, getStream, write, write |
Methods inherited from class org.restlet.representation.Representation |
---|
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getSize, getText, hasKnownSize, isAvailable, isEmpty, isTransient, release, setAvailable, setDigest, setDisposition, setExpirationDate, setRange, setSize, setTransient |
Methods inherited from class org.restlet.representation.RepresentationInfo |
---|
getModificationDate, getTag, setModificationDate, setTag |
Methods inherited from class org.restlet.representation.Variant |
---|
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public XstreamRepresentation(MediaType mediaType, T object)
mediaType
- The target media type.object
- The object to format.public XstreamRepresentation(Representation representation, Class<T> targetClass)
representation
- The representation to parse.targetClass
- The target class of the object to serialize.public XstreamRepresentation(T object)
MediaType.APPLICATION_XML
media type by
default.
object
- The object to format.Method Detail |
---|
protected XStream createXstream(MediaType mediaType) throws IOException
HierarchicalStreamDriver
or a DomDriver
.
mediaType
- The serialization media type.
IOException
public Class<? extends HierarchicalStreamDriver> getJsonDriverClass()
public T getObject() throws IOException
IOException
public Class<? extends HierarchicalStreamDriver> getXmlDriverClass()
public XStream getXstream() throws IOException
IOException
public void setJsonDriverClass(Class<? extends HierarchicalStreamDriver> jsonDriverClass)
jsonDriverClass
- The XStream JSON driver class.public void setXmlDriverClass(Class<? extends HierarchicalStreamDriver> xmlDriverClass)
xmlDriverClass
- The XStream XML driver class.public void setXstream(XStream xstream)
xstream
- The XStream object.public void write(Writer writer) throws IOException
write
in class Representation
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |