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
Converts Strings into Nodes and visa versa. An abstract class for common Serializer functionality
  • Field Details

    • canon

      protected Canonicalizer canon
    • secureValidation

      protected boolean secureValidation
  • Constructor Details

    • AbstractSerializer

      public AbstractSerializer()
  • Method Details

    • 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, IOException
      Specified by:
      deserialize in interface Serializer
      Parameters:
      source -
      ctx -
      Returns:
      the Node resulting from the parse of the source
      Throws:
      XMLEncryptionException
      IOException
    • 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)