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 2011/01/27 12:11:37 UTC

svn commit: r1064079 [4/12] - in /santuario/xml-security-java/trunk/src: main/java/javax/xml/crypto/ main/java/javax/xml/crypto/dom/ main/java/javax/xml/crypto/dsig/ main/java/javax/xml/crypto/dsig/dom/ main/java/javax/xml/crypto/dsig/keyinfo/ main/jav...

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java Thu Jan 27 11:11:33 2011
@@ -118,7 +118,7 @@ public abstract class CanonicalizerBase 
     */
    public byte[] engineCanonicalizeSubTree(Node rootNode)
            throws CanonicalizationException {
-   		return engineCanonicalizeSubTree(rootNode,(Node)null);
+                return engineCanonicalizeSubTree(rootNode,(Node)null);
    }
    /**
     * Method engineCanonicalizeXPathNodeSet
@@ -128,8 +128,8 @@ public abstract class CanonicalizerBase 
     */
    public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
            throws CanonicalizationException {
-	   this._xpathNodeSet = xpathNodeSet;
-	   return engineCanonicalizeXPathNodeSetInternal(XMLUtils.getOwnerDocument(this._xpathNodeSet));
+           this._xpathNodeSet = xpathNodeSet;
+           return engineCanonicalizeXPathNodeSetInternal(XMLUtils.getOwnerDocument(this._xpathNodeSet));
    }
 
    /**
@@ -140,68 +140,68 @@ public abstract class CanonicalizerBase 
     */
     public byte[] engineCanonicalize(XMLSignatureInput input)
     throws CanonicalizationException {
-    	try {
-    		if (input.isExcludeComments())
-    			_includeComments = false;
-			byte[] bytes;
-			if (input.isOctetStream()) {
-				return engineCanonicalize(input.getBytes());
-			}
-			if (input.isElement()) {
-				bytes = engineCanonicalizeSubTree(input.getSubNode(), input
-						.getExcludeNode());
-				return bytes;
-			} else if (input.isNodeSet()) {
-				nodeFilter=input.getNodeFilters();
+        try {
+                if (input.isExcludeComments())
+                        _includeComments = false;
+                        byte[] bytes;
+                        if (input.isOctetStream()) {
+                                return engineCanonicalize(input.getBytes());
+                        }
+                        if (input.isElement()) {
+                                bytes = engineCanonicalizeSubTree(input.getSubNode(), input
+                                                .getExcludeNode());
+                                return bytes;
+                        } else if (input.isNodeSet()) {
+                                nodeFilter=input.getNodeFilters();
                                 
                 circumventBugIfNeeded(input);
-				
-				if (input.getSubNode() != null) {
-				    bytes = engineCanonicalizeXPathNodeSetInternal(input.getSubNode());
-				} else {
-				    bytes = engineCanonicalizeXPathNodeSet(input.getNodeSet());
-				}
-				return bytes;
-
-			}
-			return null;
-		} catch (CanonicalizationException ex) {
-			throw new CanonicalizationException("empty", ex);
-		} catch (ParserConfigurationException ex) {
-			throw new CanonicalizationException("empty", ex);
-		} catch (IOException ex) {
-			throw new CanonicalizationException("empty", ex);
-		} catch (SAXException ex) {
-			throw new CanonicalizationException("empty", ex);
-		}
+                                
+                                if (input.getSubNode() != null) {
+                                    bytes = engineCanonicalizeXPathNodeSetInternal(input.getSubNode());
+                                } else {
+                                    bytes = engineCanonicalizeXPathNodeSet(input.getNodeSet());
+                                }
+                                return bytes;
+
+                        }
+                        return null;
+                } catch (CanonicalizationException ex) {
+                        throw new CanonicalizationException("empty", ex);
+                } catch (ParserConfigurationException ex) {
+                        throw new CanonicalizationException("empty", ex);
+                } catch (IOException ex) {
+                        throw new CanonicalizationException("empty", ex);
+                } catch (SAXException ex) {
+                        throw new CanonicalizationException("empty", ex);
+                }
    }
    /**
     * @param _writer The _writer to set.
     */
     public void setWriter(OutputStream _writer) {
-    	this._writer = _writer;
+        this._writer = _writer;
     }
 
     /**
-	 * Canonicalizes a Subtree node.
-	 * 
-	 * @param rootNode
-	 *            the root of the subtree to canicalize
-	 * @param excludeNode
-	 *            a node to be excluded from the canicalize operation
-	 * @return The canonicalize stream.
-	 * @throws CanonicalizationException
-	 */
+         * Canonicalizes a Subtree node.
+         * 
+         * @param rootNode
+         *            the root of the subtree to canicalize
+         * @param excludeNode
+         *            a node to be excluded from the canicalize operation
+         * @return The canonicalize stream.
+         * @throws CanonicalizationException
+         */
     byte[] engineCanonicalizeSubTree(Node rootNode,Node excludeNode)
     throws CanonicalizationException {
-    	this._excludeNode = excludeNode;
+        this._excludeNode = excludeNode;
         try {
          NameSpaceSymbTable ns=new NameSpaceSymbTable();
          int nodeLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
          if (rootNode != null && Node.ELEMENT_NODE == rootNode.getNodeType()) {
-         	//Fills the nssymbtable with the definitions of the parent of the root subnode
-         	getParentNameSpaces((Element)rootNode,ns);
-         	nodeLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
+                //Fills the nssymbtable with the definitions of the parent of the root subnode
+                getParentNameSpaces((Element)rootNode,ns);
+                nodeLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
          }         
          this.canonicalizeSubTree(rootNode,ns,rootNode,nodeLevel);
          this._writer.close();
@@ -210,13 +210,13 @@ public abstract class CanonicalizerBase 
             if (reset) {
                 ((ByteArrayOutputStream)this._writer).reset();        
             }
-         	return result;
+                return result;
          }  else if (this._writer instanceof UnsyncByteArrayOutputStream) {
-        	 byte []result=((UnsyncByteArrayOutputStream)this._writer).toByteArray();
+                 byte []result=((UnsyncByteArrayOutputStream)this._writer).toByteArray();
              if (reset) {
                  ((UnsyncByteArrayOutputStream)this._writer).reset();        
              }
-          	 return result;
+                 return result;
          }
          return null;
          
@@ -238,106 +238,106 @@ public abstract class CanonicalizerBase 
     * @throws IOException
     */
     final void canonicalizeSubTree(Node currentNode, NameSpaceSymbTable ns,Node endnode,
-    		int documentLevel)
+                int documentLevel)
     throws CanonicalizationException, IOException {
-    	if (isVisibleInt(currentNode)==-1)
-    		return;
-    	Node sibling=null;
-    	Node parentNode=null;    	
-    	final OutputStream writer=this._writer;    
-    	final Node excludeNode=this._excludeNode;
-    	final boolean includeComments=this._includeComments;
-    	Map cache=new HashMap();
-    	do {
-    		switch (currentNode.getNodeType()) {
-    		
-    		case Node.DOCUMENT_TYPE_NODE :
-    		default :
-    			break;
-    		
-    		case Node.ENTITY_NODE :
-    		case Node.NOTATION_NODE :
-    		case Node.ATTRIBUTE_NODE :
-    			// illegal node type during traversal
-    			throw new CanonicalizationException("empty");
+        if (isVisibleInt(currentNode)==-1)
+                return;
+        Node sibling=null;
+        Node parentNode=null;    	
+        final OutputStream writer=this._writer;    
+        final Node excludeNode=this._excludeNode;
+        final boolean includeComments=this._includeComments;
+        Map cache=new HashMap();
+        do {
+                switch (currentNode.getNodeType()) {
+                
+                case Node.DOCUMENT_TYPE_NODE :
+                default :
+                        break;
+                
+                case Node.ENTITY_NODE :
+                case Node.NOTATION_NODE :
+                case Node.ATTRIBUTE_NODE :
+                        // illegal node type during traversal
+                        throw new CanonicalizationException("empty");
 
             case Node.DOCUMENT_FRAGMENT_NODE :
-    		case Node.DOCUMENT_NODE :
-    			ns.outputNodePush();
-    			sibling= currentNode.getFirstChild();
-    			break;
-    			
-    		case Node.COMMENT_NODE :
-    			if (includeComments) {
-    				outputCommentToWriter((Comment) currentNode, writer, documentLevel);
-    			}
-    			break;
-    			
-    		case Node.PROCESSING_INSTRUCTION_NODE :
-    			outputPItoWriter((ProcessingInstruction) currentNode, writer, documentLevel);
-    			break;
-    			
-    		case Node.TEXT_NODE :
-    		case Node.CDATA_SECTION_NODE :
-    			outputTextToWriter(currentNode.getNodeValue(), writer);
-    			break;
-    			
-    		case Node.ELEMENT_NODE :
-    			documentLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
-    			if (currentNode==excludeNode) {
-    				break;
-    			}      
-    			Element currentElement = (Element) currentNode;
-    			//Add a level to the nssymbtable. So latter can be pop-back.
-    			ns.outputNodePush();
-    			writer.write('<');
-    			String name=currentElement.getTagName();
-    			UtfHelpper.writeByte(name,writer,cache);
-    			
-    			Iterator attrs = this.handleAttributesSubtree(currentElement,ns);
-    			if (attrs!=null) {
-    				//we output all Attrs which are available
-    				while (attrs.hasNext()) {
-    					Attr attr = (Attr) attrs.next();
-    					outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
-    				}
-    			}
-    			writer.write('>');        
-    			sibling= currentNode.getFirstChild(); 
-    			if (sibling==null) {
-    				writer.write(_END_TAG);
-    				UtfHelpper.writeStringToUtf8(name,writer);        
-        			writer.write('>');
-        			//We fineshed with this level, pop to the previous definitions.
-        			ns.outputNodePop();
-				    if (parentNode != null) {
-       			    		sibling= currentNode.getNextSibling();
-				    }
-    			} else {
-    				parentNode=currentElement;
-    			}
-    			break;
-    		}
-    		while (sibling==null  && parentNode!=null) {    		      		      			
-    			writer.write(_END_TAG);
-    			UtfHelpper.writeByte(((Element)parentNode).getTagName(),writer,cache);        
-    			writer.write('>');
-    			//We fineshed with this level, pop to the previous definitions.
-    			ns.outputNodePop();
-    			if (parentNode==endnode)
-    				return;
-    			sibling=parentNode.getNextSibling();
-    			parentNode=parentNode.getParentNode();
-    			if (parentNode == null || Node.ELEMENT_NODE != parentNode.getNodeType()) {
-    				documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
-    				parentNode=null;
-    			}    			
-    		}      
-    		if (sibling==null)
-    			return;
-    		currentNode=sibling;      
-    		sibling=currentNode.getNextSibling();  
-    	} while(true);
+                case Node.DOCUMENT_NODE :
+                        ns.outputNodePush();
+                        sibling= currentNode.getFirstChild();
+                        break;
+                        
+                case Node.COMMENT_NODE :
+                        if (includeComments) {
+                                outputCommentToWriter((Comment) currentNode, writer, documentLevel);
+                        }
+                        break;
+                        
+                case Node.PROCESSING_INSTRUCTION_NODE :
+                        outputPItoWriter((ProcessingInstruction) currentNode, writer, documentLevel);
+                        break;
+                        
+                case Node.TEXT_NODE :
+                case Node.CDATA_SECTION_NODE :
+                        outputTextToWriter(currentNode.getNodeValue(), writer);
+                        break;
+                        
+                case Node.ELEMENT_NODE :
+                        documentLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
+                        if (currentNode==excludeNode) {
+                                break;
+                        }      
+                        Element currentElement = (Element) currentNode;
+                        //Add a level to the nssymbtable. So latter can be pop-back.
+                        ns.outputNodePush();
+                        writer.write('<');
+                        String name=currentElement.getTagName();
+                        UtfHelpper.writeByte(name,writer,cache);
+                        
+                        Iterator attrs = this.handleAttributesSubtree(currentElement,ns);
+                        if (attrs!=null) {
+                                //we output all Attrs which are available
+                                while (attrs.hasNext()) {
+                                        Attr attr = (Attr) attrs.next();
+                                        outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
+                                }
+                        }
+                        writer.write('>');        
+                        sibling= currentNode.getFirstChild(); 
+                        if (sibling==null) {
+                                writer.write(_END_TAG);
+                                UtfHelpper.writeStringToUtf8(name,writer);        
+                                writer.write('>');
+                                //We fineshed with this level, pop to the previous definitions.
+                                ns.outputNodePop();
+                                    if (parentNode != null) {
+                                        sibling= currentNode.getNextSibling();
+                                    }
+                        } else {
+                                parentNode=currentElement;
+                        }
+                        break;
+                }
+                while (sibling==null  && parentNode!=null) {    		      		      			
+                        writer.write(_END_TAG);
+                        UtfHelpper.writeByte(((Element)parentNode).getTagName(),writer,cache);        
+                        writer.write('>');
+                        //We fineshed with this level, pop to the previous definitions.
+                        ns.outputNodePop();
+                        if (parentNode==endnode)
+                                return;
+                        sibling=parentNode.getNextSibling();
+                        parentNode=parentNode.getParentNode();
+                        if (parentNode == null || Node.ELEMENT_NODE != parentNode.getNodeType()) {
+                                documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
+                                parentNode=null;
+                        }    			
+                }      
+                if (sibling==null)
+                        return;
+                currentNode=sibling;      
+                sibling=currentNode.getNextSibling();  
+        } while(true);
     }
 
 
