org.apache.xml.security.encryption
Class AbstractSerializer

java.lang.Object
  extended by org.apache.xml.security.encryption.AbstractSerializer
All Implemented Interfaces:
Serializer
Direct Known Subclasses:
DocumentSerializer, TransformSerializer

public abstract class AbstractSerializer
extends Object
implements Serializer

Converts Strings into Nodes and visa versa. An abstract class for common Serializer functionality


Field Summary
protected  Canonicalizer canon
           
protected  boolean secureValidation
           
 
Constructor Summary
AbstractSerializer()
           
 
Method Summary
 String canonSerialize(Node node)
          Use the Canonicalizer to serialize the node
 byte[] canonSerializeToByteArray(Node node)
          Use the Canonicalizer to serialize the node
protected 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 isSecureValidation()
           
 String serialize(Element element)
          Returns a String representation of the specified Element.
 String serialize(NodeList content)
          Returns a String representation of the specified NodeList.
 byte[] serializeToByteArray(Element element)
          Returns a byte[] representation of the specified Element.
 byte[] serializeToByteArray(NodeList content)
          Returns a byte[] representation of the specified NodeList.
 void setCanonicalizer(Canonicalizer canon)
          Set the Canonicalizer object to use.
 void setSecureValidation(boolean secureValidation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

canon

protected Canonicalizer canon

secureValidation

protected boolean secureValidation
Constructor Detail

AbstractSerializer

public AbstractSerializer()
Method Detail

setCanonicalizer

public void setCanonicalizer(Canonicalizer canon)
Description copied from interface: Serializer
Set the Canonicalizer object to use.

Specified by:
setCanonicalizer in interface Serializer

serialize

public String serialize(Element element)
                 throws Exception
Returns a String representation of the specified Element.

Refer also to comments about setup of format.

Parameters:
element - the Element to serialize.
Returns:
the String representation of the serilaized Element.
Throws:
Exception

serializeToByteArray

public byte[] serializeToByteArray(Element element)
                            throws Exception
Returns a byte[] representation of the specified Element.

Specified by:
serializeToByteArray in interface Serializer
Parameters:
element - the Element to serialize.
Returns:
the byte[] representation of the serilaized Element.
Throws:
Exception

serialize

public String serialize(NodeList content)
                 throws Exception
Returns a String representation of the specified NodeList.

This is a special case because the NodeList may represent a DocumentFragment. 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 - the NodeList to serialize.
Returns:
the String representation of the serialized NodeList.
Throws:
Exception

serializeToByteArray

public byte[] serializeToByteArray(NodeList content)
                            throws Exception
Returns a byte[] representation of the specified NodeList.

Specified by:
serializeToByteArray in interface Serializer
Parameters:
content - the NodeList to serialize.
Returns:
the byte[] representation of the serialized NodeList.
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:
canonSerializeToByteArray in interface Serializer
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:
deserialize in interface Serializer
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

createContext

protected static String createContext(String source,
                                      Node ctx)

isSecureValidation

public boolean isSecureValidation()

setSecureValidation

public void setSecureValidation(boolean secureValidation)


Copyright © 2000–2014 The Apache Software Foundation. All rights reserved.