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 java.lang.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 java.lang.StringcanonSerialize(org.w3c.dom.Node node)Use the Canonicalizer to serialize the nodebyte[]canonSerializeToByteArray(org.w3c.dom.Node node)Use the Canonicalizer to serialize the nodeprotected static byte[]createContext(byte[] source, org.w3c.dom.Node ctx)protected static java.lang.StringcreateContext(java.lang.String source, org.w3c.dom.Node ctx)abstract org.w3c.dom.Nodedeserialize(byte[] source, org.w3c.dom.Node ctx)abstract org.w3c.dom.Nodedeserialize(java.lang.String source, org.w3c.dom.Node ctx)booleanisSecureValidation()java.lang.Stringserialize(org.w3c.dom.Element element)Returns aStringrepresentation of the specifiedElement.java.lang.Stringserialize(org.w3c.dom.NodeList content)Returns aStringrepresentation of the specifiedNodeList.byte[]serializeToByteArray(org.w3c.dom.Element element)Returns abyte[]representation of the specifiedElement.byte[]serializeToByteArray(org.w3c.dom.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 java.lang.String serialize(org.w3c.dom.Element element) throws java.lang.ExceptionReturns aStringrepresentation of the specifiedElement. Refer also to comments about setup of format.- Parameters:
element- theElementto serialize.- Returns:
- the
Stringrepresentation of the serilaizedElement. - Throws:
java.lang.Exception
-
serializeToByteArray
public byte[] serializeToByteArray(org.w3c.dom.Element element) throws java.lang.ExceptionReturns abyte[]representation of the specifiedElement.- Specified by:
serializeToByteArrayin interfaceSerializer- Parameters:
element- theElementto serialize.- Returns:
- the
byte[]representation of the serilaizedElement. - Throws:
java.lang.Exception
-
serialize
public java.lang.String serialize(org.w3c.dom.NodeList content) throws java.lang.ExceptionReturns 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:
java.lang.Exception
-
serializeToByteArray
public byte[] serializeToByteArray(org.w3c.dom.NodeList content) throws java.lang.ExceptionReturns abyte[]representation of the specifiedNodeList.- Specified by:
serializeToByteArrayin interfaceSerializer- Parameters:
content- theNodeListto serialize.- Returns:
- the
byte[]representation of the serializedNodeList. - Throws:
java.lang.Exception
-
canonSerialize
public java.lang.String canonSerialize(org.w3c.dom.Node node) throws java.lang.ExceptionUse the Canonicalizer to serialize the node- Parameters:
node-- Returns:
- the canonicalization of the node
- Throws:
java.lang.Exception
-
canonSerializeToByteArray
public byte[] canonSerializeToByteArray(org.w3c.dom.Node node) throws java.lang.ExceptionUse the Canonicalizer to serialize the node- Specified by:
canonSerializeToByteArrayin interfaceSerializer- Parameters:
node-- Returns:
- the (byte[]) canonicalization of the node
- Throws:
java.lang.Exception
-
deserialize
public abstract org.w3c.dom.Node deserialize(java.lang.String source, org.w3c.dom.Node ctx) throws XMLEncryptionException- Parameters:
source-ctx-- Returns:
- the Node resulting from the parse of the source
- Throws:
XMLEncryptionException
-
deserialize
public abstract org.w3c.dom.Node deserialize(byte[] source, org.w3c.dom.Node ctx) throws XMLEncryptionException, java.io.IOException- Specified by:
deserializein interfaceSerializer- Parameters:
source-ctx-- Returns:
- the Node resulting from the parse of the source
- Throws:
XMLEncryptionExceptionjava.io.IOException
-
createContext
protected static byte[] createContext(byte[] source, org.w3c.dom.Node ctx) throws XMLEncryptionException- Throws:
XMLEncryptionException
-
createContext
protected static java.lang.String createContext(java.lang.String source, org.w3c.dom.Node ctx)
-
isSecureValidation
public boolean isSecureValidation()
-
setSecureValidation
public void setSecureValidation(boolean secureValidation)
-
-