You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2013/02/26 15:56:42 UTC

svn commit: r1450197 [2/2] - in /santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security: algorithms/ encryption/ keys/ keys/content/ keys/content/keyvalues/ keys/content/x509/ signature/ transforms/ transforms/params/ utils/

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transforms.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transforms.java?rev=1450197&r1=1450196&r2=1450197&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transforms.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transforms.java Tue Feb 26 14:56:41 2013
@@ -115,7 +115,7 @@ public class Transforms extends Signatur
      */
     public Transforms(Document doc) {
         super(doc);
-        XMLUtils.addReturnToElement(this.constructionElement);
+        addReturnToSelf();
     }
 
     /**
@@ -166,7 +166,7 @@ public class Transforms extends Signatur
                 log.debug("Transforms.addTransform(" + transformURI + ")");
             }
 
-            Transform transform = new Transform(this.doc, transformURI);
+            Transform transform = new Transform(getDocument(), transformURI);
 
             this.addTransform(transform);
         } catch (InvalidTransformException ex) {
@@ -190,7 +190,7 @@ public class Transforms extends Signatur
                 log.debug("Transforms.addTransform(" + transformURI + ")");
             }
 
-            Transform transform = new Transform(this.doc, transformURI, contextElement);
+            Transform transform = new Transform(getDocument(), transformURI, contextElement);
 
             this.addTransform(transform);
         } catch (InvalidTransformException ex) {
@@ -211,7 +211,7 @@ public class Transforms extends Signatur
        throws TransformationException {
 
         try {
-            Transform transform = new Transform(this.doc, transformURI, contextNodes);
+            Transform transform = new Transform(getDocument(), transformURI, contextNodes);
             this.addTransform(transform);
         } catch (InvalidTransformException ex) {
             throw new TransformationException("empty", ex);
@@ -230,8 +230,8 @@ public class Transforms extends Signatur
 
         Element transformElement = transform.getElement();
 
-        this.constructionElement.appendChild(transformElement);
-        XMLUtils.addReturnToElement(this.constructionElement);
+        appendSelf(transformElement);
+        addReturnToSelf();
     }
 
     /**
@@ -304,11 +304,8 @@ public class Transforms extends Signatur
      * @return the number of transformations
      */
     public int getLength() {
-        if (transforms == null) {
-            transforms = 
-                XMLUtils.selectDsNodes(this.constructionElement.getFirstChild(), "Transform");
-        }
-        return transforms.length;       
+        initTransforms();
+        return transforms.length;
     }
 
     /**
@@ -321,16 +318,19 @@ public class Transforms extends Signatur
      */
     public Transform item(int i) throws TransformationException {
         try {
-            if (transforms == null) {
-                transforms = 
-                    XMLUtils.selectDsNodes(this.constructionElement.getFirstChild(), "Transform");
-            }
+            initTransforms();
             return new Transform(transforms[i], this.baseURI);
         } catch (XMLSecurityException ex) {
             throw new TransformationException("empty", ex);
         }
     }
 
+    private void initTransforms() {
+        if (transforms == null) {
+            transforms = XMLUtils.selectDsNodes(getFirstChild(), "Transform");
+        }
+    }
+
     /** @inheritDoc */
     public String getBaseLocalName() {
         return Constants._TAG_TRANSFORMS;

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/InclusiveNamespaces.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/InclusiveNamespaces.java?rev=1450197&r1=1450196&r2=1450197&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/InclusiveNamespaces.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/InclusiveNamespaces.java Tue Feb 26 14:56:41 2013
@@ -85,8 +85,7 @@ public class InclusiveNamespaces extends
             }
         }
         
