Class ElementProxy

java.lang.Object
org.apache.xml.security.utils.ElementProxy
Direct Known Subclasses:
Algorithm, EncryptionElementProxy, InclusiveNamespaces, SignatureElementProxy, XPath2FilterContainer, XPath2FilterContainer04, XPathFilterCHGPContainer

public abstract class ElementProxy extends Object
This is the base class to all Objects which have a direct 1:1 mapping to an Element in a particular namespace.
Author:
$Author$
  • Field Details

    • MODE_CREATE

      public static final int MODE_CREATE
      The element has been created by the code
      See Also:
    • MODE_PROCESS

      public static final int MODE_PROCESS
      The element has been readed from a DOM tree by the code
      See Also:
    • MODE_UNKNOWN

      public static final int MODE_UNKNOWN
      The element isn't known if it is readen or created
      See Also:
    • MODE_SIGN

      public static final int MODE_SIGN
      The element is going to be signed
      See Also:
    • MODE_VERIFY

      public static final int MODE_VERIFY
      The element is going to be verified
      See Also:
    • MODE_ENCRYPT

      public static final int MODE_ENCRYPT
      The element is going to be encrypted
      See Also:
    • MODE_DECRYPT

      public static final int MODE_DECRYPT
      The element is going to be decrypted
      See Also:
    • _state

      protected int _state
    • _constructionElement

      protected Element _constructionElement
      Field _constructionElement
    • _baseURI

      protected String _baseURI
      Field _baseURI
    • _doc

      protected Document _doc
      Field _doc
  • Constructor Details

    • ElementProxy

      public ElementProxy()
      Constructor ElementProxy
    • ElementProxy

      public ElementProxy(Document doc)
      Constructor ElementProxy
      Parameters:
      doc -
    • ElementProxy

      public ElementProxy(Element element, String BaseURI) throws XMLSecurityException
      Constructor ElementProxy
      Parameters:
      element -
      BaseURI -
      Throws:
      XMLSecurityException
  • Method Details

    • getBaseNamespace

      public abstract String getBaseNamespace()
      Returns the namespace of the Elements of the sub-class.
      Returns:
      the namespace of the Elements of the sub-class.
    • getBaseLocalName

      public abstract String getBaseLocalName()
      Returns the localname of the Elements of the sub-class.
      Returns:
      the localname of the Elements of the sub-class.
    • createElementForFamily

      public static Element createElementForFamily(Document doc, String namespace, String localName)
      This method creates an Element in a given namespace with a given localname. It uses the getDefaultPrefix(java.lang.String) method to decide whether a particular prefix is bound to that namespace.
      This method was refactored out of the constructor.
      Parameters:
      doc -
      namespace -
      localName -
      Returns:
      The element created.
    • setElement

      public void setElement(Element element, String BaseURI) throws XMLSecurityException
      Method setElement
      Parameters:
      element -
      BaseURI -
      Throws:
      XMLSecurityException
    • getElement

      public final Element getElement()
      Returns the Element which was constructed by the Object.
      Returns:
      the Element which was constructed by the Object.
    • getElementPlusReturns

      public final NodeList getElementPlusReturns()
      Returns the Element plus a leading and a trailing CarriageReturn Text node.
      Returns:
      the Element which was constructed by the Object.
    • getDocument

      public Document getDocument()
      Method getDocument
      Returns:
      the Document where this element is contained.
    • getBaseURI

      public String getBaseURI()
      Method getBaseURI
      Returns:
      the base uri of the namespace of this element
    • guaranteeThatElementInCorrectSpace

      public void guaranteeThatElementInCorrectSpace() throws XMLSecurityException
      Method guaranteeThatElementInCorrectSpace
      Throws:
      XMLSecurityException
    • addBigIntegerElement

      public void addBigIntegerElement(BigInteger bi, String localname)
      Method setVal
      Parameters:
      bi -
      localname -
    • addBase64Element

      public void addBase64Element(byte[] bytes, String localname)
      Method addBase64Element
      Parameters:
      bytes -
      localname -
    • addTextElement

      public void addTextElement(String text, String localname)
      Method addTextElement
      Parameters:
      text -
      localname -
    • addBase64Text

      public void addBase64Text(byte[] bytes)
      Method addBase64Text
      Parameters:
      bytes -
    • addText

      public void addText(String text)
      Method addText
      Parameters:
      text -
    • getBigIntegerFromChildElement

      public BigInteger getBigIntegerFromChildElement(String localname, String namespace) throws Base64DecodingException
      Method getVal
      Parameters:
      localname -
      namespace -
      Returns:
      The biginter contained in the given element
      Throws:
      Base64DecodingException
    • getBytesFromChildElement

      public byte[] getBytesFromChildElement(String localname, String namespace) throws XMLSecurityException
      Method getBytesFromChildElement
      Parameters:
      localname -
      namespace -
      Returns:
      the bytes
      Throws:
      XMLSecurityException
    • getTextFromChildElement

      public String getTextFromChildElement(String localname, String namespace)
      Method getTextFromChildElement
      Parameters:
      localname -
      namespace -
      Returns:
      the Text of the textNode
    • getBytesFromTextChild

      public byte[] getBytesFromTextChild() throws XMLSecurityException
      Method getBytesFromTextChild
      Returns:
      The base64 bytes from the first text child of this element
      Throws:
      XMLSecurityException
    • getTextFromTextChild

      public String getTextFromTextChild()
      Method getTextFromTextChild
      Returns:
      the Text obtained concatening all the the text nodes of this element
    • length

      public int length(String namespace, String localname)
      Method length
      Parameters:
      namespace -
      localname -
      Returns:
      the number of elements {namespace}:localname under this element
    • setXPathNamespaceContext

      public void setXPathNamespaceContext(String prefix, String uri) throws XMLSecurityException
      Adds an xmlns: definition to the Element. This can be called as follows:
       // set namespace with ds prefix
       xpathContainer.setXPathNamespaceContext("ds", "http://www.w3.org/2000/09/xmldsig#");
       xpathContainer.setXPathNamespaceContext("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#");
       
      Parameters:
      prefix -
      uri -
      Throws:
      XMLSecurityException
    • setDefaultPrefix

      public static void setDefaultPrefix(String namespace, String prefix) throws XMLSecurityException
      Method setDefaultPrefix
      Parameters:
      namespace -
      prefix -
      Throws:
      XMLSecurityException
    • getDefaultPrefix

      public static String getDefaultPrefix(String namespace)
      Method getDefaultPrefix
      Parameters:
      namespace -
      Returns:
      the default prefix bind to this element.