Class AbstractSerializer
java.lang.Object
org.apache.xml.security.encryption.AbstractSerializer
- All Implemented Interfaces:
Serializer
- Direct Known Subclasses:
DocumentSerializer,TransformSerializer
Converts
Strings into Nodes 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 StringcreateContext(String source, Node ctx) abstract Nodedeserialize(byte[] source, Node ctx) abstract Nodedeserialize(String source, Node ctx) booleanReturns aStringrepresentation of the specifiedElement.Returns aStringrepresentation of the specifiedNodeList.byte[]serializeToByteArray(Element element) Returns abyte[]representation of the specifiedElement.byte[]serializeToByteArray(NodeList content) Returns abyte[]representation of the specifiedNodeList.voidsetCanonicalizer(Canonicalizer canon) Set the Canonicalizer object to use.voidsetSecureValidation(boolean secureValidation)
-
Field Details
-
canon
-
secureValidation
protected boolean secureValidation
-
-
Constructor Details
-
AbstractSerializer
public AbstractSerializer()
-
-
Method Details
-
setCanonicalizer
Description copied from interface:SerializerSet the Canonicalizer object to use.- Specified by:
setCanonicalizerin interfaceSerializer
-
serialize
Returns aStringrepresentation of the specifiedElement. Refer also to comments about setup of format.- Parameters:
element- theElementto serialize.- Returns:
- the
Stringrepresentation of the serilaizedElement. - Throws:
Exception
-
serializeToByteArray
Returns abyte[]representation of the specifiedElement.- Specified by:
serializeToByteArrayin interfaceSerializer- Parameters:
element- theElementto serialize.- Returns:
- the
byte[]representation of the serilaizedElement. - Throws:
Exception
-
serialize
Returns aStringrepresentation 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- theNodeListto serialize.- Returns:
- the
Stringrepresentation of the serializedNodeList. - Throws:
Exception
-
serializeToByteArray
Returns abyte[]representation of the specifiedNodeList.- Specified by:
serializeToByteArrayin interfaceSerializer- Parameters:
content- theNodeListto 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:
canonSerializeToByteArrayin 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:
deserializein interfaceSerializer- Parameters:
source-ctx-- Returns:
- the Node resulting from the parse of the source
- Throws:
XMLEncryptionExceptionIOException
-
createContext
- Throws:
XMLEncryptionException
-
createContext
-
isSecureValidation
public boolean isSecureValidation() -
setSecureValidation
public void setSecureValidation(boolean secureValidation)
-