-        this.constructionElement.setAttributeNS(
-            null, InclusiveNamespaces._ATT_EC_PREFIXLIST, sb.toString().trim());
+        setLocalAttribute(InclusiveNamespaces._ATT_EC_PREFIXLIST, sb.toString().trim());
     }
 
     /**
@@ -107,7 +106,7 @@ public class InclusiveNamespaces extends
      * @return The Inclusive Namespace string
      */
     public String getInclusiveNamespaces() {
-        return this.constructionElement.getAttributeNS(null, InclusiveNamespaces._ATT_EC_PREFIXLIST);
+        return getLocalAttribute(InclusiveNamespaces._ATT_EC_PREFIXLIST);
     }
     
     /**

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer.java?rev=1450197&r1=1450196&r2=1450197&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer.java Tue Feb 26 14:56:41 2013
@@ -86,9 +86,8 @@ public class XPath2FilterContainer exten
     private XPath2FilterContainer(Document doc, String xpath2filter, String filterType) {
         super(doc);
 
-        this.constructionElement.setAttributeNS(
-            null, XPath2FilterContainer._ATT_FILTER, filterType);
-        this.constructionElement.appendChild(doc.createTextNode(xpath2filter));
+        setLocalAttribute(XPath2FilterContainer._ATT_FILTER, filterType);
+        appendSelf(createText(xpath2filter));
     }
 
     /**
@@ -102,8 +101,7 @@ public class XPath2FilterContainer exten
 
         super(element, BaseURI);
 
-        String filterStr = 
-            this.constructionElement.getAttributeNS(null, XPath2FilterContainer._ATT_FILTER);
+        String filterStr = getLocalAttribute(XPath2FilterContainer._ATT_FILTER);
 
         if (!filterStr.equals(XPath2FilterContainer._ATT_FILTER_VALUE_INTERSECT) 
             && !filterStr.equals(XPath2FilterContainer._ATT_FILTER_VALUE_SUBTRACT) 
@@ -210,8 +208,7 @@ public class XPath2FilterContainer exten
      * @return <code>true</code> if the <code>Filter</code> attribute has value "intersect".
      */
     public boolean isIntersect() {
-        return this.constructionElement.getAttributeNS(
-            null, XPath2FilterContainer._ATT_FILTER
+        return getLocalAttribute(XPath2FilterContainer._ATT_FILTER
         ).equals(XPath2FilterContainer._ATT_FILTER_VALUE_INTERSECT);
     }
 
@@ -221,8 +218,7 @@ public class XPath2FilterContainer exten
      * @return <code>true</code> if the <code>Filter</code> attribute has value "subtract".
      */
     public boolean isSubtract() {
-        return this.constructionElement.getAttributeNS(
-            null, XPath2FilterContainer._ATT_FILTER
+        return getLocalAttribute(XPath2FilterContainer._ATT_FILTER
         ).equals(XPath2FilterContainer._ATT_FILTER_VALUE_SUBTRACT);
     }
 
@@ -232,8 +228,7 @@ public class XPath2FilterContainer exten
      * @return <code>true</code> if the <code>Filter</code> attribute has value "union".
      */
     public boolean isUnion() {
-        return this.constructionElement.getAttributeNS(
-            null, XPath2FilterContainer._ATT_FILTER
+        return getLocalAttribute(XPath2FilterContainer._ATT_FILTER
         ).equals(XPath2FilterContainer._ATT_FILTER_VALUE_UNION);
     }
 
@@ -256,7 +251,7 @@ public class XPath2FilterContainer exten
      */
     public Node getXPathFilterTextNode() {
 
-        NodeList children = this.constructionElement.getChildNodes();
+        NodeList children = getElement().getChildNodes();
         int length = children.getLength();
 
         for (int i = 0; i < length; i++) {

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java?rev=1450197&r1=1450196&r2=1450197&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java Tue Feb 26 14:56:41 2013
@@ -21,7 +21,6 @@ package org.apache.xml.security.transfor
 import org.apache.xml.security.exceptions.XMLSecurityException;
 import org.apache.xml.security.transforms.TransformParam;
 import org.apache.xml.security.utils.ElementProxy;
-import org.apache.xml.security.utils.XMLUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -74,16 +73,15 @@ public class XPath2FilterContainer04 ext
     private XPath2FilterContainer04(Document doc, String xpath2filter, String filterType) {
         super(doc);
 
-        this.constructionElement.setAttributeNS(
-            null, XPath2FilterContainer04._ATT_FILTER, filterType);
+        setLocalAttribute(XPath2FilterContainer04._ATT_FILTER, filterType);
 
         if ((xpath2filter.length() > 2)
             && (!Character.isWhitespace(xpath2filter.charAt(0)))) {
-            XMLUtils.addReturnToElement(this.constructionElement);
-            this.constructionElement.appendChild(doc.createTextNode(xpath2filter));
-            XMLUtils.addReturnToElement(this.constructionElement);
+            addReturnToSelf();
+            appendSelf(createText(xpath2filter));
+            addReturnToSelf();
         } else {
-            this.constructionElement.appendChild(doc.createTextNode(xpath2filter));
+            appendSelf(createText(xpath2filter));
         }
     }
 
@@ -99,8 +97,7 @@ public class XPath2FilterContainer04 ext
 
         super(element, BaseURI);
 
-        String filterStr =
-            this.constructionElement.getAttributeNS(null, XPath2FilterContainer04._ATT_FILTER);
+        String filterStr = getLocalAttribute(XPath2FilterContainer04._ATT_FILTER);
 
         if (!filterStr.equals(XPath2FilterContainer04._ATT_FILTER_VALUE_INTERSECT) 
             && !filterStr.equals(XPath2FilterContainer04._ATT_FILTER_VALUE_SUBTRACT) 
@@ -179,8 +176,7 @@ public class XPath2FilterContainer04 ext
      * @return <code>true</code> if the <code>Filter</code> attribute has value "intersect".
      */
     public boolean isIntersect() {
-        return this.constructionElement.getAttributeNS(
-            null, XPath2FilterContainer04._ATT_FILTER
+        return getLocalAttribute(XPath2FilterContainer04._ATT_FILTER
         ).equals(XPath2FilterContainer04._ATT_FILTER_VALUE_INTERSECT);
     }
 
@@ -190,8 +186,7 @@ public class XPath2FilterContainer04 ext
      * @return <code>true</code> if the <code>Filter</code> attribute has value "subtract".
      */
     public boolean isSubtract() {
-        return this.constructionElement.getAttributeNS(
-            null, XPath2FilterContainer04._ATT_FILTER
+        return getLocalAttribute(XPath2FilterContainer04._ATT_FILTER
         ).equals(XPath2FilterContainer04._ATT_FILTER_VALUE_SUBTRACT);
     }
 
@@ -201,8 +196,7 @@ public class XPath2FilterContainer04 ext
      * @return <code>true</code> if the <code>Filter</code> attribute has value "union".
      */
     public boolean isUnion() {
-        return this.constructionElement.getAttributeNS(
-            null, XPath2FilterContainer04._ATT_FILTER
+        return getLocalAttribute(XPath2FilterContainer04._ATT_FILTER
         ).equals(XPath2FilterContainer04._ATT_FILTER_VALUE_UNION);
     }
 
@@ -224,7 +218,7 @@ public class XPath2FilterContainer04 ext
      * @return the first Text node which contains information from the XPath 2 Filter String
      */
     public Node getXPathFilterTextNode() {
-        NodeList children = this.constructionElement.getChildNodes();
+        NodeList children = getElement().getChildNodes();
         int length = children.getLength();
 
         for (int i = 0; i < length; i++) {

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathContainer.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathContainer.java?rev=1450197&r1=1450196&r2=1450197&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathContainer.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathContainer.java Tue Feb 26 14:56:41 2013
@@ -50,16 +50,16 @@ public class XPathContainer extends Sign
      * @param xpath
      */
     public void setXPath(String xpath) {
-        if (this.constructionElement.getChildNodes() != null) {
-            NodeList nl = this.constructionElement.getChildNodes();
+        if (getElement().getChildNodes() != null) {
+            NodeList nl = getElement().getChildNodes();
 
             for (int i = 0; i < nl.getLength(); i++) {
-                this.constructionElement.removeChild(nl.item(i));
+                getElement().removeChild(nl.item(i));
             }
         }
 
-        Text xpathText = this.doc.createTextNode(xpath);
-        this.constructionElement.appendChild(xpathText);
+        Text xpathText = createText(xpath);
+        appendSelf(xpathText);
     }
 
     /**

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java?rev=1450197&r1=1450196&r2=1450197&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java Tue Feb 26 14:56:41 2013
@@ -83,13 +83,9 @@ public class XPathFilterCHGPContainer ex
         super(doc);
 
         if (includeSlashPolicy) {
-            this.constructionElement.setAttributeNS(
-                null, XPathFilterCHGPContainer._ATT_INCLUDESLASH, "true"
-            );
+            setLocalAttribute(XPathFilterCHGPContainer._ATT_INCLUDESLASH, "true");
         } else {
-            this.constructionElement.setAttributeNS(
-                null, XPathFilterCHGPContainer._ATT_INCLUDESLASH, "false"
-            );
+            setLocalAttribute(XPathFilterCHGPContainer._ATT_INCLUDESLASH, "false");
         }
 
         if ((includeButSearch != null) && (includeButSearch.trim().length() > 0)) {
@@ -99,10 +95,10 @@ public class XPathFilterCHGPContainer ex
                 );
 
             includeButSearchElem.appendChild(
-                this.doc.createTextNode(indentXPathText(includeButSearch))
+                createText(indentXPathText(includeButSearch))
             );
-            XMLUtils.addReturnToElement(this.constructionElement);
-            this.constructionElement.appendChild(includeButSearchElem);
+            addReturnToSelf();
+            appendSelf(includeButSearchElem);
         }
 
         if ((excludeButSearch != null) && (excludeButSearch.trim().length() > 0)) {
@@ -112,10 +108,10 @@ public class XPathFilterCHGPContainer ex
                 );
 
             excludeButSearchElem.appendChild(
-                this.doc.createTextNode(indentXPathText(excludeButSearch)));
+                createText(indentXPathText(excludeButSearch)));
             
-            XMLUtils.addReturnToElement(this.constructionElement);
-            this.constructionElement.appendChild(excludeButSearchElem);
+            addReturnToSelf();
+            appendSelf(excludeButSearchElem);
         }
 
         if ((exclude != null) && (exclude.trim().length() > 0)) {
@@ -123,12 +119,12 @@ public class XPathFilterCHGPContainer ex
                 ElementProxy.createElementForFamily(
                    doc, this.getBaseNamespace(), XPathFilterCHGPContainer._TAG_EXCLUDE);
 
-            excludeElem.appendChild(this.doc.createTextNode(indentXPathText(exclude)));
-            XMLUtils.addReturnToElement(this.constructionElement);
-            this.constructionElement.appendChild(excludeElem);
+            excludeElem.appendChild(createText(indentXPathText(exclude)));
+            addReturnToSelf();
+            appendSelf(excludeElem);
         }
 
-        XMLUtils.addReturnToElement(this.constructionElement);
+        addReturnToSelf();
     }
 
     /**
@@ -202,7 +198,7 @@ public class XPathFilterCHGPContainer ex
 
         Element xElem = 
             XMLUtils.selectNode(
-                this.constructionElement.getFirstChild(), this.getBaseNamespace(), type, 0
+                getElement().getFirstChild(), this.getBaseNamespace(), type, 0
             );
 
         return XMLUtils.getFullTextChildrenFromElement(xElem);
@@ -241,8 +237,7 @@ public class XPathFilterCHGPContainer ex
      * @return the string
      */
     public boolean getIncludeSlashPolicy() {
-        return this.constructionElement.getAttributeNS(
-            null, XPathFilterCHGPContainer._ATT_INCLUDESLASH).equals("true");
+        return getLocalAttribute(XPathFilterCHGPContainer._ATT_INCLUDESLASH).equals("true");
     }
 
     /**
@@ -261,7 +256,7 @@ public class XPathFilterCHGPContainer ex
         }
 
         return XMLUtils.selectNodeText(
-            this.constructionElement.getFirstChild(), this.getBaseNamespace(), type, 0
+            getFirstChild(), this.getBaseNamespace(), type, 0
         );
     }
 

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/ElementProxy.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/ElementProxy.java?rev=1450197&r1=1450196&r2=1450197&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/ElementProxy.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/ElementProxy.java Tue Feb 26 14:56:41 2013
@@ -40,14 +40,16 @@ public abstract class ElementProxy {
     protected static final org.apache.commons.logging.Log log = 
         org.apache.commons.logging.LogFactory.getLog(ElementProxy.class);
 
-    /** Field constructionElement */
-    protected Element constructionElement = null;
+    /**
+     * What XML element does this ElementProxy instance wrap? 
+     */
+    private Element wrappedElement = null;
 
     /** Field baseURI */
     protected String baseURI = null;
 
     /** Field doc */
-    protected Document doc = null;
+    private Document wrappedDoc = null;
     
     /** Field prefixMappings */
     private static Map<String, String> prefixMappings = new ConcurrentHashMap<String, String>();
@@ -69,9 +71,8 @@ public abstract class ElementProxy {
             throw new RuntimeException("Document is null");
         }
 
-        this.doc = doc;
-        this.constructionElement = 
-            createElementForFamilyLocal(this.doc, this.getBaseNamespace(), this.getBaseLocalName());      
+        this.wrappedDoc = doc;
+        this.wrappedElement = createElementForFamilyLocal(this.getBaseNamespace(), this.getBaseLocalName());      
     }
     
     /**
@@ -90,8 +91,7 @@ public abstract class ElementProxy {
             log.debug("setElement(\"" + element.getTagName() + "\", \"" + BaseURI + "\")");
         }
 
-        this.doc = element.getOwnerDocument();
-        this.constructionElement = element;
+        setElement(element);
         this.baseURI = BaseURI;
 
         this.guaranteeThatElementInCorrectSpace();
@@ -113,8 +113,9 @@ public abstract class ElementProxy {
     
     
     protected Element createElementForFamilyLocal(
-        Document doc, String namespace, String localName
-    ) {	   	  
+        String namespace, String localName
+    ) {
+        Document doc = getDocument();
         Element result = null;
         if (namespace == null) {
             result = doc.createElementNS(null, localName);
@@ -180,19 +181,17 @@ public abstract class ElementProxy {
             log.debug("setElement(" + element.getTagName() + ", \"" + BaseURI + "\"");
         }
 
-        this.doc = element.getOwnerDocument();
-        this.constructionElement = element;
+        setElement(element);
         this.baseURI = BaseURI;
     }
 
-
     /**
      * Returns the Element which was constructed by the Object.
      *
      * @return the Element which was constructed by the Object.
      */
     public final Element getElement() {
-        return this.constructionElement;
+        return this.wrappedElement;
     }
 
     /**
@@ -204,20 +203,27 @@ public abstract class ElementProxy {
 
         HelperNodeList nl = new HelperNodeList();
 
-        nl.appendChild(this.doc.createTextNode("\n"));
-        nl.appendChild(this.getElement());
-        nl.appendChild(this.doc.createTextNode("\n"));
+        nl.appendChild(createText("\n"));
+        nl.appendChild(getElement());
+        nl.appendChild(createText("\n"));
 
         return nl;
     }
 
+    protected Text createText(String text) {
+        return this.wrappedDoc.createTextNode(text);
+    }
+
     /**
      * Method getDocument
      *
      * @return the Document where this element is contained.
      */
     public Document getDocument() {
-        return this.doc;
+        if (wrappedDoc == null) {
+            wrappedDoc = XMLUtils.getOwnerDocument(wrappedElement);
+        }
+        return wrappedDoc;
     }
 
     /**
@@ -239,8 +245,8 @@ public abstract class ElementProxy {
         String expectedLocalName = this.getBaseLocalName();
         String expectedNamespaceUri = this.getBaseNamespace();
 
-        String actualLocalName = this.constructionElement.getLocalName();
-        String actualNamespaceUri = this.constructionElement.getNamespaceURI();
+        String actualLocalName = getElement().getLocalName();
+        String actualNamespaceUri = getElement().getNamespaceURI();
 
         if(!expectedNamespaceUri.equals(actualNamespaceUri) 
             && !expectedLocalName.equals(actualLocalName)) {      
@@ -258,14 +264,18 @@ public abstract class ElementProxy {
      */
     public void addBigIntegerElement(BigInteger bi, String localname) {
         if (bi != null) {
-            Element e = XMLUtils.createElementInSignatureSpace(this.doc, localname);
+            Element e = XMLUtils.createElementInSignatureSpace(getDocument(), localname);
 
             Base64.fillElementWithBigInteger(e, bi);
-            this.constructionElement.appendChild(e);
-            XMLUtils.addReturnToElement(this.constructionElement);
+            appendSelf(e);
+            addReturnToSelf();
         }
     }
 
+    protected void addReturnToSelf() {
+        XMLUtils.addReturnToElement(getElement());
+    }
+
     /**
      * Method addBase64Element
      *
@@ -274,11 +284,11 @@ public abstract class ElementProxy {
      */
     public void addBase64Element(byte[] bytes, String localname) {
         if (bytes != null) {
-            Element e = Base64.encodeToElement(this.doc, localname, bytes);
+            Element e = Base64.encodeToElement(getDocument(), localname, bytes);
 
-            this.constructionElement.appendChild(e);
+            appendSelf(e);
             if (!XMLUtils.ignoreLineBreaks()) {
-                this.constructionElement.appendChild(this.doc.createTextNode("\n"));
+                appendSelf(createText("\n"));
             }
         }
     }
@@ -290,12 +300,12 @@ public abstract class ElementProxy {
      * @param localname
      */
     public void addTextElement(String text, String localname) {
-        Element e = XMLUtils.createElementInSignatureSpace(this.doc, localname);
-        Text t = this.doc.createTextNode(text);
+        Element e = XMLUtils.createElementInSignatureSpace(getDocument(), localname);
+        Text t = createText(text);
 
-        e.appendChild(t);
-        this.constructionElement.appendChild(e);
-        XMLUtils.addReturnToElement(this.constructionElement);
+        appendOther(e, t);
+        appendSelf(e);
+        addReturnToSelf();
     }
 
     /**
@@ -306,12 +316,24 @@ public abstract class ElementProxy {
     public void addBase64Text(byte[] bytes) {
         if (bytes != null) {
             Text t = XMLUtils.ignoreLineBreaks() 
-                ? this.doc.createTextNode(Base64.encode(bytes))
-                : this.doc.createTextNode("\n" + Base64.encode(bytes) + "\n");
-            this.constructionElement.appendChild(t);
+                ? createText(Base64.encode(bytes))
+                : createText("\n" + Base64.encode(bytes) + "\n");
+            appendSelf(t);
         }
     }
 
+    protected void appendSelf(ElementProxy toAppend) {
+        getElement().appendChild(toAppend.getElement());
+    }
+    
+    protected void appendSelf(Node toAppend) {
+        getElement().appendChild(toAppend);
+    }
+    
+    protected void appendOther(Element parent, Node toAppend) {
+        parent.appendChild(toAppend);
+    }
+    
     /**
      * Method addText
      *
@@ -319,9 +341,9 @@ public abstract class ElementProxy {
      */
     public void addText(String text) {
         if (text != null) {
-            Text t = this.doc.createTextNode(text);
+            Text t = createText(text);
 
-            this.constructionElement.appendChild(t);
+            appendSelf(t);
         }
     }
 
@@ -338,7 +360,7 @@ public abstract class ElementProxy {
     ) throws Base64DecodingException {
         return Base64.decodeBigIntegerFromString(
             XMLUtils.selectNodeText(
-                this.constructionElement.getFirstChild(), namespace, localname, 0
+                getFirstChild(), namespace, localname, 0
             ).getNodeValue()
         );
     }
@@ -355,7 +377,7 @@ public abstract class ElementProxy {
         throws XMLSecurityException {
         Element e =
             XMLUtils.selectNode(
-                this.constructionElement.getFirstChild(), namespace, localname, 0
+                getFirstChild(), namespace, localname, 0
             );
 
         return Base64.decode(e);
@@ -370,7 +392,7 @@ public abstract class ElementProxy {
      */
     public String getTextFromChildElement(String localname, String namespace) {
         return XMLUtils.selectNode(
-                this.constructionElement.getFirstChild(),
+                getFirstChild(),
                 namespace,
                 localname,
                 0).getTextContent();
@@ -383,7 +405,7 @@ public abstract class ElementProxy {
      * @throws XMLSecurityException
      */
     public byte[] getBytesFromTextChild() throws XMLSecurityException {
-        return Base64.decode(XMLUtils.getFullTextChildrenFromElement(this.constructionElement));
+        return Base64.decode(getTextFromTextChild());
     }
 
     /**
@@ -393,7 +415,7 @@ public abstract class ElementProxy {
      *    element
      */
     public String getTextFromTextChild() {
-        return XMLUtils.getFullTextChildrenFromElement(this.constructionElement);
+        return XMLUtils.getFullTextChildrenFromElement(getElement());
     }
 
     /**
@@ -405,7 +427,7 @@ public abstract class ElementProxy {
      */
     public int length(String namespace, String localname) {
         int number = 0;
-        Node sibling = this.constructionElement.getFirstChild();
+        Node sibling = getFirstChild();
         while (sibling != null) {        
             if (localname.equals(sibling.getLocalName())
                 && namespace.equals(sibling.getNamespaceURI())) {
@@ -443,18 +465,18 @@ public abstract class ElementProxy {
             ns = "xmlns:" + prefix;
         }
 
-        Attr a = this.constructionElement.getAttributeNodeNS(Constants.NamespaceSpecNS, ns);
+        Attr a = getElement().getAttributeNodeNS(Constants.NamespaceSpecNS, ns);
 
         if (a != null) { 
             if (!a.getNodeValue().equals(uri)) {
-                Object exArgs[] = { ns, this.constructionElement.getAttributeNS(null, ns) };
+                Object exArgs[] = { ns, getElement().getAttributeNS(null, ns) };
 
                 throw new XMLSecurityException("namespacePrefixAlreadyUsedByOtherURI", exArgs);
             }
             return;
         }
 
-        this.constructionElement.setAttributeNS(Constants.NamespaceSpecNS, ns, uri);
+        getElement().setAttributeNS(Constants.NamespaceSpecNS, ns, uri);
     }
 
     /**
@@ -510,4 +532,51 @@ public abstract class ElementProxy {
         return prefixMappings.get(namespace);
     }
 
+    /**
+     * New value for the wrapped XML element that this object is a proxy for.
+     * 
+     * @param elem  New element
+     * 
+     * @see #getWrappedElement()
+     */
+    protected void setElement(Element elem) {
+        wrappedElement = elem;
+    }
+    
+    /**
+     * Set a new value for the wrapped document that this object is a proxy for.
+     * 
+     * @param doc New document object being wrapped.
+     * 
+     * @see #getWrappedDocument()
+     */
+    protected void setDocument(Document doc) {
+        wrappedDoc = doc;
+    }
+    
+    protected String getLocalAttribute(String attrName) {
+        return getElement().getAttributeNS(null, attrName);
+    }
+    
+    protected void setLocalAttribute(String attrName, String value) {
+        getElement().setAttributeNS(null, attrName, value);
+    }
+    
+    protected void setLocalIdAttribute(String attrName, String value) {
+        
+        if (value != null) {
+            Attr attr = getDocument().createAttributeNS(null, attrName);
+            attr.setValue(value);
+            getElement().setAttributeNodeNS(attr);
+            getElement().setIdAttributeNode(attr, true);
+        }
+        else {
+            getElement().removeAttributeNS(null, attrName);
+        }
+    }
+    
+    protected Node getFirstChild() {
+        return getElement().getFirstChild();
+    }
+    
 }

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/Signature11ElementProxy.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/Signature11ElementProxy.java?rev=1450197&r1=1450196&r2=1450197&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/Signature11ElementProxy.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/Signature11ElementProxy.java Tue Feb 26 14:56:41 2013
@@ -42,9 +42,8 @@ public abstract class Signature11Element
             throw new RuntimeException("Document is null");
         }
 
-        this.doc = doc;
-        this.constructionElement = 
-            XMLUtils.createElementInSignature11Space(this.doc, this.getBaseLocalName());
+        setDocument(doc);
+        setElement(XMLUtils.createElementInSignature11Space(doc, this.getBaseLocalName()));
     }
 
     /**

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/SignatureElementProxy.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/SignatureElementProxy.java?rev=1450197&r1=1450196&r2=1450197&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/SignatureElementProxy.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/SignatureElementProxy.java Tue Feb 26 14:56:41 2013
@@ -42,9 +42,9 @@ public abstract class SignatureElementPr
             throw new RuntimeException("Document is null");
         }
 
-        this.doc = doc;
-        this.constructionElement = 
-            XMLUtils.createElementInSignatureSpace(this.doc, this.getBaseLocalName());
+        setDocument(doc);
+        setElement(XMLUtils.createElementInSignatureSpace(doc,
+                this.getBaseLocalName()));
     }
 
     /**