You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by ra...@apache.org on 2005/01/19 20:28:07 UTC

cvs commit: xml-security/src_unitTests/org/apache/xml/security/test EncryptionTest.java

raul        2005/01/19 11:28:07

  Modified:    src/org/apache/xml/security/c14n/implementations
                        CanonicalizerBase.java
               src/org/apache/xml/security/c14n CanonicalizerSpi.java
                        Canonicalizer.java
               src/org/apache/xml/security/encryption XMLCipher.java
               src_unitTests/org/apache/xml/security/test
                        EncryptionTest.java
  Log:
  Fix the XMLCypher problems after restore the reset behaviour
  to c14nbase.
  
  Revision  Changes    Path
  1.13      +10 -3     xml-security/src/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java
  
  Index: CanonicalizerBase.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- CanonicalizerBase.java	18 Jan 2005 18:15:54 -0000	1.12
  +++ CanonicalizerBase.java	19 Jan 2005 19:28:06 -0000	1.13
  @@ -131,7 +131,9 @@
            this._writer.close();
            if (this._writer instanceof ByteArrayOutputStream) {
               byte []result=((ByteArrayOutputStream)this._writer).toByteArray();
  -			((ByteArrayOutputStream)this._writer).reset();
  +            if (reset) {
  +                ((ByteArrayOutputStream)this._writer).reset();        
  +            }
            	return result;
            } 
            return null;
  @@ -277,7 +279,11 @@
            this.canonicalizeXPathNodeSet(rootNodeOfC14n,new  NameSpaceSymbTable());
            this._writer.close();
            if (this._writer instanceof ByteArrayOutputStream) {
  -         	return ((ByteArrayOutputStream)this._writer).toByteArray();
  +            byte [] sol=((ByteArrayOutputStream)this._writer).toByteArray();
  +            if (reset) {
  +            	((ByteArrayOutputStream)this._writer).reset();
  +            }
  +         	return sol;
            }
            return null;
         } catch (UnsupportedEncodingException ex) {
  @@ -749,4 +755,5 @@
       public void setWriter(OutputStream _writer) {
       	this._writer = _writer;
       }
  +     
   }
  
  
  
  1.11      +3 -1      xml-security/src/org/apache/xml/security/c14n/CanonicalizerSpi.java
  
  Index: CanonicalizerSpi.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src/org/apache/xml/security/c14n/CanonicalizerSpi.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- CanonicalizerSpi.java	23 Sep 2004 20:23:20 -0000	1.10
  +++ CanonicalizerSpi.java	19 Jan 2005 19:28:06 -0000	1.11
  @@ -95,7 +95,6 @@
         // db.setErrorHandler(eh);
         Document document = db.parse(in);
         byte result[] = this.engineCanonicalizeSubTree(document);
  -
         return result;
      }
   
  @@ -189,5 +188,8 @@
       * @param os
       */
      public abstract void setWriter(OutputStream os);
  +   
  +   /** Reset the writter after a c14n */
  +   protected boolean reset=false;
      //J+
   }
  
  
  
  1.10      +5 -0      xml-security/src/org/apache/xml/security/c14n/Canonicalizer.java
  
  Index: Canonicalizer.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src/org/apache/xml/security/c14n/Canonicalizer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Canonicalizer.java	23 Sep 2004 20:23:20 -0000	1.9
  +++ Canonicalizer.java	19 Jan 2005 19:28:06 -0000	1.10
  @@ -102,6 +102,7 @@
   
            this.canonicalizerSpi =
               (CanonicalizerSpi) Class.forName(implementingClass).newInstance();
  +         this.canonicalizerSpi.reset=true;
         } catch (Exception e) {
            Object exArgs[] = { algorithmURI };
   
  @@ -345,5 +346,9 @@
         }
   
         return null;
  +   }
  +   
  +   public void notReset() {
  +   	    this.canonicalizerSpi.reset=false;
      }
   }
  
  
  
  1.34      +3 -0      xml-security/src/org/apache/xml/security/encryption/XMLCipher.java
  
  Index: XMLCipher.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src/org/apache/xml/security/encryption/XMLCipher.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- XMLCipher.java	18 Nov 2004 22:29:25 -0000	1.33
  +++ XMLCipher.java	19 Jan 2005 19:28:06 -0000	1.34
  @@ -281,6 +281,7 @@
   		try {
   			instance._canon = Canonicalizer.getInstance
   				(Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS);
  +            
   		} catch (InvalidCanonicalizerException ice) {
   			throw new XMLEncryptionException("empty", ice);
   		}
  @@ -1796,6 +1797,7 @@
           String serialize(NodeList content) throws Exception { //XMLEncryptionException {
               ByteArrayOutputStream baos = new ByteArrayOutputStream();
               _canon.setWriter(baos);
  +            _canon.notReset();
               for (int i = 0; i < content.getLength(); i++) {                
                   _canon.canonicalizeSubtree(content.item(i));                
               }
  @@ -1812,6 +1814,7 @@
   		String canonSerialize(Node node) throws Exception {
   			ByteArrayOutputStream baos = new ByteArrayOutputStream();
   			_canon.setWriter(baos);			
  +            _canon.notReset();
   			_canon.canonicalizeSubtree(node);			
   			baos.close();            
   			return baos.toString("UTF-8");
  
  
  
  1.3       +8 -0      xml-security/src_unitTests/org/apache/xml/security/test/EncryptionTest.java
  
  Index: EncryptionTest.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src_unitTests/org/apache/xml/security/test/EncryptionTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EncryptionTest.java	8 Feb 2004 06:08:22 -0000	1.2
  +++ EncryptionTest.java	19 Jan 2005 19:28:07 -0000	1.3
  @@ -17,8 +17,11 @@
   
   package org.apache.xml.security.test;
   
  +import java.security.Security;
  +
   import org.apache.xml.security.test.encryption.XMLCipherTester;
   import org.apache.xml.security.test.encryption.BaltimoreEncTest;
  +import org.bouncycastle.jce.provider.BouncyCastleProvider;
   
   import junit.framework.Test;
   import junit.framework.TestCase;
  @@ -33,10 +36,15 @@
   
       public static void main(String[] args) {
   		org.apache.xml.security.Init.init();
  +        
           processCmdLineArgs(args);
           TestRunner.run(suite());
       }
  +    static {
  +        Security.addProvider(new BouncyCastleProvider());
   
  +   
  +    }
       public static Test suite() {
           TestSuite suite = new TestSuite("DOM XML Encryption Tests");
           suite.addTest(new TestSuite(XMLCipherTester.class));