Class AbstractSerializer
- java.lang.Object
-
- org.apache.xml.security.encryption.AbstractSerializer
-
- All Implemented Interfaces:
Serializer
- Direct Known Subclasses:
DocumentSerializer,TransformSerializer
public abstract class AbstractSerializer extends Object implements Serializer
ConvertsStrings intoNodes and visa versa. An abstract class for common Serializer functionality
-
-
Field Summary
Fields Modifier and Type Field Description protected Canonicalizercanonprotected booleansecureValidation
-
Constructor Summary
Constructors Constructor Description AbstractSerializer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringcanonSerialize(Node node)Use the Canonicalizer to serialize the nodebyte[]canonSerializeToByteArray(Node node)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)booleanisSecureValidation()Stringserialize(Element element)Returns aStringrepresentation of the specifiedElement.Stringserialize(NodeList content)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 Detail
-
canon
protected Canonicalizer canon
-
secureValidation
protected boolean secureValidation
-
-
Method Detail
-
setCanonicalizer
public void setCanonicalizer(Canonicalizer canon)
Description copied from interface:SerializerSet the Canonicalizer object to use.- Specified by:
setCanonicalizerin interfaceSerializer
-
serialize
public String serialize(Element element) throws Exception
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
public byte[] serializeToByteArray(Element element) throws Exception
Returns abyte[]representation of the specifiedElement.- Specified by:
serializeToByteArrayin interfaceSerializer- Parameters:
element- theElementto serialize.- Returns:
- the
byte[]representation of the serilaizedElement. - Throws:
Exception
-
serialize
public String serialize(NodeList content) throws Exception
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
public byte[] serializeToByteArray(NodeList content) throws Exception
Returns abyte[]representation of the specifiedNodeList.- Specified by:
serializeToByteArrayin interfaceSerializer- Parameters:
content- theNodeListto serialize.- Returns:
- the
byte[]representation of the serializedNodeList. - Throws:
Exception
-
canonSerialize
public String canonSerialize(Node node) throws Exception
Use the Canonicalizer to serialize the node- Parameters:
node-- Returns:
- the canonicalization of the node
- Throws:
Exception
-
canonSerializeToByteArray
public byte[] canonSerializeToByteArray(Node node) throws Exception
Use the Canonicalizer to serialize the node- Specified by:
canonSerializeToByteArrayin interfaceSerializer- Parameters:
node-- Returns:
- the (byte[]) canonicalization of the node
- Throws:
Exception
-
deserialize
public abstract Node deserialize(String source, Node ctx) throws XMLEncryptionException
- 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
- Specified by:
deserializein interfaceSerializer- Parameters:
source-ctx-- Returns:
- the Node resulting from the parse of the source
- Throws:
XMLEncryptionException
-
createContext
protected static byte[] createContext(byte[] source, Node ctx) throws XMLEncryptionException- Throws:
XMLEncryptionException
-
isSecureValidation
public boolean isSecureValidation()
-
setSecureValidation
public void setSecureValidation(boolean secureValidation)
-
-