Class AbstractSerializer
java.lang.Object
org.apache.xml.security.encryption.AbstractSerializer
- All Implemented Interfaces:
Serializer
- Direct Known Subclasses:
DocumentSerializer
,TransformSerializer
Converts
String
s into Node
s and visa versa.
An abstract class for common Serializer functionality-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncanonSerialize
(Node node) Use the Canonicalizer to serialize the nodebyte[]
Use the Canonicalizer to serialize the nodeprotected static byte[]
createContext
(byte[] source, Node ctx) protected static String
createContext
(String source, Node ctx) abstract Node
deserialize
(byte[] source, Node ctx) abstract Node
deserialize
(String source, Node ctx) boolean
Returns aString
representation of the specifiedElement
.Returns aString
representation of the specifiedNodeList
.byte[]
serializeToByteArray
(Element element) Returns abyte[]
representation of the specifiedElement
.byte[]
serializeToByteArray
(NodeList content) Returns abyte[]
representation of the specifiedNodeList
.void
setCanonicalizer
(Canonicalizer canon) Set the Canonicalizer object to use.void
setSecureValidation
(boolean secureValidation)
-
Field Details
-
canon
-
secureValidation
protected boolean secureValidation
-
-
Constructor Details
-
AbstractSerializer
public AbstractSerializer()
-
-
Method Details
-
setCanonicalizer
Description copied from interface:Serializer
Set the Canonicalizer object to use.- Specified by:
setCanonicalizer
in interfaceSerializer
-
serialize
Returns aString
representation of the specifiedElement
. Refer also to comments about setup of format.- Parameters:
element
- theElement
to serialize.- Returns:
- the
String
representation of the serilaizedElement
. - Throws:
Exception
-
serializeToByteArray
Returns abyte[]
representation of the specifiedElement
.- Specified by:
serializeToByteArray
in interfaceSerializer
- Parameters:
element
- theElement
to serialize.- Returns:
- the
byte[]
representation of the serilaizedElement
. - Throws:
Exception
-
serialize
Returns aString
representation of the specifiedNodeList
. This is a special case because the NodeList may represent aDocumentFragment
. A document fragment may be a non-valid XML document (refer to appropriate description of W3C) because it my start with a non-element node, e.g. a text node. The methods first converts the node list into a document fragment. Special care is taken to not destroy the current document, thus the method clones the nodes (deep cloning) before it appends them to the document fragment. Refer also to comments about setup of format.- Parameters:
content
- theNodeList
to serialize.- Returns:
- the
String
representation of the serializedNodeList
. - Throws:
Exception
-
serializeToByteArray
Returns abyte[]
representation of the specifiedNodeList
.- Specified by:
serializeToByteArray
in interfaceSerializer
- Parameters:
content
- theNodeList
to serialize.- Returns:
- the
byte[]
representation of the serializedNodeList
. - Throws:
Exception
-
canonSerialize
Use the Canonicalizer to serialize the node- Parameters:
node
-- Returns:
- the canonicalization of the node
- Throws:
Exception
-
canonSerializeToByteArray
Use the Canonicalizer to serialize the node- Specified by:
canonSerializeToByteArray
in interfaceSerializer
- Parameters:
node
-- Returns:
- the (byte[]) canonicalization of the node
- Throws:
Exception
-
deserialize
- Parameters:
source
-ctx
-- Returns:
- the Node resulting from the parse of the source
- Throws:
XMLEncryptionException
-
deserialize
public abstract Node deserialize(byte[] source, Node ctx) throws XMLEncryptionException, IOException - Specified by:
deserialize
in interfaceSerializer
- Parameters:
source
-ctx
-- Returns:
- the Node resulting from the parse of the source
- Throws:
XMLEncryptionException
IOException
-
createContext
- Throws:
XMLEncryptionException
-
createContext
-
isSecureValidation
public boolean isSecureValidation() -
setSecureValidation
public void setSecureValidation(boolean secureValidation)
-