@@ -351,15 +351,15 @@ public abstract class CanonicalizerBase 
          if (this._writer instanceof ByteArrayOutputStream) {
             byte [] sol=((ByteArrayOutputStream)this._writer).toByteArray();
             if (reset) {
-            	((ByteArrayOutputStream)this._writer).reset();
+                ((ByteArrayOutputStream)this._writer).reset();
             }
-         	return sol;
+                return sol;
          }  else if (this._writer instanceof UnsyncByteArrayOutputStream) {
-        	 byte []result=((UnsyncByteArrayOutputStream)this._writer).toByteArray();
+                 byte []result=((UnsyncByteArrayOutputStream)this._writer).toByteArray();
              if (reset) {
                  ((UnsyncByteArrayOutputStream)this._writer).reset();        
              }
-          	 return result;
+                 return result;
          }
          return null;
       } catch (UnsupportedEncodingException ex) {
@@ -371,62 +371,62 @@ public abstract class CanonicalizerBase 
 
    /**
     * Canoicalizes all the nodes included in the currentNode and contained in the 
-	* _xpathNodeSet field.
+        * _xpathNodeSet field.
     *
     * @param currentNode
-	* @param endnode
+        * @param endnode
     * @throws CanonicalizationException
     * @throws IOException
     */
    final void canonicalizeXPathNodeSet(Node currentNode,Node endnode )
            throws CanonicalizationException, IOException {
-   	if (isVisibleInt(currentNode)==-1)
-		return;
-	boolean currentNodeIsVisible = false;	  
-	NameSpaceSymbTable ns=new  NameSpaceSymbTable();
-	if (currentNode != null && Node.ELEMENT_NODE == currentNode.getNodeType())
-		getParentNameSpaces((Element)currentNode,ns);
-  	Node sibling=null;
-	Node parentNode=null;	
-	OutputStream writer=this._writer;
-	int documentLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
-	Map cache=new HashMap();
-	do {
-		switch (currentNode.getNodeType()) {
-		
-		case Node.DOCUMENT_TYPE_NODE :
-		default :
-			break;
-		
-		case Node.ENTITY_NODE :
-		case Node.NOTATION_NODE :
-		case Node.ATTRIBUTE_NODE :
-			// illegal node type during traversal
-			throw new CanonicalizationException("empty");
+        if (isVisibleInt(currentNode)==-1)
+                return;
+        boolean currentNodeIsVisible = false;	  
+        NameSpaceSymbTable ns=new  NameSpaceSymbTable();
+        if (currentNode != null && Node.ELEMENT_NODE == currentNode.getNodeType())
+                getParentNameSpaces((Element)currentNode,ns);
+        Node sibling=null;
+        Node parentNode=null;	
+        OutputStream writer=this._writer;
+        int documentLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
+        Map cache=new HashMap();
+        do {
+                switch (currentNode.getNodeType()) {
+                
+                case Node.DOCUMENT_TYPE_NODE :
+                default :
+                        break;
+                
+                case Node.ENTITY_NODE :
+                case Node.NOTATION_NODE :
+                case Node.ATTRIBUTE_NODE :
+                        // illegal node type during traversal
+                        throw new CanonicalizationException("empty");
 
         case Node.DOCUMENT_FRAGMENT_NODE :
-		case Node.DOCUMENT_NODE :
-			ns.outputNodePush();
-			//currentNode = currentNode.getFirstChild();  
-			sibling= currentNode.getFirstChild();
-			break;
-			
-		case Node.COMMENT_NODE :			
-			if (this._includeComments && (isVisibleDO(currentNode,ns.getLevel())==1)) {
-				outputCommentToWriter((Comment) currentNode, writer, documentLevel);
-			}
-			break;
-			
-		case Node.PROCESSING_INSTRUCTION_NODE :
-			if (isVisible(currentNode))
-				outputPItoWriter((ProcessingInstruction) currentNode, writer, documentLevel);
-			break;
-			
-		case Node.TEXT_NODE :
-		case Node.CDATA_SECTION_NODE :
-			if (isVisible(currentNode)) {
-			outputTextToWriter(currentNode.getNodeValue(), writer);
-			for (Node nextSibling = currentNode.getNextSibling();
+                case Node.DOCUMENT_NODE :
+                        ns.outputNodePush();
+                        //currentNode = currentNode.getFirstChild();  
+                        sibling= currentNode.getFirstChild();
+                        break;
+                        
+                case Node.COMMENT_NODE :			
+                        if (this._includeComments && (isVisibleDO(currentNode,ns.getLevel())==1)) {
+                                outputCommentToWriter((Comment) currentNode, writer, documentLevel);
+                        }
+                        break;
+                        
+                case Node.PROCESSING_INSTRUCTION_NODE :
+                        if (isVisible(currentNode))
+                                outputPItoWriter((ProcessingInstruction) currentNode, writer, documentLevel);
+                        break;
+                        
+                case Node.TEXT_NODE :
+                case Node.CDATA_SECTION_NODE :
+                        if (isVisible(currentNode)) {
+                        outputTextToWriter(currentNode.getNodeValue(), writer);
+                        for (Node nextSibling = currentNode.getNextSibling();
                     (nextSibling != null)
                     && ((nextSibling.getNodeType() == Node.TEXT_NODE)
                         || (nextSibling.getNodeType()
@@ -436,188 +436,188 @@ public abstract class CanonicalizerBase 
                currentNode=nextSibling;
                sibling=currentNode.getNextSibling();
             }
-			
-			}
-			break;
-			
-		case Node.ELEMENT_NODE :
-			documentLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
-			Element currentElement = (Element) currentNode;
-			//Add a level to the nssymbtable. So latter can be pop-back.
-			String name=null;
-			int i=isVisibleDO(currentNode,ns.getLevel());
-			if (i==-1) {
-				sibling= currentNode.getNextSibling();
-				break;
-			}
-			currentNodeIsVisible=(i==1);
-			if (currentNodeIsVisible) {
-				ns.outputNodePush();
-				writer.write('<');
-				name=currentElement.getTagName();
-				UtfHelpper.writeByte(name,writer,cache);
-			} else {
-				ns.push();
-			}
-			
-			Iterator attrs = handleAttributes(currentElement,ns);
-			if (attrs!=null) {
-				//we output all Attrs which are available
-				while (attrs.hasNext()) {
-					Attr attr = (Attr) attrs.next();
-					outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
-				}
-			}
-			if (currentNodeIsVisible) {
-				writer.write('>');
-			}
-			sibling= currentNode.getFirstChild(); 
-		
-			if (sibling==null) {
-				if (currentNodeIsVisible) {
-					writer.write(_END_TAG);
-					UtfHelpper.writeByte(name,writer,cache);        
-					writer.write('>');
-					//We fineshed with this level, pop to the previous definitions.
-					ns.outputNodePop();
-				} else {
-					ns.pop();
-				}				
-				if (parentNode != null) {
-    					sibling= currentNode.getNextSibling();
-				}
-			} else {
-				parentNode=currentElement;
-			}			
-			break;
-		}
-		while (sibling==null  && parentNode!=null) {    
-			if (isVisible(parentNode)) {
-				writer.write(_END_TAG);
-				UtfHelpper.writeByte(((Element)parentNode).getTagName(),writer,cache);        
-				writer.write('>');
-				//We fineshed with this level, pop to the previous definitions.
-				ns.outputNodePop();
-			} else {
-				ns.pop();
-			}
-			if (parentNode==endnode)
-				return;
-			sibling=parentNode.getNextSibling();
-			parentNode=parentNode.getParentNode();   
-			if (parentNode == null || Node.ELEMENT_NODE != parentNode.getNodeType()) {
-				parentNode=null;
-				documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
-			}    			
-		}      
-		if (sibling==null)
-			return;
-		currentNode=sibling;      
-		sibling=currentNode.getNextSibling();  
-	} while(true);
+                        
+                        }
+                        break;
+                        
+                case Node.ELEMENT_NODE :
+                        documentLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
+                        Element currentElement = (Element) currentNode;
+                        //Add a level to the nssymbtable. So latter can be pop-back.
+                        String name=null;
+                        int i=isVisibleDO(currentNode,ns.getLevel());
+                        if (i==-1) {
+                                sibling= currentNode.getNextSibling();
+                                break;
+                        }
+                        currentNodeIsVisible=(i==1);
+                        if (currentNodeIsVisible) {
+                                ns.outputNodePush();
+                                writer.write('<');
+                                name=currentElement.getTagName();
+                                UtfHelpper.writeByte(name,writer,cache);
+                        } else {
+                                ns.push();
+                        }
+                        
+                        Iterator attrs = handleAttributes(currentElement,ns);
+                        if (attrs!=null) {
+                                //we output all Attrs which are available
+                                while (attrs.hasNext()) {
+                                        Attr attr = (Attr) attrs.next();
+                                        outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
+                                }
+                        }
+                        if (currentNodeIsVisible) {
+                                writer.write('>');
+                        }
+                        sibling= currentNode.getFirstChild(); 
+                
+                        if (sibling==null) {
+                                if (currentNodeIsVisible) {
+                                        writer.write(_END_TAG);
+                                        UtfHelpper.writeByte(name,writer,cache);        
+                                        writer.write('>');
+                                        //We fineshed with this level, pop to the previous definitions.
+                                        ns.outputNodePop();
+                                } else {
+                                        ns.pop();
+                                }				
+                                if (parentNode != null) {
+                                        sibling= currentNode.getNextSibling();
+                                }
+                        } else {
+                                parentNode=currentElement;
+                        }			
+                        break;
+                }
+                while (sibling==null  && parentNode!=null) {    
+                        if (isVisible(parentNode)) {
+                                writer.write(_END_TAG);
+                                UtfHelpper.writeByte(((Element)parentNode).getTagName(),writer,cache);        
+                                writer.write('>');
+                                //We fineshed with this level, pop to the previous definitions.
+                                ns.outputNodePop();
+                        } else {
+                                ns.pop();
+                        }
+                        if (parentNode==endnode)
+                                return;
+                        sibling=parentNode.getNextSibling();
+                        parentNode=parentNode.getParentNode();   
+                        if (parentNode == null || Node.ELEMENT_NODE != parentNode.getNodeType()) {
+                                parentNode=null;
+                                documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
+                        }    			
+                }      
+                if (sibling==null)
+                        return;
+                currentNode=sibling;      
+                sibling=currentNode.getNextSibling();  
+        } while(true);
    }
    int isVisibleDO(Node currentNode,int level) {
-	   if (nodeFilter!=null) {
-	   		Iterator it=nodeFilter.iterator();
-	   		while (it.hasNext()) {   	
-	   			int i=((NodeFilter)it.next()).isNodeIncludeDO(currentNode,level);
-	   			if (i!=1)
-	   				return i;
-	   		}
-		   }
-	   if ((this._xpathNodeSet!=null) && !this._xpathNodeSet.contains(currentNode))
-  			return 0;
-	   return 1;
+           if (nodeFilter!=null) {
+                        Iterator it=nodeFilter.iterator();
+                        while (it.hasNext()) {   	
+                                int i=((NodeFilter)it.next()).isNodeIncludeDO(currentNode,level);
+                                if (i!=1)
+                                        return i;
+                        }
+                   }
+           if ((this._xpathNodeSet!=null) && !this._xpathNodeSet.contains(currentNode))
+                        return 0;
+           return 1;
    }
    int isVisibleInt(Node currentNode) {
-	   if (nodeFilter!=null) {
-   		Iterator it=nodeFilter.iterator();
-   		while (it.hasNext()) {   			
-   			int i=((NodeFilter)it.next()).isNodeInclude(currentNode);
-   			if (i!=1)
-   				return i;
-   		}
-	   }
-   		if ((this._xpathNodeSet!=null) && !this._xpathNodeSet.contains(currentNode))
-   			return 0;
-   		return 1;
-   	}
+           if (nodeFilter!=null) {
+                Iterator it=nodeFilter.iterator();
+                while (it.hasNext()) {   			
+                        int i=((NodeFilter)it.next()).isNodeInclude(currentNode);
+                        if (i!=1)
+                                return i;
+                }
+           }
+                if ((this._xpathNodeSet!=null) && !this._xpathNodeSet.contains(currentNode))
+                        return 0;
+                return 1;
+        }
    
    boolean isVisible(Node currentNode) {
-	   if (nodeFilter!=null) {
-   		Iterator it=nodeFilter.iterator();
-   		while (it.hasNext()) {   			
-   			if (((NodeFilter)it.next()).isNodeInclude(currentNode)!=1)
-   				return false;
-   		}
-	   }
-   		if ((this._xpathNodeSet!=null) && !this._xpathNodeSet.contains(currentNode))
-   			return false;
-   		return true;
-   	}
-
-	void handleParent(Element e,NameSpaceSymbTable ns) {
-	   if (!e.hasAttributes()) {
-				return;
-		}
-		NamedNodeMap attrs = e.getAttributes();
-		int attrsLength = attrs.getLength();
-		for (int i = 0; i < attrsLength; i++) {
-			Attr N = (Attr) attrs.item(i);
-			if (!Constants.NamespaceSpecNS.equals(N.getNamespaceURI())) {
-				//Not a namespace definition, ignore.
-				continue;
-			}
-
-			String NName=N.getLocalName();
-			String NValue=N.getNodeValue();
-			if (XML.equals(NName)
+           if (nodeFilter!=null) {
+                Iterator it=nodeFilter.iterator();
+                while (it.hasNext()) {   			
+                        if (((NodeFilter)it.next()).isNodeInclude(currentNode)!=1)
+                                return false;
+                }
+           }
+                if ((this._xpathNodeSet!=null) && !this._xpathNodeSet.contains(currentNode))
+                        return false;
+                return true;
+        }
+
+        void handleParent(Element e,NameSpaceSymbTable ns) {
+           if (!e.hasAttributes()) {
+                                return;
+                }
+                NamedNodeMap attrs = e.getAttributes();
+                int attrsLength = attrs.getLength();
+                for (int i = 0; i < attrsLength; i++) {
+                        Attr N = (Attr) attrs.item(i);
+                        if (!Constants.NamespaceSpecNS.equals(N.getNamespaceURI())) {
+                                //Not a namespace definition, ignore.
+                                continue;
+                        }
+
+                        String NName=N.getLocalName();
+                        String NValue=N.getNodeValue();
+                        if (XML.equals(NName)
                && Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
-					continue;
-			}            
-			ns.addMapping(NName,NValue,N);             
-		}   			
+                                        continue;
+                        }            
+                        ns.addMapping(NName,NValue,N);             
+                }   			
    }
 
-	/**
-	 * Adds to ns the definitons from the parent elements of el
-   	 * @param el
-   	 * @param ns
-   	 */
-   	final void getParentNameSpaces(Element el,NameSpaceSymbTable ns)  {
-   		List parents=new ArrayList(10);
-   		Node n1=el.getParentNode();
-   		if (n1 == null || Node.ELEMENT_NODE != n1.getNodeType()) {
-   			return;
-   		}
-   		//Obtain all the parents of the elemnt
-   		Element parent=(Element) n1;
-   		while (parent!=null) {
-   			parents.add(parent);
-   			Node n=parent.getParentNode();
-   			if (n == null || Node.ELEMENT_NODE != n.getNodeType()) {
-   				break;
-   			}
-   			parent=(Element)n;
-   		}
-   		//Visit them in reverse order.
-   		ListIterator it=parents.listIterator(parents.size());
-   		while (it.hasPrevious()) {
-   			Element ele=(Element)it.previous();
-   			handleParent(ele, ns);
-      	}
+        /**
+         * Adds to ns the definitons from the parent elements of el
+         * @param el
+         * @param ns
+         */
+        final void getParentNameSpaces(Element el,NameSpaceSymbTable ns)  {
+                List parents=new ArrayList(10);
+                Node n1=el.getParentNode();
+                if (n1 == null || Node.ELEMENT_NODE != n1.getNodeType()) {
+                        return;
+                }
+                //Obtain all the parents of the elemnt
+                Element parent=(Element) n1;
+                while (parent!=null) {
+                        parents.add(parent);
+                        Node n=parent.getParentNode();
+                        if (n == null || Node.ELEMENT_NODE != n.getNodeType()) {
+                                break;
+                        }
+                        parent=(Element)n;
+                }
+                //Visit them in reverse order.
+                ListIterator it=parents.listIterator(parents.size());
+                while (it.hasPrevious()) {
+                        Element ele=(Element)it.previous();
+                        handleParent(ele, ns);
+        }
         Attr nsprefix;
         if (((nsprefix=ns.getMappingWithoutRendered("xmlns"))!=null) 
                 && "".equals(nsprefix.getValue())) {
              ns.addMappingAndRender("xmlns","",nullNode);
         }
-   	}
+        }
    /**
     * Obtain the attributes to output for this node in XPathNodeSet c14n. 
     *
     * @param E
-	* @param ns
-	* @return the attributes nodes to output.
+        * @param ns
+        * @return the attributes nodes to output.
     * @throws CanonicalizationException
     */
    abstract Iterator handleAttributes(Element E, NameSpaceSymbTable ns )
@@ -627,8 +627,8 @@ public abstract class CanonicalizerBase 
     * Obtain the attributes to output for this node in a Subtree c14n.
     *
     * @param E
-	* @param ns
-	* @return the attributes nodes to output.
+        * @param ns
+        * @return the attributes nodes to output.
     * @throws CanonicalizationException
     */
    abstract Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
@@ -637,204 +637,204 @@ public abstract class CanonicalizerBase 
    abstract void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException;
    
    /**
-	    * Outputs an Attribute to the internal Writer.
-	    *
-	    * The string value of the node is modified by replacing
-	    * <UL>
-	    * <LI>all ampersands (&) with <CODE>&amp;amp;</CODE></LI>
-	    * <LI>all open angle brackets (<) with <CODE>&amp;lt;</CODE></LI>
-	    * <LI>all quotation mark characters with <CODE>&amp;quot;</CODE></LI>
-	    * <LI>and the whitespace characters <CODE>#x9</CODE>, #xA, and #xD, with character
-	    * references. The character references are written in uppercase
-	    * hexadecimal with no leading zeroes (for example, <CODE>#xD</CODE> is represented
-	    * by the character reference <CODE>&amp;#xD;</CODE>)</LI>
-	    * </UL>
-	    *
-	    * @param name
-	    * @param value
-	    * @param writer 
-	    * @throws IOException
-	    */
-	   static final void outputAttrToWriter(final String name, final String value, final OutputStream writer,
-			   	final Map cache) throws IOException {
-	      writer.write(' ');
-	      UtfHelpper.writeByte(name,writer,cache);
-	      writer.write(equalsStr);
-	      byte  []toWrite;
-	      final int length = value.length();
-	      int i=0;
-	      while (i < length) {        
-	         char c = value.charAt(i++);
-	
-	         switch (c) {
-	
-	         case '&' :
-	         	toWrite=_AMP_;
-	            break;
-	
-	         case '<' :
-	         	toWrite=_LT_;
-	            break;
-	
-	         case '"' :
-	         	toWrite=_QUOT_;
-	            break;
-	
-	         case 0x09 :    // '\t'
-	         	toWrite=__X9_;
-	            break;
-	
-	         case 0x0A :    // '\n'
-	         	toWrite=__XA_;
-	            break;
-	
-	         case 0x0D :    // '\r'
-	         	toWrite=__XD_;
-	            break;
-	
-	         default :
-	        	if (c < 0x80 ) {
-	        		writer.write(c);
-	        	} else {
-	        		UtfHelpper.writeCharToUtf8(c,writer);
-	        	};
-	            continue;
-	         }
-	         writer.write(toWrite);
-	      }
-	
-	      writer.write('\"');
-	   }
-
-	/**
-	    * Outputs a PI to the internal Writer.
-	    *
-	    * @param currentPI
-	    * @param writer where to write the things
-	    * @throws IOException
-	    */
-	   static final void outputPItoWriter(ProcessingInstruction currentPI, OutputStream writer,int position) throws IOException {   	  
-	
-	      if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
-	        writer.write('\n');
-	      }
-	      writer.write(_BEGIN_PI);
-	
-	      final String target = currentPI.getTarget();
-	      int length = target.length();
-	
-	      for (int i = 0; i < length; i++) {         
-	      	 char c=target.charAt(i);
-	         if (c==0x0D) {
-	            writer.write(__XD_);
-	         } else {
-	        	 if (c < 0x80)  {
-	         		writer.write(c);
-	         	} else {
-	         		UtfHelpper.writeCharToUtf8(c,writer);
-	         	};           
-	         }
-	      }
-	
-	      final String data = currentPI.getData();
-	     
-	      length = data.length();
-	
-	      if (length > 0) {
-	         writer.write(' ');
-	
-	         for (int i = 0; i < length; i++) {            
-	         	char c=data.charAt(i);
-	            if (c==0x0D) {
-	               writer.write(__XD_);
-	            } else {
-	            	UtfHelpper.writeCharToUtf8(c,writer);               
-	            }
-	         }
-	      }
-	
-	      writer.write(_END_PI);
-	      if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
-	        writer.write('\n');
-	     }
-	   }
-
-	   /**
-	    * Method outputCommentToWriter
-	    *
-	    * @param currentComment
-	    * @param writer writer where to write the things
-	    * @throws IOException
-	    */
-	   static final void outputCommentToWriter(Comment currentComment, OutputStream writer,int position) throws IOException {   	  
-	   	  if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
-	   		writer.write('\n');
-	   	  }
-	      writer.write(_BEGIN_COMM);
-	
-	      final String data = currentComment.getData();
-	      final int length = data.length();      
-	
-	      for (int i = 0; i < length; i++) {         
-	         char c=data.charAt(i);
-	         if (c==0x0D) {
-	            writer.write(__XD_);
-	         } else {
-	        	 if (c < 0x80)  {
-	         		writer.write(c);
-	         	} else {
-	         		UtfHelpper.writeCharToUtf8(c,writer);
-	         	};               
-	         }      
-	      }
-	
-	      writer.write(_END_COMM);
-	      if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
-			writer.write('\n');
-		 }
-	   }
-
-	   /**
-	    * Outputs a Text of CDATA section to the internal Writer.
-	    *
-	    * @param text
-	    * @param writer writer where to write the things
-	    * @throws IOException
-	    */
-	   static final void outputTextToWriter(final String text, final OutputStream writer) throws IOException {
-	      final int length = text.length();
-	      byte []toWrite;
-	      for (int i = 0; i < length; i++) {
-	         char c = text.charAt(i);
-	
-	         switch (c) {
-	
-	         case '&' :
-	         	toWrite=_AMP_;
-	            break;
-	
-	         case '<' :
-	         	toWrite=_LT_;
-	            break;
-	
-	         case '>' :
-	         	toWrite=_GT_;
-	            break;
-	
-	         case 0xD :
-	         	toWrite=__XD_;
-	            break;
-	
-	         default :
-	        	 if (c < 0x80) {
-	        		 writer.write(c);
-	        	 } else {
-	        		 UtfHelpper.writeCharToUtf8(c,writer);
-	        	 };
-	            continue;
-	         }
-	         writer.write(toWrite);
-	      }
-	   }
+            * Outputs an Attribute to the internal Writer.
+            *
+            * The string value of the node is modified by replacing
+            * <UL>
+            * <LI>all ampersands (&) with <CODE>&amp;amp;</CODE></LI>
+            * <LI>all open angle brackets (<) with <CODE>&amp;lt;</CODE></LI>
+            * <LI>all quotation mark characters with <CODE>&amp;quot;</CODE></LI>
+            * <LI>and the whitespace characters <CODE>#x9</CODE>, #xA, and #xD, with character
+            * references. The character references are written in uppercase
+            * hexadecimal with no leading zeroes (for example, <CODE>#xD</CODE> is represented
+            * by the character reference <CODE>&amp;#xD;</CODE>)</LI>
+            * </UL>
+            *
+            * @param name
+            * @param value
+            * @param writer 
+            * @throws IOException
+            */
+           static final void outputAttrToWriter(final String name, final String value, final OutputStream writer,
+                                final Map cache) throws IOException {
+              writer.write(' ');
+              UtfHelpper.writeByte(name,writer,cache);
+              writer.write(equalsStr);
+              byte  []toWrite;
+              final int length = value.length();
+              int i=0;
+              while (i < length) {        
+                 char c = value.charAt(i++);
+        
+                 switch (c) {
+        
+                 case '&' :
+                        toWrite=_AMP_;
+                    break;
+        
+                 case '<' :
+                        toWrite=_LT_;
+                    break;
+        
+                 case '"' :
+                        toWrite=_QUOT_;
+                    break;
+        
+                 case 0x09 :    // '\t'
+                        toWrite=__X9_;
+                    break;
+        
+                 case 0x0A :    // '\n'
+                        toWrite=__XA_;
+                    break;
+        
+                 case 0x0D :    // '\r'
+                        toWrite=__XD_;
+                    break;
+        
+                 default :
+                        if (c < 0x80 ) {
+                                writer.write(c);
+                        } else {
+                                UtfHelpper.writeCharToUtf8(c,writer);
+                        };
+                    continue;
+                 }
+                 writer.write(toWrite);
+              }
+        
+              writer.write('\"');
+           }
+
+        /**
+            * Outputs a PI to the internal Writer.
+            *
+            * @param currentPI
+            * @param writer where to write the things
+            * @throws IOException
+            */
+           static final void outputPItoWriter(ProcessingInstruction currentPI, OutputStream writer,int position) throws IOException {   	  
+        
+              if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
+                writer.write('\n');
+              }
+              writer.write(_BEGIN_PI);
+        
+              final String target = currentPI.getTarget();
+              int length = target.length();
+        
+              for (int i = 0; i < length; i++) {         
+                 char c=target.charAt(i);
+                 if (c==0x0D) {
+                    writer.write(__XD_);
+                 } else {
+                         if (c < 0x80)  {
+                                writer.write(c);
+                        } else {
+                                UtfHelpper.writeCharToUtf8(c,writer);
+                        };           
+                 }
+              }
+        
+              final String data = currentPI.getData();
+             
+              length = data.length();
+        
+              if (length > 0) {
+                 writer.write(' ');
+        
+                 for (int i = 0; i < length; i++) {            
+                        char c=data.charAt(i);
+                    if (c==0x0D) {
+                       writer.write(__XD_);
+                    } else {
+                        UtfHelpper.writeCharToUtf8(c,writer);               
+                    }
+                 }
+              }
+        
+              writer.write(_END_PI);
+              if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
+                writer.write('\n');
+             }
+           }
+
+           /**
+            * Method outputCommentToWriter
+            *
+            * @param currentComment
+            * @param writer writer where to write the things
+            * @throws IOException
+            */
+           static final void outputCommentToWriter(Comment currentComment, OutputStream writer,int position) throws IOException {   	  
+                  if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
+                        writer.write('\n');
+                  }
+              writer.write(_BEGIN_COMM);
+        
+              final String data = currentComment.getData();
+              final int length = data.length();      
+        
+              for (int i = 0; i < length; i++) {         
+                 char c=data.charAt(i);
+                 if (c==0x0D) {
+                    writer.write(__XD_);
+                 } else {
+                         if (c < 0x80)  {
+                                writer.write(c);
+                        } else {
+                                UtfHelpper.writeCharToUtf8(c,writer);
+                        };               
+                 }      
+              }
+        
+              writer.write(_END_COMM);
+              if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
+                        writer.write('\n');
+                 }
+           }
+
+           /**
+            * Outputs a Text of CDATA section to the internal Writer.
+            *
+            * @param text
+            * @param writer writer where to write the things
+            * @throws IOException
+            */
+           static final void outputTextToWriter(final String text, final OutputStream writer) throws IOException {
+              final int length = text.length();
+              byte []toWrite;
+              for (int i = 0; i < length; i++) {
+                 char c = text.charAt(i);
+        
+                 switch (c) {
+        
+                 case '&' :
+                        toWrite=_AMP_;
+                    break;
+        
+                 case '<' :
+                        toWrite=_LT_;
+                    break;
+        
+                 case '>' :
+                        toWrite=_GT_;
+                    break;
+        
+                 case 0xD :
+                        toWrite=__XD_;
+                    break;
+        
+                 default :
+                         if (c < 0x80) {
+                                 writer.write(c);
+                         } else {
+                                 UtfHelpper.writeCharToUtf8(c,writer);
+                         };
+                    continue;
+                 }
+                 writer.write(toWrite);
+              }
+           }
      
 }

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java Thu Jan 27 11:11:33 2011
@@ -34,182 +34,182 @@ import org.w3c.dom.Node;
  * @author Raul Benito
  **/
 public class NameSpaceSymbTable {
-	
-	/**The map betwen prefix-> entry table. */
-	SymbMap symb;
-	/**The level of nameSpaces (for Inclusive visibility).*/
-	int nameSpaces=0;
-	/**The stacks for removing the definitions when doing pop.*/
-	List level;
+        
+        /**The map betwen prefix-> entry table. */
+        SymbMap symb;
+        /**The level of nameSpaces (for Inclusive visibility).*/
+        int nameSpaces=0;
+        /**The stacks for removing the definitions when doing pop.*/
+        List level;
     boolean cloned=true;	
-	static final String XMLNS="xmlns";
-	final static SymbMap initialMap=new SymbMap();
-	static {
-		NameSpaceSymbEntry ne=new NameSpaceSymbEntry("",null,true,XMLNS);
-		ne.lastrendered="";		
-		initialMap.put(XMLNS,ne);
-	}
+        static final String XMLNS="xmlns";
+        final static SymbMap initialMap=new SymbMap();
+        static {
+                NameSpaceSymbEntry ne=new NameSpaceSymbEntry("",null,true,XMLNS);
+                ne.lastrendered="";		
+                initialMap.put(XMLNS,ne);
+        }
     /**
      * Default constractor
      **/		
     public NameSpaceSymbTable() {    	
-    	level = new ArrayList(10);
-    	//Insert the default binding for xmlns.    	
-    	symb=(SymbMap) initialMap.clone();
+        level = new ArrayList(10);
+        //Insert the default binding for xmlns.    	
+        symb=(SymbMap) initialMap.clone();
     }
     
     /**
-	 * Get all the unrendered nodes in the name space.
-	 * For Inclusive rendering
+         * Get all the unrendered nodes in the name space.
+         * For Inclusive rendering
      * @param result the list where to fill the unrendered xmlns definitions.
-	 **/       
-	public  void getUnrenderedNodes(Collection result) {		
-	   //List result=new ArrayList();
-	   Iterator it=symb.entrySet().iterator();
-	   while (it.hasNext()) {	   	   
-	   		NameSpaceSymbEntry n=(NameSpaceSymbEntry)(it.next());
-	   		//put them rendered?
-	   		if ((!n.rendered) && (n.n!=null)) {
-	   			n=(NameSpaceSymbEntry) n.clone();
+         **/       
+        public  void getUnrenderedNodes(Collection result) {		
+           //List result=new ArrayList();
+           Iterator it=symb.entrySet().iterator();
+           while (it.hasNext()) {	   	   
+                        NameSpaceSymbEntry n=(NameSpaceSymbEntry)(it.next());
+                        //put them rendered?
+                        if ((!n.rendered) && (n.n!=null)) {
+                                n=(NameSpaceSymbEntry) n.clone();
                 needsClone();
                 symb.put(n.prefix,n);         
                 n.lastrendered=n.uri;
                 n.rendered=true;
                 
-	   			result.add(n.n);
-	   			
-	   		}
-	   }	   
-	}
-	
-	/**
+                                result.add(n.n);
+                                
+                        }
+           }	   
+        }
+        
+        /**
      * Push a frame for visible namespace. 
      * For Inclusive rendering.
      **/
-	public void outputNodePush() {
-		nameSpaces++;
-		push();
-	}
-	
-	/**
+        public void outputNodePush() {
+                nameSpaces++;
+                push();
+        }
+        
+        /**
      * Pop a frame for visible namespace.
      **/
-	public void outputNodePop() {
-		nameSpaces--;
-		pop();
-	}
-	
-	/**
+        public void outputNodePop() {
+                nameSpaces--;
+                pop();
+        }
+        
+        /**
      * Push a frame for a node.
      * Inclusive or Exclusive.
      **/
-	public void push() {		
-		//Put the number of namespace definitions in the stack.
+        public void push() {		
+                //Put the number of namespace definitions in the stack.
         level.add(null);
         cloned=false;
-	}
-	
-	/**
+        }
+        
+        /**
      * Pop a frame.
      * Inclusive or Exclusive.
      **/
-	public void pop() {
+        public void pop() {
         int size=level.size()-1;
         Object ob= level.remove(size);
         if (ob!=null) {
-        	symb=(SymbMap)ob;
+                symb=(SymbMap)ob;
             if (size==0) {
                cloned=false;   
             } else
-            	cloned=(level.get(size-1)!=symb);
+                cloned=(level.get(size-1)!=symb);
         } else {
-        	cloned=false;
+                cloned=false;
         }
         
         
-	}
-	
-	final void needsClone() {
-		if (!cloned) {			
+        }
+        
+        final void needsClone() {
+                if (!cloned) {			
             level.set(level.size()-1,symb);
-			symb=(SymbMap) symb.clone();
+                        symb=(SymbMap) symb.clone();
             cloned=true;
         }
     }
-	
-	
-	/**
-	 * Gets the attribute node that defines the binding for the prefix.      
+        
+        
+        /**
+         * Gets the attribute node that defines the binding for the prefix.      
      * @param prefix the prefix to obtain the attribute.
      * @return null if there is no need to render the prefix. Otherwise the node of
      * definition.
      **/
-	public Attr getMapping(String prefix) {					
-		NameSpaceSymbEntry entry=symb.get(prefix);
-		if (entry==null) {
-			//There is no definition for the prefix(a bug?).
-			return null;
-		}
-		if (entry.rendered) {		
-			//No need to render an entry already rendered.
-			return null;		
-		}
-		// Mark this entry as render.
+        public Attr getMapping(String prefix) {					
+                NameSpaceSymbEntry entry=symb.get(prefix);
+                if (entry==null) {
+                        //There is no definition for the prefix(a bug?).
+                        return null;
+                }
+                if (entry.rendered) {		
+                        //No need to render an entry already rendered.
+                        return null;		
+                }
+                // Mark this entry as render.
         entry=(NameSpaceSymbEntry) entry.clone();
         needsClone();
         symb.put(prefix,entry);
-		entry.rendered=true;
-		entry.level=nameSpaces;
-		entry.lastrendered=entry.uri;				
-		// Return the node for outputing.
-		return entry.n;
-	}
-	
-	/**
+                entry.rendered=true;
+                entry.level=nameSpaces;
+                entry.lastrendered=entry.uri;				
+                // Return the node for outputing.
+                return entry.n;
+        }
+        
+        /**
      * Gets a definition without mark it as render. 
      * For render in exclusive c14n the namespaces in the include prefixes.
      * @param prefix The prefix whose definition is neaded.
      * @return the attr to render, null if there is no need to render
      **/
-	public Attr getMappingWithoutRendered(String prefix) {					
-		NameSpaceSymbEntry entry= symb.get(prefix);
-		if (entry==null) {		   
-			return null;
-		}
-		if (entry.rendered) {		
-			return null;		
-		}
-		return entry.n;
-	}
-	
-	/**
+        public Attr getMappingWithoutRendered(String prefix) {					
+                NameSpaceSymbEntry entry= symb.get(prefix);
+                if (entry==null) {		   
+                        return null;
+                }
+                if (entry.rendered) {		
+                        return null;		
+                }
+                return entry.n;
+        }
+        
+        /**
      * Adds the mapping for a prefix.
      * @param prefix the prefix of definition
      * @param uri the Uri of the definition
      * @param n the attribute that have the definition
      * @return true if there is already defined.
      **/
-	public boolean addMapping(String prefix, String uri,Attr n) {						
-		NameSpaceSymbEntry ob = symb.get(prefix);		
-		if ((ob!=null) && uri.equals(ob.uri)) {
-			//If we have it previously defined. Don't keep working.
-			return false;
-		}			
-		//Creates and entry in the table for this new definition.
-		NameSpaceSymbEntry ne=new NameSpaceSymbEntry(uri,n,false,prefix);		
+        public boolean addMapping(String prefix, String uri,Attr n) {						
+                NameSpaceSymbEntry ob = symb.get(prefix);		
+                if ((ob!=null) && uri.equals(ob.uri)) {
+                        //If we have it previously defined. Don't keep working.
+                        return false;
+                }			
+                //Creates and entry in the table for this new definition.
+                NameSpaceSymbEntry ne=new NameSpaceSymbEntry(uri,n,false,prefix);		
         needsClone();
-		symb.put(prefix, ne);
-		if (ob != null) {
-			//We have a previous definition store it for the pop.			
-			//Check if a previous definition(not the inmidiatly one) has been rendered.			
-			ne.lastrendered=ob.lastrendered;			
-			if ((ob.lastrendered!=null)&& (ob.lastrendered.equals(uri))) {
-				//Yes it is. Mark as rendered.
-				ne.rendered=true;
-			}			
-		} 			
+                symb.put(prefix, ne);
+                if (ob != null) {
+                        //We have a previous definition store it for the pop.			
+                        //Check if a previous definition(not the inmidiatly one) has been rendered.			
+                        ne.lastrendered=ob.lastrendered;			
+                        if ((ob.lastrendered!=null)&& (ob.lastrendered.equals(uri))) {
+                                //Yes it is. Mark as rendered.
+                                ne.rendered=true;
+                        }			
+                } 			
         return true;
-	}
+        }
 
     /**
      * Adds a definition and mark it as render.
@@ -248,38 +248,38 @@ public class NameSpaceSymbTable {
         return ne.n;
     }
 
-	public int getLevel() {
-		// TODO Auto-generated method stub
-		return level.size();
-	}
+        public int getLevel() {
+                // TODO Auto-generated method stub
+                return level.size();
+        }
 
-	public void removeMapping(String prefix) {
-		NameSpaceSymbEntry ob = symb.get(prefix);
+        public void removeMapping(String prefix) {
+                NameSpaceSymbEntry ob = symb.get(prefix);
         
         if (ob!=null) {
             needsClone();
             symb.put(prefix,null);         
         }
-	}
+        }
 
-	public void removeMappingIfNotRender(String prefix) {
-		NameSpaceSymbEntry ob = symb.get(prefix);
+        public void removeMappingIfNotRender(String prefix) {
+                NameSpaceSymbEntry ob = symb.get(prefix);
         
         if (ob!=null && !ob.rendered) {
             needsClone();
             symb.put(prefix,null);         
         }
-	}
+        }
 
-	public boolean removeMappingIfRender(String prefix) {
-		NameSpaceSymbEntry ob = symb.get(prefix);
+        public boolean removeMappingIfRender(String prefix) {
+                NameSpaceSymbEntry ob = symb.get(prefix);
         
         if (ob!=null && ob.rendered) {
             needsClone();
             symb.put(prefix,null);         
         }
         return false;
-	}
+        }
 }
 
 /**
@@ -317,10 +317,10 @@ class SymbMap implements Cloneable {
     int free=23;
     NameSpaceSymbEntry[] entries;
     String[] keys;
-	SymbMap() {
-		entries=new NameSpaceSymbEntry[free];
-		keys=new String[free];
-	}
+        SymbMap() {
+                entries=new NameSpaceSymbEntry[free];
+                keys=new String[free];
+        }
     void put(String key, NameSpaceSymbEntry value) {		
         int index = index(key);
         Object oldKey = keys[index];
@@ -328,21 +328,21 @@ class SymbMap implements Cloneable {
         entries[index] = value;
         if (oldKey==null || !oldKey.equals(key)) {	        	        
             if (--free == 0) {
-            	free=entries.length;
-            	int newCapacity = free<<2;				
-            	rehash(newCapacity);			
+                free=entries.length;
+                int newCapacity = free<<2;				
+                rehash(newCapacity);			
             }
         }
     }
-	
+        
     List entrySet() {
-    	List a=new ArrayList();
-    	for (int i=0;i<entries.length;i++) {
-    		if ((entries[i]!=null) && !("".equals(entries[i].uri))) {
-    			a.add(entries[i]);
-	    }
-    	}
-    	return a;		
+        List a=new ArrayList();
+        for (int i=0;i<entries.length;i++) {
+                if ((entries[i]!=null) && !("".equals(entries[i].uri))) {
+                        a.add(entries[i]);
+            }
+        }
+        return a;		
     }
 
     protected int index(Object obj) {		
@@ -353,12 +353,12 @@ class SymbMap implements Cloneable {
         Object cur = set[index];
 
         if (cur == null || (cur.equals( obj))) {
-        	return index;
+                return index;
         }
         length=length-1;
         do {
-        	index=index==length? 0:++index;
-        	cur = set[index];
+                index=index==length? 0:++index;
+                cur = set[index];
         } while (cur != null && (!cur.equals(obj)));       
         return index;
     }
@@ -391,18 +391,18 @@ class SymbMap implements Cloneable {
     }
 
     protected Object clone()  {
-    	try {
-    		SymbMap copy=(SymbMap) super.clone();
-    		copy.entries=new NameSpaceSymbEntry[entries.length];
-    		System.arraycopy(entries,0,copy.entries,0,entries.length);
-    		copy.keys=new String[keys.length];
-    		System.arraycopy(keys,0,copy.keys,0,keys.length);
-			
-    		return copy;
-	} catch (CloneNotSupportedException e) {
-	    // TODO Auto-generated catch block
-	    e.printStackTrace();
-	}
-	return null;
+        try {
+                SymbMap copy=(SymbMap) super.clone();
+                copy.entries=new NameSpaceSymbEntry[entries.length];
+                System.arraycopy(entries,0,copy.entries,0,entries.length);
+                copy.keys=new String[keys.length];
+                System.arraycopy(keys,0,copy.keys,0,keys.length);
+                        
+                return copy;
+        } catch (CloneNotSupportedException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return null;
     }
 }

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/UtfHelpper.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/UtfHelpper.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/UtfHelpper.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/UtfHelpper.java Thu Jan 27 11:11:33 2011
@@ -22,150 +22,150 @@ import java.util.Map;
 
 public class UtfHelpper {
 
-	final static void writeByte(final String str,final OutputStream out,Map cache) throws IOException {
-		   byte []result=(byte[]) cache.get(str);	 
-		   if (result==null) {
-			   result=getStringInUtf8(str);
-			   cache.put(str,result);
-		   }
-		   
-		   out.write(result);
-		   
-	   }
-
-	final static void writeCharToUtf8(final char c,final OutputStream out) throws IOException{   	
-	   	if (c < 0x80) {
-	        out.write(c);
-	        return;
-	    }
-	   	if ((c >= 0xD800 && c <= 0xDBFF) || (c >= 0xDC00 && c <= 0xDFFF) ){
-        	//No Surrogates in sun java
-        	out.write(0x3f);
-        	return;
+        final static void writeByte(final String str,final OutputStream out,Map cache) throws IOException {
+                   byte []result=(byte[]) cache.get(str);	 
+                   if (result==null) {
+                           result=getStringInUtf8(str);
+                           cache.put(str,result);
+                   }
+                   
+                   out.write(result);
+                   
+           }
+
+        final static void writeCharToUtf8(final char c,final OutputStream out) throws IOException{   	
+                if (c < 0x80) {
+                out.write(c);
+                return;
+            }
+                if ((c >= 0xD800 && c <= 0xDBFF) || (c >= 0xDC00 && c <= 0xDFFF) ){
+                //No Surrogates in sun java
+                out.write(0x3f);
+                return;
         }
-	    int bias;
-	    int write;
-	    char ch;
-	    if (c > 0x07FF) {
-	        ch=(char)(c>>>12);      
-	        write=0xE0;
-	        if (ch>0) {
-	            write |= ( ch & 0x0F);
-	        } 
-	        out.write(write);
-	        write=0x80;
-	        bias=0x3F;        
-	    } else {
-	    	write=0xC0;
-	    	bias=0x1F;
-	    }
-	    ch=(char)(c>>>6);
-	    if (ch>0) {
-	         write|= (ch & bias);
-	    } 
-	    out.write(write);
-	    out.write(0x80 | ((c) & 0x3F));    
-	   	
-	   }
-
-	final static void writeStringToUtf8(final String str,final OutputStream out) throws IOException{	   
-	   	final int length=str.length();
-	   	int i=0;
-	    char c;    
-	   	while (i<length) {
-	   		c=str.charAt(i++);        
-	        if (c < 0x80)  {
-	            out.write(c);
-	            continue;
-	        }
-	        if ((c >= 0xD800 && c <= 0xDBFF) || (c >= 0xDC00 && c <= 0xDFFF) ){
-	        	//No Surrogates in sun java
-	        	out.write(0x3f);
-	        	continue;
-	        }
-	        char ch;
-	        int bias;
-	        int write;
-	        if (c > 0x07FF) {
-	            ch=(char)(c>>>12);      
-	            write=0xE0;
-	            if (ch>0) {
-	                write |= ( ch & 0x0F);
-	            } 
-	            out.write(write);
-	            write=0x80;
-	            bias=0x3F;        
-	        } else {
-	        	write=0xC0;
-	        	bias=0x1F;
-	        }
-	        ch=(char)(c>>>6);
-	        if (ch>0) {
-	             write|= (ch & bias);
-	        } 
-	        out.write(write);
-	        out.write(0x80 | ((c) & 0x3F));       
-	           		
-	   	}
-	    
-	   }
-	public final static byte[] getStringInUtf8(final String str) {
-		   final int length=str.length();
-		   boolean expanded=false;
-		   byte []result=new byte[length];
-		   	int i=0;
-		   	int out=0;
-		    char c;    
-		   	while (i<length) {
-		   		c=str.charAt(i++);        
-		        if ( c < 0x80 ) {
-		            result[out++]=(byte)c;
-		            continue;
-		        }
-		        if ((c >= 0xD800 && c <= 0xDBFF) || (c >= 0xDC00 && c <= 0xDFFF) ){  	
-		        	   //No Surrogates in sun java
-		        	   result[out++]=0x3f;
-		        	
-		        	continue;
-		        }
-		        if (!expanded) {
-		        	byte newResult[]=new byte[3*length];
-				   	System.arraycopy(result, 0, newResult, 0, out);				   	    	
-				   	result=newResult;
-				   	expanded=true;
-		        } 
-		        char ch;
-		        int bias;
-		        byte write;
-		        if (c > 0x07FF) {
-		            ch=(char)(c>>>12);      
-		            write=(byte)0xE0;
-		            if (ch>0) {
-		                write |= ( ch & 0x0F);
-		            } 
-		            result[out++]=write;
-		            write=(byte)0x80;
-		            bias=0x3F;        
-		        } else {
-		        	write=(byte)0xC0;
-		        	bias=0x1F;
-		        }
-		        ch=(char)(c>>>6);
-		        if (ch>0) {
-		             write|= (ch & bias);
-		        } 
-		        result[out++]=write;
-		        result[out++]=(byte)(0x80 | ((c) & 0x3F));/**/       
-		          		
-		   	}
-		   	if (expanded) {
-		   		byte newResult[]=new byte[out];
-		   		System.arraycopy(result, 0, newResult, 0, out);
-		   		result=newResult;
-		   	}
-		   	return result;
-	   }
+            int bias;
+            int write;
+            char ch;
+            if (c > 0x07FF) {
+                ch=(char)(c>>>12);      
+                write=0xE0;
+                if (ch>0) {
+                    write |= ( ch & 0x0F);
+                } 
+                out.write(write);
+                write=0x80;
+                bias=0x3F;        
+            } else {
+                write=0xC0;
+                bias=0x1F;
+            }
+            ch=(char)(c>>>6);
+            if (ch>0) {
+                 write|= (ch & bias);
+            } 
+            out.write(write);
+            out.write(0x80 | ((c) & 0x3F));    
+                
+           }
+
+        final static void writeStringToUtf8(final String str,final OutputStream out) throws IOException{	   
+                final int length=str.length();
+                int i=0;
+            char c;    
+                while (i<length) {
+                        c=str.charAt(i++);        
+                if (c < 0x80)  {
+                    out.write(c);
+                    continue;
+                }
+                if ((c >= 0xD800 && c <= 0xDBFF) || (c >= 0xDC00 && c <= 0xDFFF) ){
+                        //No Surrogates in sun java
+                        out.write(0x3f);
+                        continue;
+                }
+                char ch;
+                int bias;
+                int write;
+                if (c > 0x07FF) {
+                    ch=(char)(c>>>12);      
+                    write=0xE0;
+                    if (ch>0) {
+                        write |= ( ch & 0x0F);
+                    } 
+                    out.write(write);
+                    write=0x80;
+                    bias=0x3F;        
+                } else {
+                        write=0xC0;
+                        bias=0x1F;
+                }
+                ch=(char)(c>>>6);
+                if (ch>0) {
+                     write|= (ch & bias);
+                } 
+                out.write(write);
+                out.write(0x80 | ((c) & 0x3F));       
+                                
+                }
+            
+           }
+        public final static byte[] getStringInUtf8(final String str) {
+                   final int length=str.length();
+                   boolean expanded=false;
+                   byte []result=new byte[length];
+                        int i=0;
+                        int out=0;
+                    char c;    
+                        while (i<length) {
+                                c=str.charAt(i++);        
+                        if ( c < 0x80 ) {
+                            result[out++]=(byte)c;
+                            continue;
+                        }
+                        if ((c >= 0xD800 && c <= 0xDBFF) || (c >= 0xDC00 && c <= 0xDFFF) ){  	
+                                   //No Surrogates in sun java
+                                   result[out++]=0x3f;
+                                
+                                continue;
+                        }
+                        if (!expanded) {
+                                byte newResult[]=new byte[3*length];
+                                        System.arraycopy(result, 0, newResult, 0, out);				   	    	
+                                        result=newResult;
+                                        expanded=true;
+                        } 
+                        char ch;
+                        int bias;
+                        byte write;
+                        if (c > 0x07FF) {
+                            ch=(char)(c>>>12);      
+                            write=(byte)0xE0;
+                            if (ch>0) {
+                                write |= ( ch & 0x0F);
+                            } 
+                            result[out++]=write;
+                            write=(byte)0x80;
+                            bias=0x3F;        
+                        } else {
+                                write=(byte)0xC0;
+                                bias=0x1F;
+                        }
+                        ch=(char)(c>>>6);
+                        if (ch>0) {
+                             write|= (ch & bias);
+                        } 
+                        result[out++]=write;
+                        result[out++]=(byte)(0x80 | ((c) & 0x3F));/**/       
+                                        
+                        }
+                        if (expanded) {
+                                byte newResult[]=new byte[out];
+                                System.arraycopy(result, 0, newResult, 0, out);
+                                result=newResult;
+                        }
+                        return result;
+           }
 
-	
+        
 
 }

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/CipherReference.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/CipherReference.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/CipherReference.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/CipherReference.java Thu Jan 27 11:11:33 2011
@@ -62,12 +62,12 @@ public interface CipherReference {
      */
     String getURI();
 
-	/**
-	 * Gets the URI as an Attribute node.  Used to meld the CipherREference
-	 * with the XMLSignature ResourceResolvers
+        /**
+         * Gets the URI as an Attribute node.  Used to meld the CipherREference
+         * with the XMLSignature ResourceResolvers
      * @return
-	 */
-	public Attr getURIAsAttr();
+         */
+        public Attr getURIAsAttr();
 
     /**
      * Returns the <code>Transforms</code> that specifies how to transform the

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/CipherValue.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/CipherValue.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/CipherValue.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/CipherValue.java Thu Jan 27 11:11:33 2011
@@ -29,8 +29,8 @@ public interface CipherValue {
      *
      * @return cipher value.
      */
-	String getValue();
-	// byte[] getValue();
+        String getValue();
+        // byte[] getValue();
     
     /**
      * Sets the Base 64 encoded, encrypted octets that is the
@@ -38,6 +38,6 @@ public interface CipherValue {
      *
      * @param value the cipher value.
      */
-	void setValue(String value);
-	// void setValue(byte[] value);
+        void setValue(String value);
+        // void setValue(byte[] value);
 }

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/ReferenceList.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/ReferenceList.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/ReferenceList.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/ReferenceList.java Thu Jan 27 11:11:33 2011
@@ -41,7 +41,7 @@ import java.util.Iterator;
  * @see Reference
  */
 public interface ReferenceList {
-	/** DATA TAG */
+        /** DATA TAG */
     public static final int DATA_REFERENCE = 0x00000001;
     /** KEY TAG */
     public static final int KEY_REFERENCE  = 0x00000002;

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/Transforms.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/Transforms.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/Transforms.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/Transforms.java Thu Jan 27 11:11:33 2011
@@ -55,17 +55,17 @@ public interface Transforms {
      *
      * @param transform.
      */
-	/*    void removeTransform(Transform transform); */
+        /*    void removeTransform(Transform transform); */
 
-	/**
-	 * Temporary method to turn the XMLEncryption Transforms class
-	 * into a DS class.  The main logic is currently implemented in the
-	 * DS class, so we need to get to get the base class.
-	 * <p>
-	 * <b>Note</b> This will be removed in future versions
+        /**
+         * Temporary method to turn the XMLEncryption Transforms class
+         * into a DS class.  The main logic is currently implemented in the
+         * DS class, so we need to get to get the base class.
+         * <p>
+         * <b>Note</b> This will be removed in future versions
      * @return
-	 */
+         */
 
-	org.apache.xml.security.transforms.Transforms getDSTransforms();
+        org.apache.xml.security.transforms.Transforms getDSTransforms();
 
 }