santuario-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1056263 [4/10] - in /santuario/xml-security-java/trunk: ./ src/test/java/javax/xml/crypto/test/ src/test/java/javax/xml/crypto/test/dsig/ src/test/java/javax/xml/crypto/test/dsig/dom/ src/test/java/javax/xml/crypto/test/dsig/keyinfo/ src/t...
Date Fri, 07 Jan 2011 11:23:13 GMT
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/PhaosXMLDSig3Test.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/PhaosXMLDSig3Test.java?rev=1056263&r1=1056262&r2=1056263&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/PhaosXMLDSig3Test.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/PhaosXMLDSig3Test.java Fri Jan  7 11:23:09 2011
@@ -25,8 +25,6 @@ import javax.xml.crypto.KeySelector;
 import javax.xml.crypto.dsig.XMLSignatureException;
 import javax.xml.crypto.dsig.dom.DOMValidateContext;
 
-import junit.framework.*;
-
 import javax.xml.crypto.test.KeySelectors;
 
 /**
@@ -35,261 +33,273 @@ import javax.xml.crypto.test.KeySelector
  *
  * @author Sean Mullan
  */
-public class PhaosXMLDSig3Test extends TestCase {
+public class PhaosXMLDSig3Test extends org.junit.Assert {
 
     private SignatureValidator validator;
     private File base;
 
     static {
         Security.insertProviderAt
-            (new org.jcp.xml.dsig.internal.dom.XMLDSigRI(), 1);
+        (new org.jcp.xml.dsig.internal.dom.XMLDSigRI(), 1);
     }
 
-    public PhaosXMLDSig3Test(String name) {
-        super(name);
+    public PhaosXMLDSig3Test() {
+        String fs = System.getProperty("file.separator");
+        String basedir = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
+        base = new File(basedir + fs + "data" + fs +
+                        "com" + fs + "phaos", "phaos-xmldsig-three");
+        validator = new SignatureValidator(base);
+    }
 
-	String fs = System.getProperty("file.separator");
-	String basedir = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
-	base = new File(basedir + fs + "data" + fs +
-	    "com" + fs + "phaos", "phaos-xmldsig-three");
-	validator = new SignatureValidator(base);
-    }
-//    public void test_signature_big() throws Exception {
-//        String file = "signature-big.xml";
-//
-//        boolean coreValidity = validator.validate(file, 
-//		new KeySelectors.CollectionKeySelector(base));
-//        assertTrue("Signature failed core validation", coreValidity);
-//    }
+    @org.junit.Test
     public void test_signature_dsa_detached() throws Exception {
-	String file = "signature-dsa-detached.xml";
+        String file = "signature-dsa-detached.xml";
 
         DOMValidateContext vc = validator.getValidateContext
-            (file, new KeySelectors.RawX509KeySelector());
+        (file, new KeySelectors.RawX509KeySelector());
         vc.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
 
-	boolean coreValidity = validator.validate(vc);
-	assertTrue("Signature failed core validation", coreValidity);
+        boolean coreValidity = validator.validate(vc);
+        assertTrue("Signature failed core validation", coreValidity);
     }
+
+    @org.junit.Test
     public void test_signature_dsa_enveloped() throws Exception {
-	String file = "signature-dsa-enveloped.xml";
+        String file = "signature-dsa-enveloped.xml";
+
+        boolean coreValidity = 
+            validator.validate(file, new KeySelectors.RawX509KeySelector());
+        assertTrue("Signature failed core validation", coreValidity);
+    }
 
-	boolean coreValidity = 
-	    validator.validate(file, new KeySelectors.RawX509KeySelector());
-	assertTrue("Signature failed core validation", coreValidity);
-    }    
+    @org.junit.Test
     public void test_signature_dsa_enveloping() throws Exception {
-	String file = "signature-dsa-enveloping.xml";
+        String file = "signature-dsa-enveloping.xml";
 
-	boolean coreValidity = 
-	    validator.validate(file, new KeySelectors.RawX509KeySelector());
-	assertTrue("Signature failed core validation", coreValidity);
+        boolean coreValidity = 
+            validator.validate(file, new KeySelectors.RawX509KeySelector());
+        assertTrue("Signature failed core validation", coreValidity);
     }
+
+    @org.junit.Test
     public void test_signature_dsa_manifest() throws Exception {
-	String file = "signature-dsa-manifest.xml";
+        String file = "signature-dsa-manifest.xml";
 
-	boolean coreValidity = 
-	    validator.validate(file, new KeySelectors.KeyValueKeySelector());
-	assertTrue("Signature failed core validation", coreValidity);
+        boolean coreValidity = 
+            validator.validate(file, new KeySelectors.KeyValueKeySelector());
+        assertTrue("Signature failed core validation", coreValidity);
     }
+
+    @org.junit.Test
     public void test_signature_hmac_sha1_40_c14n_comments_detached() 
-	throws Exception {
+    throws Exception {
         String file = "signature-hmac-sha1-40-c14n-comments-detached.xml";
-        
-	KeySelector ks = new KeySelectors.SecretKeySelector
-	    ("test".getBytes("ASCII") );
+
+        KeySelector ks = new KeySelectors.SecretKeySelector
+            ("test".getBytes("ASCII") );
         try {
-	    boolean coreValidity = validator.validate(file, ks);
+            validator.validate(file, ks);
             fail("Expected HMACOutputLength Exception");
         } catch (XMLSignatureException xse) {
-            System.out.println(xse.getMessage());
+            //System.out.println(xse.getMessage());
             // pass
         }
     }
+
+    @org.junit.Test
     public void test_signature_hmac_sha1_40_exclusive_c14n_comments_detached() 
-	throws Exception {
+    throws Exception {
         String file = "signature-hmac-sha1-40-exclusive-c14n-comments-detached.xml";
-        
-	KeySelector ks = new KeySelectors.SecretKeySelector
-	    ("test".getBytes("ASCII") );
+
+        KeySelector ks = new KeySelectors.SecretKeySelector
+            ("test".getBytes("ASCII") );
         try {
-	    boolean coreValidity = validator.validate(file, ks);
+            validator.validate(file, ks);
             fail("Expected HMACOutputLength Exception");
         } catch (XMLSignatureException xse) {
-            System.out.println(xse.getMessage());
+            //System.out.println(xse.getMessage());
             // pass
         }
     }
+
+    @org.junit.Test
     public void test_signature_hmac_sha1_exclusive_c14n_comments_detached() 
-	throws Exception {
+    throws Exception {
         String file = "signature-hmac-sha1-exclusive-c14n-comments-detached.xml";
-        
-	KeySelector ks = new KeySelectors.SecretKeySelector
-	    ("test".getBytes("ASCII") );
-	boolean coreValidity = validator.validate(file, ks);
-	assertTrue("Signature failed core validation", coreValidity);
+
+        KeySelector ks = new KeySelectors.SecretKeySelector
+            ("test".getBytes("ASCII") );
+        boolean coreValidity = validator.validate(file, ks);
+        assertTrue("Signature failed core validation", coreValidity);
     }
+
+    @org.junit.Test
     public void test_signature_hmac_sha1_exclusive_c14n_enveloped() 
-	throws Exception {
+    throws Exception {
         String file = "signature-hmac-sha1-exclusive-c14n-enveloped.xml";
-        
-	KeySelector ks = new KeySelectors.SecretKeySelector
-	    ("test".getBytes("ASCII") );
-	boolean coreValidity = validator.validate(file, ks);
-	assertTrue("Signature failed core validation", coreValidity);
+
+        KeySelector ks = new KeySelectors.SecretKeySelector
+            ("test".getBytes("ASCII") );
+        boolean coreValidity = validator.validate(file, ks);
+        assertTrue("Signature failed core validation", coreValidity);
     }
+
+    @org.junit.Test
     public void test_signature_rsa_detached_b64_transform() throws Exception {
-	String file = "signature-rsa-detached-b64-transform.xml";
+        String file = "signature-rsa-detached-b64-transform.xml";
 
-	boolean coreValidity = 
-	    validator.validate(file, new KeySelectors.KeyValueKeySelector());
-	assertTrue("Signature failed core validation", coreValidity);
+        boolean coreValidity = 
+            validator.validate(file, new KeySelectors.KeyValueKeySelector());
+        assertTrue("Signature failed core validation", coreValidity);
     }
+
+    @org.junit.Test
     public void test_signature_rsa_detached_xpath_transform() throws Exception {
-	String file = "signature-rsa-detached-xpath-transform.xml";
+        String file = "signature-rsa-detached-xpath-transform.xml";
+
+        boolean coreValidity = 
+            validator.validate(file, new KeySelectors.KeyValueKeySelector());
+        assertTrue("Signature failed core validation", coreValidity);
+    }
 
-	boolean coreValidity = 
-	    validator.validate(file, new KeySelectors.KeyValueKeySelector());
-	assertTrue("Signature failed core validation", coreValidity);
-    }    
+    @org.junit.Test
     public void test_signature_rsa_detached_xslt_transform_bad_rm() throws Exception {
-	String file = "signature-rsa-detached-xslt-transform-bad-retrieval-method.xml";
+        String file = "signature-rsa-detached-xslt-transform-bad-retrieval-method.xml";
 
-	try {
-	    validator.validate(file, 
-			       new KeySelectors.CollectionKeySelector(base));
-	    fail("Should throw XMLSignatureException for using DSA key with " +
-		 "RSA algorithm");
-	} catch (XMLSignatureException xse) {}
+        try {
+            validator.validate(file, 
+                               new KeySelectors.CollectionKeySelector(base));
+            fail("Should throw XMLSignatureException for using DSA key with " +
+            "RSA algorithm");
+        } catch (XMLSignatureException xse) {}
     }
+
+    @org.junit.Test
     public void test_signature_rsa_detached_xslt_transform_rm() throws Exception {
-	String file = "signature-rsa-detached-xslt-transform-retrieval-method.xml";
+        String file = "signature-rsa-detached-xslt-transform-retrieval-method.xml";
 
-	boolean coreValidity = 
-	    validator.validate(file, 
-			       new KeySelectors.CollectionKeySelector(base));
-	assertTrue("Signature failed core validation", coreValidity);
+        boolean coreValidity = 
+            validator.validate(file, 
+                               new KeySelectors.CollectionKeySelector(base));
+        assertTrue("Signature failed core validation", coreValidity);
     }
+
+    @org.junit.Test
     public void test_signature_rsa_detached_xslt_transform() throws Exception {
-	String file = "signature-rsa-detached-xslt-transform.xml";
+        String file = "signature-rsa-detached-xslt-transform.xml";
 
-	boolean coreValidity = 
-	    validator.validate(file, new KeySelectors.KeyValueKeySelector());
-	assertTrue("Signature failed core validation", coreValidity);
+        boolean coreValidity = 
+            validator.validate(file, new KeySelectors.KeyValueKeySelector());
+        assertTrue("Signature failed core validation", coreValidity);
     }
+
+    @org.junit.Test
     public void test_signature_rsa_detached() throws Exception {
-	String file = "signature-rsa-detached.xml";
+        String file = "signature-rsa-detached.xml";
 
         DOMValidateContext vc = validator.getValidateContext
-	    (file, new KeySelectors.RawX509KeySelector());
+            (file, new KeySelectors.RawX509KeySelector());
         vc.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
-	boolean coreValidity = validator.validate(vc);
-	assertTrue("Signature failed core validation", coreValidity);
+        boolean coreValidity = validator.validate(vc);
+        assertTrue("Signature failed core validation", coreValidity);
     }
+
+    @org.junit.Test
     public void test_signature_rsa_enveloped_bad_digest_val() throws Exception {
-	String file = "signature-rsa-enveloped-bad-digest-val.xml";
+        String file = "signature-rsa-enveloped-bad-digest-val.xml";
 
-	boolean coreValidity = 
-	    validator.validate(file, new KeySelectors.RawX509KeySelector());
-	assertFalse("Signature should fail core validation", coreValidity);
+        boolean coreValidity = 
+            validator.validate(file, new KeySelectors.RawX509KeySelector());
+        assertFalse("Signature should fail core validation", coreValidity);
     }
+
+    @org.junit.Test
     public void test_signature_rsa_enveloped() throws Exception {
-	String file = "signature-rsa-enveloped.xml";
+        String file = "signature-rsa-enveloped.xml";
 
-	boolean coreValidity =
-	    validator.validate(file, new KeySelectors.RawX509KeySelector());
-	assertTrue("Signature failed core validation", coreValidity);
+        boolean coreValidity =
+            validator.validate(file, new KeySelectors.RawX509KeySelector());
+        assertTrue("Signature failed core validation", coreValidity);
     }
+
+    @org.junit.Test
     public void test_signature_rsa_enveloping() throws Exception {
-	String file = "signature-rsa-enveloping.xml";
+        String file = "signature-rsa-enveloping.xml";
 
-	boolean coreValidity = 
-	    validator.validate(file, new KeySelectors.RawX509KeySelector());
-	assertTrue("Signature failed core validation", coreValidity);
-   }
-   public void test_signature_rsa_manifest_x509_data_cert_chain() throws Exception {
+        boolean coreValidity = 
+            validator.validate(file, new KeySelectors.RawX509KeySelector());
+        assertTrue("Signature failed core validation", coreValidity);
+    }
+
+    @org.junit.Test
+    public void test_signature_rsa_manifest_x509_data_cert_chain() throws Exception {
         String file = "signature-rsa-manifest-x509-data-cert-chain.xml";
 
         boolean coreValidity =
             validator.validate(file, new KeySelectors.RawX509KeySelector());
         assertTrue("Signature failed core validation", coreValidity);
-   }
-   public void test_signature_rsa_manifest_x509_data_cert() throws Exception {
+    }
+
+    @org.junit.Test
+    public void test_signature_rsa_manifest_x509_data_cert() throws Exception {
         String file = "signature-rsa-manifest-x509-data-cert.xml";
 
         boolean coreValidity =
             validator.validate(file, new KeySelectors.RawX509KeySelector());
         assertTrue("Signature failed core validation", coreValidity);
-   }
-   public void test_signature_rsa_manifest_x509_data_issuer_serial() throws Exception {
+    }
+
+    @org.junit.Test
+    public void test_signature_rsa_manifest_x509_data_issuer_serial() throws Exception {
         String file = "signature-rsa-manifest-x509-data-issuer-serial.xml";
 
         boolean coreValidity = validator.validate(file, 
-		new KeySelectors.CollectionKeySelector(base));
+                                                  new KeySelectors.CollectionKeySelector(base));
         assertTrue("Signature failed core validation", coreValidity);
-   }
-   public void test_signature_rsa_manifest_x509_data_ski() throws Exception {
+    }
+
+    @org.junit.Test
+    public void test_signature_rsa_manifest_x509_data_ski() throws Exception {
         String file = "signature-rsa-manifest-x509-data-ski.xml";
 
         boolean coreValidity = validator.validate(file, 
-		new KeySelectors.CollectionKeySelector(base));
+                                                  new KeySelectors.CollectionKeySelector(base));
         assertTrue("Signature failed core validation", coreValidity);
-   }
-   public void test_signature_rsa_manifest_x509_data_subject_name() throws Exception {
+    }
+
+    @org.junit.Test
+    public void test_signature_rsa_manifest_x509_data_subject_name() throws Exception {
         String file = "signature-rsa-manifest-x509-data-subject-name.xml";
 
         boolean coreValidity = validator.validate(file, 
-		new KeySelectors.CollectionKeySelector(base));
+                                                  new KeySelectors.CollectionKeySelector(base));
         assertTrue("Signature failed core validation", coreValidity);
-   }
-   public void test_signature_rsa_manifest_x509_data() throws Exception {
+    }
+
+    @org.junit.Test
+    public void test_signature_rsa_manifest_x509_data() throws Exception {
         String file = "signature-rsa-manifest-x509-data.xml";
 
         boolean coreValidity =
             validator.validate(file, new KeySelectors.RawX509KeySelector());
         assertTrue("Signature failed core validation", coreValidity);
-   }
-   public void test_signature_rsa_manifest() throws Exception {
+    }
+
+    @org.junit.Test
+    public void test_signature_rsa_manifest() throws Exception {
         String file = "signature-rsa-manifest.xml";
 
         boolean coreValidity =
             validator.validate(file, new KeySelectors.KeyValueKeySelector());
         assertTrue("Signature failed core validation", coreValidity);
-   }
-   public void test_signature_rsa_xpath_transform_enveloped() throws Exception {
+    }
+
+    @org.junit.Test
+    public void test_signature_rsa_xpath_transform_enveloped() throws Exception {
         String file = "signature-rsa-xpath-transform-enveloped.xml";
 
         boolean coreValidity =
             validator.validate(file, new KeySelectors.RawX509KeySelector());
         assertTrue("Signature failed core validation", coreValidity);
-   }
-   public static void main(String[] args) throws Exception {
-        PhaosXMLDSig3Test pt = new PhaosXMLDSig3Test("");
-//	pt.test_signature_big();
-        pt.test_signature_dsa_detached();
-        pt.test_signature_dsa_enveloped();
-	pt.test_signature_dsa_enveloping();
-	pt.test_signature_dsa_manifest();
-	pt.test_signature_hmac_sha1_40_c14n_comments_detached();
-	pt.test_signature_hmac_sha1_40_exclusive_c14n_comments_detached();
-	pt.test_signature_hmac_sha1_exclusive_c14n_comments_detached(); 
-	pt.test_signature_hmac_sha1_exclusive_c14n_enveloped();
-	pt.test_signature_rsa_detached_b64_transform();
-	pt.test_signature_rsa_detached_xpath_transform();
-	pt.test_signature_rsa_detached_xslt_transform_bad_rm();
-	pt.test_signature_rsa_detached_xslt_transform_rm();
-	pt.test_signature_rsa_detached_xslt_transform();
-	pt.test_signature_rsa_detached();
-	pt.test_signature_rsa_enveloped_bad_digest_val();
-	pt.test_signature_rsa_enveloped();
-	pt.test_signature_rsa_enveloping();
-	pt.test_signature_rsa_manifest_x509_data_cert_chain();
-	pt.test_signature_rsa_manifest_x509_data_cert();
-	pt.test_signature_rsa_manifest_x509_data_issuer_serial();
-	pt.test_signature_rsa_manifest_x509_data_ski();
-	pt.test_signature_rsa_manifest_x509_data_subject_name();
-	pt.test_signature_rsa_manifest_x509_data();
-	pt.test_signature_rsa_manifest();
-	pt.test_signature_rsa_xpath_transform_enveloped();
     }
 }

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ReferenceTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ReferenceTest.java?rev=1056263&r1=1056262&r2=1056263&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ReferenceTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ReferenceTest.java Fri Jan  7 11:23:09 2011
@@ -32,15 +32,12 @@ import javax.xml.crypto.dsig.spec.C14NMe
 import javax.xml.crypto.dsig.spec.TransformParameterSpec;
 import org.w3c.dom.Document;
 
-import junit.framework.*;
-
 /**
  * Unit test for javax.xml.crypto.dsig.Reference
  *
- * @version $Id$
  * @author Valerie Peng
  */
-public class ReferenceTest extends TestCase {
+public class ReferenceTest extends org.junit.Assert {
     private XMLSignatureFactory fac;
     private KeyInfoFactory kifac;
     private DigestMethod dmSHA1;
@@ -48,8 +45,8 @@ public class ReferenceTest extends TestC
 
     private static final String[] CRYPTO_ALGS = { "RSA", "DSA" };
     private static final String[] SIG_ALGS = { 
-	SignatureMethod.RSA_SHA1, 
-	SignatureMethod.DSA_SHA1 
+        SignatureMethod.RSA_SHA1, 
+        SignatureMethod.DSA_SHA1 
     };
 
     static {
@@ -57,177 +54,178 @@ public class ReferenceTest extends TestC
             (new org.jcp.xml.dsig.internal.dom.XMLDSigRI(), 1);
     }
 
-    public ReferenceTest() {
-	super("ReferenceTest");
-    }
-
-    public ReferenceTest(String name) {
-	super(name);
-    }
-
-    public void setUp() throws Exception {
+    public ReferenceTest() throws Exception {
         fac = XMLSignatureFactory.getInstance
             ("DOM", new org.jcp.xml.dsig.internal.dom.XMLDSigRI());
-	kifac = KeyInfoFactory.getInstance
+        kifac = KeyInfoFactory.getInstance
             ("DOM", new org.jcp.xml.dsig.internal.dom.XMLDSigRI());
-	dmSHA1 = fac.newDigestMethod(DigestMethod.SHA1, null); 
+        dmSHA1 = fac.newDigestMethod(DigestMethod.SHA1, null); 
     }
 
-    public void tearDown() {}
-
+    @org.junit.Test
     public void testConstructor() throws Exception {
-	Reference ref;
-	// test XMLSignatureFactory.newReference(String uri, 
-	//     DigestMethod dm) for generating Reference objects
-	ref = fac.newReference(null, dmSHA1);
-	assertNotNull(ref);
-	ref = fac.newReference(uri, dmSHA1);
-	assertNotNull(ref);
-	try {
-	    ref = fac.newReference("illegal!@#$%" + uri, dmSHA1);
-	    fail("Should throw a IAE for non-RFC2396-compliant uri");
-	} catch (IllegalArgumentException iae) {
-	} catch (Exception ex) {
-	    fail("Should throw a IAE instead of " + ex + 
-		 " for non-RFC2396-compliant uri");
-	}
-	try {
-	    ref = fac.newReference(uri, null);
-	    fail("Should throw a NPE for null dm");
-	} catch (NullPointerException npe) {
-	} catch (Exception ex) {
-	    fail("Should throw a NPE instead of " + ex + " for null dm");
-	}
-
-	// test XMLSignatureFactory.newReference(String uri, 
-	//    DigestMethod dm, List transforms, String type, String id)
-	// for generating Reference objects
-	try {   
-	    ref = fac.newReference(null, dmSHA1, null, null, null);
-	    assertEquals(ref.getDigestMethod(), dmSHA1);
-	} catch(Exception ex) {
-	    fail("Unexpected Exception: " + ex);
-	}
-
-	try {
-	    ref = fac.newReference(null, null, null, null, null);
-	    fail("Should throw a NPE for null dm");
-	} catch (NullPointerException npe) {
-	} catch(Exception ex) {
-	    fail("Should throw a NPE instead of " + ex + " for null dm");
-	}
-	String id  = "id";
-	String type = "type";
-	try {
-	    ref = fac.newReference(uri, dmSHA1, null, type, id);
-	    assertNotNull(ref.getDigestMethod());
-	    assertEquals(uri, ref.getURI());
-	    assertEquals(id, ref.getId());
-	    assertEquals(type, ref.getType());        
+        Reference ref;
+        // test XMLSignatureFactory.newReference(String uri, 
+        //     DigestMethod dm) for generating Reference objects
+        ref = fac.newReference(null, dmSHA1);
+        assertNotNull(ref);
+        ref = fac.newReference(uri, dmSHA1);
+        assertNotNull(ref);
+        
+        try {
+            ref = fac.newReference("illegal!@#$%" + uri, dmSHA1);
+            fail("Should throw a IAE for non-RFC2396-compliant uri");
+        } catch (IllegalArgumentException iae) {
+        } catch (Exception ex) {
+            fail("Should throw a IAE instead of " + ex + 
+                 " for non-RFC2396-compliant uri");
+        }
+        
+        try {
+            ref = fac.newReference(uri, null);
+            fail("Should throw a NPE for null dm");
+        } catch (NullPointerException npe) {
+        } catch (Exception ex) {
+            fail("Should throw a NPE instead of " + ex + " for null dm");
+        }
+
+        // test XMLSignatureFactory.newReference(String uri, 
+        //    DigestMethod dm, List transforms, String type, String id)
+        // for generating Reference objects
+        try {   
+            ref = fac.newReference(null, dmSHA1, null, null, null);
+            assertEquals(ref.getDigestMethod(), dmSHA1);
+        } catch(Exception ex) {
+            fail("Unexpected Exception: " + ex);
+        }
+
+        try {
+            ref = fac.newReference(null, null, null, null, null);
+            fail("Should throw a NPE for null dm");
+        } catch (NullPointerException npe) {
+        } catch(Exception ex) {
+            fail("Should throw a NPE instead of " + ex + " for null dm");
+        }
+        
+        String id  = "id";
+        String type = "type";
+        try {
+            ref = fac.newReference(uri, dmSHA1, null, type, id);
+            assertNotNull(ref.getDigestMethod());
+            assertEquals(uri, ref.getURI());
+            assertEquals(id, ref.getId());
+            assertEquals(type, ref.getType());        
         assertEquals(ref.getTransforms(), Collections.EMPTY_LIST);
-	    
-	} catch(Exception ex) {
-	    fail("Unexpected Exception: " + ex);
-	}
-	List transforms = new Vector();
-	try {
-	    // try empty transforms list
-	    ref = fac.newReference(uri, dmSHA1, transforms, 
-				   type, id);
-	    assertTrue(Arrays.equals(transforms.toArray(), 
-				     ref.getTransforms().toArray()));
-	} catch(Exception ex) {
-	    fail("Unexpected Exception: " + ex);
-	}
-	transforms.add(new Object());
-	try {
-	    // try a transforms list with an invalid object
-	    ref = fac.newReference(uri, dmSHA1, transforms, 
-				   type, id);
-	} catch (ClassCastException cce) {
-	} catch (Exception ex) {
-	    fail("Should throw a ClassCastException instead of " + ex);
-	}
-	// Test with various composition of Transform list 
-	// 1. String only 
-	transforms.clear();
-	transforms.add(Transform.BASE64);
-	try {
-	    // try a transforms list with a String object
-	    ref = fac.newReference(uri, dmSHA1, transforms, 
-	    			   type, id);
-	    fail("Should throw a CCE for illegal transforms");
-	} catch (ClassCastException cce) {
-	} catch(Exception ex) {
-	    fail("Should throw a CCE instead of " + ex + 
-		 " for illegal transforms");
-	}
-	// 2. Transform only
-	transforms.clear();
-	Transform c14nWithComments = fac.newTransform
-	    (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS, 
-	     (TransformParameterSpec) null);
-	transforms.add(c14nWithComments);
-	try {
-	    // try a transforms list with a Transform object
-	    ref = fac.newReference(uri, dmSHA1, transforms, type, id);
-	    assertTrue(Arrays.equals(transforms.toArray(), 
-				     ref.getTransforms().toArray()));
-	} catch (Exception ex) {
-	    fail("Unexpected Exception: " + ex);
-	}
+            
+        } catch(Exception ex) {
+            fail("Unexpected Exception: " + ex);
+        }
+        
+        List<Object> transforms = new Vector<Object>();
+        try {
+            // try empty transforms list
+            ref = fac.newReference(uri, dmSHA1, transforms, 
+                                   type, id);
+            assertTrue(Arrays.equals(transforms.toArray(), 
+                                     ref.getTransforms().toArray()));
+        } catch(Exception ex) {
+            fail("Unexpected Exception: " + ex);
+        }
+        transforms.add(new Object());
+        try {
+            // try a transforms list with an invalid object
+            ref = fac.newReference(uri, dmSHA1, transforms, 
+                                   type, id);
+        } catch (ClassCastException cce) {
+        } catch (Exception ex) {
+            fail("Should throw a ClassCastException instead of " + ex);
+        }
+        
+        // Test with various composition of Transform list 
+        // 1. String only 
+        transforms.clear();
+        transforms.add(Transform.BASE64);
+        try {
+            // try a transforms list with a String object
+            ref = fac.newReference(uri, dmSHA1, transforms, 
+                                   type, id);
+            fail("Should throw a CCE for illegal transforms");
+        } catch (ClassCastException cce) {
+        } catch(Exception ex) {
+            fail("Should throw a CCE instead of " + ex + 
+                 " for illegal transforms");
+        }
+        
+        // 2. Transform only
+        transforms.clear();
+        Transform c14nWithComments = fac.newTransform
+            (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS, 
+             (TransformParameterSpec) null);
+        transforms.add(c14nWithComments);
+        try {
+            // try a transforms list with a Transform object
+            ref = fac.newReference(uri, dmSHA1, transforms, type, id);
+            assertTrue(Arrays.equals(transforms.toArray(), 
+                                     ref.getTransforms().toArray()));
+        } catch (Exception ex) {
+            fail("Unexpected Exception: " + ex);
+        }
     }
+    
+    @org.junit.Test
     public void testisFeatureSupported() throws Exception {
-	Reference ref = fac.newReference(null, dmSHA1, null, null, null);
-	try {
-	    ref.isFeatureSupported(null); 
-	    fail("Should raise a NPE for null feature"); 
-	} catch (NullPointerException npe) {}
-	    
-	assertTrue(!ref.isFeatureSupported("not supported"));
+        Reference ref = fac.newReference(null, dmSHA1, null, null, null);
+        try {
+            ref.isFeatureSupported(null); 
+            fail("Should raise a NPE for null feature"); 
+        } catch (NullPointerException npe) {}
+            
+        assertTrue(!ref.isFeatureSupported("not supported"));
     }
 
+    @org.junit.Test
     public void testvalidate() throws Exception {
         testvalidate(false);
     }
 
+    @org.junit.Test
     public void testvalidateWithCaching() throws Exception {
         testvalidate(true);
     }
 
     private void testvalidate(boolean cache) throws Exception {
-	Reference ref = null;
-	String type = "http://www.w3.org/2000/09/xmldsig#Object";
-	byte[] in = new byte[200];
-	Random rand = new Random();
-	
-	// Test XMLSignContext
-	XMLSignContext signContext;
-	XMLValidateContext validateContext;
-	for (int i = 0; i < CRYPTO_ALGS.length; i++) {
-	    rand.nextBytes(in);
+        Reference ref = null;
+        String type = "http://www.w3.org/2000/09/xmldsig#Object";
+        byte[] in = new byte[200];
+        Random rand = new Random();
+        
+        // Test XMLSignContext
+        XMLSignContext signContext;
+        XMLValidateContext validateContext;
+        for (int i = 0; i < CRYPTO_ALGS.length; i++) {
+            rand.nextBytes(in);
             URIDereferencer dereferrer =
                 new TestUtils.OctetStreamURIDereferencer(in);
-	    Document doc = TestUtils.newDocument();
-	    signContext = new 
-		DOMSignContext(TestUtils.getPrivateKey(CRYPTO_ALGS[i]), doc);
-	    signContext.setURIDereferencer(dereferrer);
+            Document doc = TestUtils.newDocument();
+            signContext = new 
+                DOMSignContext(TestUtils.getPrivateKey(CRYPTO_ALGS[i]), doc);
+            signContext.setURIDereferencer(dereferrer);
             if (cache) {
                 signContext.setProperty
                     ("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
             }
-	    ref = fac.newReference(null, dmSHA1, null, type, null);
-	    XMLSignature sig = fac.newXMLSignature(fac.newSignedInfo
-		(fac.newCanonicalizationMethod
-		 (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS, 
-		  (C14NMethodParameterSpec) null),
-	    	fac.newSignatureMethod(SIG_ALGS[i], null),
-		Collections.singletonList(ref)),
-		kifac.newKeyInfo(Collections.singletonList
-		(kifac.newKeyValue(TestUtils.getPublicKey(CRYPTO_ALGS[i])))));
-	    try {
-		sig.sign(signContext);
-         	if (!cache) {
+            ref = fac.newReference(null, dmSHA1, null, type, null);
+            XMLSignature sig = fac.newXMLSignature(fac.newSignedInfo
+                (fac.newCanonicalizationMethod
+                 (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS, 
+                  (C14NMethodParameterSpec) null),
+                fac.newSignatureMethod(SIG_ALGS[i], null),
+                Collections.singletonList(ref)),
+                kifac.newKeyInfo(Collections.singletonList
+                (kifac.newKeyValue(TestUtils.getPublicKey(CRYPTO_ALGS[i])))));
+            try {
+                sig.sign(signContext);
+                if (!cache) {
                     assertNull(ref.getDereferencedData());
                     assertNull(ref.getDigestInputStream());
                 } else {
@@ -235,21 +233,21 @@ public class ReferenceTest extends TestC
                     assertNotNull(ref.getDigestInputStream());
                     assertTrue(digestInputEqual(ref));
                 }
-	        validateContext = new DOMValidateContext
-		    (TestUtils.getPublicKey(CRYPTO_ALGS[i]), 
-		    doc.getDocumentElement());
-	        validateContext.setURIDereferencer(dereferrer);
+                validateContext = new DOMValidateContext
+                    (TestUtils.getPublicKey(CRYPTO_ALGS[i]), 
+                    doc.getDocumentElement());
+                validateContext.setURIDereferencer(dereferrer);
 
                 if (cache) {
                     validateContext.setProperty
                         ("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
                 }
-		boolean result = sig.validate(validateContext);
-		assertTrue(result);
+                boolean result = sig.validate(validateContext);
+                assertTrue(result);
      
-		Iterator iter = sig.getSignedInfo().getReferences().iterator();
-		for (int j=0; iter.hasNext(); j++) {
-		    Reference validated_ref = (Reference) iter.next();
+                Iterator<?> iter = sig.getSignedInfo().getReferences().iterator();
+                for (int j=0; iter.hasNext(); j++) {
+                    Reference validated_ref = (Reference) iter.next();
                     if (!cache) {
                         assertNull(validated_ref.getDereferencedData());
                         assertNull(validated_ref.getDigestInputStream());
@@ -258,16 +256,16 @@ public class ReferenceTest extends TestC
                         assertNotNull(validated_ref.getDigestInputStream());
                         assertTrue(digestInputEqual(validated_ref));
                     }
-		    byte[] dv =  validated_ref.getDigestValue();
+                    byte[] dv =  validated_ref.getDigestValue();
                     byte[] cdv = validated_ref.getCalculatedDigestValue();
                     assertTrue(Arrays.equals(dv, cdv));
-		    boolean valid = validated_ref.validate(validateContext);
-		    assertTrue(valid);
-		}
-	    } catch (XMLSignatureException xse) {
-		fail("Unexpected Exception: " + xse); 
-	    }
-	}
+                    boolean valid = validated_ref.validate(validateContext);
+                    assertTrue(valid);
+                }
+            } catch (XMLSignatureException xse) {
+                fail("Unexpected Exception: " + xse); 
+            }
+        }
     }
 
     private boolean digestInputEqual(Reference ref) throws Exception {

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SecureXSLTTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SecureXSLTTest.java?rev=1056263&r1=1056262&r2=1056263&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SecureXSLTTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SecureXSLTTest.java Fri Jan  7 11:23:09 2011
@@ -34,16 +34,16 @@ public class SecureXSLTTest extends Test
     }
 
     public SecureXSLTTest(String name) {
-	super(name);
+        super(name);
     }
 
     public void test() throws Exception {
 
         String fs = System.getProperty("file.separator");
         String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
-    	
+        
         File baseDir = new File(base + fs + "data" 
-	    + fs + "javax" + fs + "xml" + fs + "crypto", "dsig");
+            + fs + "javax" + fs + "xml" + fs + "crypto", "dsig");
 
         String[] signatures =
             { "signature1.xml", "signature2.xml", "signature3.xml" };
@@ -53,7 +53,7 @@ public class SecureXSLTTest extends Test
         XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
         File f = new File("doc.xml");
         for (int i=0; i<signatures.length; i++) {
-	    String signature = signatures[i];
+            String signature = signatures[i];
             // System.out.println("Validating " + signature);
             Document doc = dbf.newDocumentBuilder().parse
                 (new FileInputStream(new File(baseDir, signature)));
@@ -66,9 +66,9 @@ public class SecureXSLTTest extends Test
 
             DOMValidateContext valContext = new DOMValidateContext
                 (new KeySelectors.KeyValueKeySelector(), nl.item(0));
-	    // enable reference caching in your validation context 
-	    valContext.setProperty
-    		("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
+            // enable reference caching in your validation context 
+            valContext.setProperty
+                ("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
 
             // make sure file is not left over from previous run
             f.delete();
@@ -78,7 +78,7 @@ public class SecureXSLTTest extends Test
                 if (sig.validate(valContext)) {
                     System.err.println("Signature UNEXPECTEDLY passed validation");
                 }
-		sig.getSignedInfo().getReferences().get(0);
+                sig.getSignedInfo().getReferences().get(0);
             } catch (XMLSignatureException xse) {
                 // this is good, but still make sure attack was not successful
                 // by falling through and checking if file was created

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureMethodTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureMethodTest.java?rev=1056263&r1=1056262&r2=1056263&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureMethodTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureMethodTest.java Fri Jan  7 11:23:09 2011
@@ -35,70 +35,70 @@ public class SignatureMethodTest extends
     XMLSignatureFactory factory;
 
     private static final String SIG_ALGOS[] = {
-	SignatureMethod.DSA_SHA1,
-	SignatureMethod.RSA_SHA1,
-	SignatureMethod.HMAC_SHA1
+        SignatureMethod.DSA_SHA1,
+        SignatureMethod.RSA_SHA1,
+        SignatureMethod.HMAC_SHA1
     };
 
     public SignatureMethodTest() {
-	super("SignatureMethodTest");
+        super("SignatureMethodTest");
     }
 
     public SignatureMethodTest(String name) {
-	super(name);
+        super(name);
     }
 
     public void setUp() throws Exception { 
-	factory = XMLSignatureFactory.getInstance
+        factory = XMLSignatureFactory.getInstance
             ("DOM", new org.jcp.xml.dsig.internal.dom.XMLDSigRI());
     }
 
     public void tearDown() { }
 
     public void testisFeatureSupported() throws Exception {
-	SignatureMethod sm;
-	for (int i = 0; i < SIG_ALGOS.length; i++) {
-	    String algo = SIG_ALGOS[i];
-	    sm = factory.newSignatureMethod(algo, null);
-	    try {
-		sm.isFeatureSupported(null); 
-		fail("Should raise a NPE for null feature"); 
-	    } catch (NullPointerException npe) {}
-	    
-	    assertTrue(!sm.isFeatureSupported("not supported"));
-	}
+        SignatureMethod sm;
+        for (int i = 0; i < SIG_ALGOS.length; i++) {
+            String algo = SIG_ALGOS[i];
+            sm = factory.newSignatureMethod(algo, null);
+            try {
+                sm.isFeatureSupported(null); 
+                fail("Should raise a NPE for null feature"); 
+            } catch (NullPointerException npe) {}
+            
+            assertTrue(!sm.isFeatureSupported("not supported"));
+        }
     }
 
     public void testConstructor() throws Exception {
-	// test XMLSignatureFactory.newAlgorithmMethod
-	// (String algorithm, AlgorithmParameterSpec params)
-	// for generating SignatureMethod objects
-	SignatureMethod sm;
-	for (int i = 0; i < SIG_ALGOS.length; i++) {
-	    String algo = SIG_ALGOS[i];
-	    sm = factory.newSignatureMethod(algo, null);
-	    assertEquals(sm.getAlgorithm(), algo);
-
-	    assertNull(sm.getParameterSpec());
-	    try {
-		sm = factory.newSignatureMethod
-		    (algo, new TestUtils.MyOwnSignatureMethodParameterSpec());
-		fail("Should raise an IAPE for invalid parameters"); 
-	    } catch (InvalidAlgorithmParameterException iape) {
-	    } catch (Exception ex) {
-		fail("Should raise an IAPE instead of " + ex);
-	    }
-	}
-
-	try {
-	    sm = factory.newSignatureMethod("non-existent", null); 
-	    fail("Should raise an NSAE for non-existent algos"); 
-	} catch (NoSuchAlgorithmException nsae) {}
-
-	try {
-	    sm = factory.newSignatureMethod(null, null); 
-	    fail("Should raise a NPE for null algo"); 
-	} catch (NullPointerException npe) {}
+        // test XMLSignatureFactory.newAlgorithmMethod
+        // (String algorithm, AlgorithmParameterSpec params)
+        // for generating SignatureMethod objects
+        SignatureMethod sm;
+        for (int i = 0; i < SIG_ALGOS.length; i++) {
+            String algo = SIG_ALGOS[i];
+            sm = factory.newSignatureMethod(algo, null);
+            assertEquals(sm.getAlgorithm(), algo);
+
+            assertNull(sm.getParameterSpec());
+            try {
+                sm = factory.newSignatureMethod
+                    (algo, new TestUtils.MyOwnSignatureMethodParameterSpec());
+                fail("Should raise an IAPE for invalid parameters"); 
+            } catch (InvalidAlgorithmParameterException iape) {
+            } catch (Exception ex) {
+                fail("Should raise an IAPE instead of " + ex);
+            }
+        }
+
+        try {
+            sm = factory.newSignatureMethod("non-existent", null); 
+            fail("Should raise an NSAE for non-existent algos"); 
+        } catch (NoSuchAlgorithmException nsae) {}
+
+        try {
+            sm = factory.newSignatureMethod(null, null); 
+            fail("Should raise a NPE for null algo"); 
+        } catch (NullPointerException npe) {}
     } 
 }
 

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertiesTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertiesTest.java?rev=1056263&r1=1056262&r2=1056263&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertiesTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertiesTest.java Fri Jan  7 11:23:09 2011
@@ -37,77 +37,77 @@ public class SignaturePropertiesTest ext
     private SignatureProperty prop;
 
     public SignaturePropertiesTest() {
-	super("SignaturePropertiesTest");
+        super("SignaturePropertiesTest");
     }
 
     public SignaturePropertiesTest(String name) {
-	super(name);
+        super(name);
     }
 
     public void setUp() throws Exception {
-	factory = XMLSignatureFactory.getInstance
+        factory = XMLSignatureFactory.getInstance
             ("DOM", new org.jcp.xml.dsig.internal.dom.XMLDSigRI());
-	prop = factory.newSignatureProperty
-	    (Collections.singletonList(new TestUtils.MyOwnXMLStructure()),
-	     "propTarget", "propId");
+        prop = factory.newSignatureProperty
+            (Collections.singletonList(new TestUtils.MyOwnXMLStructure()),
+             "propTarget", "propId");
     }
     
     public void tearDown() {}
     
     public void testConstructor() {
-	// test XMLSignatureFactory.newSignatureProperties(List, String) 
-	SignatureProperties props;
+        // test XMLSignatureFactory.newSignatureProperties(List, String) 
+        SignatureProperties props;
 
-	try {
-	    props = factory.newSignatureProperties(null, id); 
-	    fail("Should raise a NPE for null content"); 
-	} catch (NullPointerException npe) {
-	} catch (Exception ex) {
-	    fail("Should raise a NPE for null content instead of " + ex);
-	}
-	List list = new Vector();
-	try {
-	    props = factory.newSignatureProperties(list, id); 
-	    fail("Should raise an IAE for empty content"); 
-	} catch (IllegalArgumentException iae) {
-	} catch (Exception ex) {
-	    fail("Should raise an IAE for empty content instead of " + ex);
-	}
-	String strEntry = "wrong type";
-	list.add(strEntry);
-	try {
-	    props = factory.newSignatureProperties(list, id); 
-	    fail("Should raise a CCE for content containing " +
-		 "invalid, i.e. non-SignatureProperty, entries"); 
-	} catch (ClassCastException cce) {
-	} catch (Exception ex) {
-	    fail("Should raise a CCE for content with invalid entries " +
-		 "instead of " + ex);
-	}
-	list.remove(strEntry);
-	list.add(prop);
-	props = factory.newSignatureProperties(list, id);
-	assertNotNull(props);
-	List unmodifiable = props.getProperties();
-	assertNotNull(unmodifiable);
-	try {
-	    unmodifiable.add(prop);
-	    fail("Should return an unmodifiable List object");
-	} catch (UnsupportedOperationException uoe) {}
-	assertTrue(Arrays.equals(unmodifiable.toArray(), list.toArray()));
-	assertNotNull(props);
-	assertEquals(props.getId(), id);
+        try {
+            props = factory.newSignatureProperties(null, id); 
+            fail("Should raise a NPE for null content"); 
+        } catch (NullPointerException npe) {
+        } catch (Exception ex) {
+            fail("Should raise a NPE for null content instead of " + ex);
+        }
+        List list = new Vector();
+        try {
+            props = factory.newSignatureProperties(list, id); 
+            fail("Should raise an IAE for empty content"); 
+        } catch (IllegalArgumentException iae) {
+        } catch (Exception ex) {
+            fail("Should raise an IAE for empty content instead of " + ex);
+        }
+        String strEntry = "wrong type";
+        list.add(strEntry);
+        try {
+            props = factory.newSignatureProperties(list, id); 
+            fail("Should raise a CCE for content containing " +
+                 "invalid, i.e. non-SignatureProperty, entries"); 
+        } catch (ClassCastException cce) {
+        } catch (Exception ex) {
+            fail("Should raise a CCE for content with invalid entries " +
+                 "instead of " + ex);
+        }
+        list.remove(strEntry);
+        list.add(prop);
+        props = factory.newSignatureProperties(list, id);
+        assertNotNull(props);
+        List unmodifiable = props.getProperties();
+        assertNotNull(unmodifiable);
+        try {
+            unmodifiable.add(prop);
+            fail("Should return an unmodifiable List object");
+        } catch (UnsupportedOperationException uoe) {}
+        assertTrue(Arrays.equals(unmodifiable.toArray(), list.toArray()));
+        assertNotNull(props);
+        assertEquals(props.getId(), id);
     }
 
     public void testisFeatureSupported() {
-	List list = new Vector();
-	list.add(prop);
-	SignatureProperties props = factory.newSignatureProperties(list, id);
-	try {
-	    props.isFeatureSupported(null); 
-	    fail("Should raise a NPE for null feature"); 
-	} catch (NullPointerException npe) {}
+        List list = new Vector();
+        list.add(prop);
+        SignatureProperties props = factory.newSignatureProperties(list, id);
+        try {
+            props.isFeatureSupported(null); 
+            fail("Should raise a NPE for null feature"); 
+        } catch (NullPointerException npe) {}
 
-	assertTrue(!props.isFeatureSupported("not supported"));
+        assertTrue(!props.isFeatureSupported("not supported"));
     }
 }

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertyTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertyTest.java?rev=1056263&r1=1056262&r2=1056263&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertyTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertyTest.java Fri Jan  7 11:23:09 2011
@@ -37,84 +37,84 @@ public class SignaturePropertyTest exten
     private String id = "id";
 
     public SignaturePropertyTest() {
-	super("SignaturePropertyTest");
+        super("SignaturePropertyTest");
     }
 
     public SignaturePropertyTest(String name) {
-	super(name);
+        super(name);
     }
 
     public void setUp() throws Exception {
-	factory = XMLSignatureFactory.getInstance
+        factory = XMLSignatureFactory.getInstance
             ("DOM", new org.jcp.xml.dsig.internal.dom.XMLDSigRI());
     }
     
     public void tearDown() {}
     
     public void testConstructor() {
-	// test XMLSignatureFactory.newSignatureProperty(List, String, String) 
-	SignatureProperty prop;
+        // test XMLSignatureFactory.newSignatureProperty(List, String, String) 
+        SignatureProperty prop;
 
-	try {
-	    prop = factory.newSignatureProperty(null, target, id); 
-	    fail("Should raise a NPE for null content"); 
-	} catch (NullPointerException npe) {
-	} catch (Exception ex) {
-	    fail("Should raise a NPE for null content instead of " + ex);
-	}
-	List list = new Vector();
-	try {
-	    prop = factory.newSignatureProperty(list, target, id); 
-	    fail("Should raise an IAE for empty content"); 
-	} catch (IllegalArgumentException iae) {
-	} catch (Exception ex) {
-	    fail("Should raise an IAE for empty content instead of " + ex);
-	}
-	String strEntry = "wrong type";
-	list.add(strEntry);
-	try {
-	    prop = factory.newSignatureProperty(list, target, id); 
-	    fail("Should raise a CCE for content containing " +
-		 "invalid, i.e. non-XMLStructure, entries"); 
-	} catch (ClassCastException cce) {
-	} catch (Exception ex) {
-	    fail("Should raise a CCE for content with invalid entries " +
-		 "instead of " + ex);
-	}
-	list.remove(strEntry);
-	list.add(new TestUtils.MyOwnXMLStructure());
-	try {
-	    prop = factory.newSignatureProperty(list, null, id);
-	    fail("Should raise a NPE for null target"); 
-	} catch (NullPointerException npe) {
-	} catch (Exception ex) {
-	    fail("Should raise a NPE for null target instead of " + ex);
-	}
-
-	prop = factory.newSignatureProperty(list, target, id);
-	assertNotNull(prop);
-	List unmodifiable = prop.getContent();
-	assertNotNull(unmodifiable);
-	try {
-	    unmodifiable.add(new TestUtils.MyOwnXMLStructure());
-	    fail("Should return an unmodifiable List object");
-	} catch (UnsupportedOperationException uoe) {}
-	assertTrue(Arrays.equals(unmodifiable.toArray(), list.toArray()));
-	assertEquals(prop.getTarget(), target);
-	assertEquals(prop.getId(), id);
-	assertNotNull(prop);
+        try {
+            prop = factory.newSignatureProperty(null, target, id); 
+            fail("Should raise a NPE for null content"); 
+        } catch (NullPointerException npe) {
+        } catch (Exception ex) {
+            fail("Should raise a NPE for null content instead of " + ex);
+        }
+        List list = new Vector();
+        try {
+            prop = factory.newSignatureProperty(list, target, id); 
+            fail("Should raise an IAE for empty content"); 
+        } catch (IllegalArgumentException iae) {
+        } catch (Exception ex) {
+            fail("Should raise an IAE for empty content instead of " + ex);
+        }
+        String strEntry = "wrong type";
+        list.add(strEntry);
+        try {
+            prop = factory.newSignatureProperty(list, target, id); 
+            fail("Should raise a CCE for content containing " +
+                 "invalid, i.e. non-XMLStructure, entries"); 
+        } catch (ClassCastException cce) {
+        } catch (Exception ex) {
+            fail("Should raise a CCE for content with invalid entries " +
+                 "instead of " + ex);
+        }
+        list.remove(strEntry);
+        list.add(new TestUtils.MyOwnXMLStructure());
+        try {
+            prop = factory.newSignatureProperty(list, null, id);
+            fail("Should raise a NPE for null target"); 
+        } catch (NullPointerException npe) {
+        } catch (Exception ex) {
+            fail("Should raise a NPE for null target instead of " + ex);
+        }
+
+        prop = factory.newSignatureProperty(list, target, id);
+        assertNotNull(prop);
+        List unmodifiable = prop.getContent();
+        assertNotNull(unmodifiable);
+        try {
+            unmodifiable.add(new TestUtils.MyOwnXMLStructure());
+            fail("Should return an unmodifiable List object");
+        } catch (UnsupportedOperationException uoe) {}
+        assertTrue(Arrays.equals(unmodifiable.toArray(), list.toArray()));
+        assertEquals(prop.getTarget(), target);
+        assertEquals(prop.getId(), id);
+        assertNotNull(prop);
     }
 
     public void testisFeatureSupported() {
-	List list = new Vector();
-	list.add(new TestUtils.MyOwnXMLStructure());
-	SignatureProperty prop = factory.newSignatureProperty
-	    (list, target, id);
-	try {
-	    prop.isFeatureSupported(null); 
-	    fail("Should raise a NPE for null feature"); 
-	} catch (NullPointerException npe) {}
+        List list = new Vector();
+        list.add(new TestUtils.MyOwnXMLStructure());
+        SignatureProperty prop = factory.newSignatureProperty
+            (list, target, id);
+        try {
+            prop.isFeatureSupported(null); 
+            fail("Should raise a NPE for null feature"); 
+        } catch (NullPointerException npe) {}
 
-	assertTrue(!prop.isFeatureSupported("not supported"));
+        assertTrue(!prop.isFeatureSupported("not supported"));
     }
 }

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureValidator.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureValidator.java?rev=1056263&r1=1056262&r2=1056263&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureValidator.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureValidator.java Fri Jan  7 11:23:09 2011
@@ -41,55 +41,55 @@ public class SignatureValidator {
     private File dir;
 
     public SignatureValidator(File base) {
-	dir = base;
+        dir = base;
     }
 
     public boolean validate(String fn, KeySelector ks) throws Exception {
-	return validate(fn, ks, null);
+        return validate(fn, ks, null);
     }
 
     public DOMValidateContext getValidateContext(String fn, KeySelector ks)
-	throws Exception {
+        throws Exception {
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);
         dbf.setValidating(false);
         Document doc = dbf.newDocumentBuilder().parse(new File(dir, fn));
         Element sigElement = getSignatureElement(doc);
-	if (sigElement == null) {
-	    throw new Exception("Couldn't find signature Element");
-	}
-	DOMValidateContext vc = new DOMValidateContext(ks, sigElement);
-	vc.setBaseURI(dir.toURI().toString());
-	return vc;
+        if (sigElement == null) {
+            throw new Exception("Couldn't find signature Element");
+        }
+        DOMValidateContext vc = new DOMValidateContext(ks, sigElement);
+        vc.setBaseURI(dir.toURI().toString());
+        return vc;
     }
 
     public boolean validate(String fn, KeySelector ks, URIDereferencer ud)
-	throws Exception {
+        throws Exception {
 
-	DOMValidateContext vc = getValidateContext(fn, ks);
-	if (ud != null) {
-	    vc.setURIDereferencer(ud);
-	}
+        DOMValidateContext vc = getValidateContext(fn, ks);
+        if (ud != null) {
+            vc.setURIDereferencer(ud);
+        }
 
-	return validate(vc);
+        return validate(vc);
     }
 
     public boolean validate(DOMValidateContext vc) throws Exception {
 
         XMLSignatureFactory factory = XMLSignatureFactory.getInstance
             ("DOM", new org.jcp.xml.dsig.internal.dom.XMLDSigRI());
-    	XMLSignature signature = factory.unmarshalXMLSignature(vc);
-    	boolean coreValidity = signature.validate(vc);
+        XMLSignature signature = factory.unmarshalXMLSignature(vc);
+        boolean coreValidity = signature.validate(vc);
     
-    	// Check core validation status
-    	if (coreValidity == false) {
-    	    // check the validation status of each Reference
-    	    Iterator i = signature.getSignedInfo().getReferences().iterator();
-    	    for (int j=0; i.hasNext(); j++) {
-		Reference reference = (Reference) i.next();
-		reference.validate(vc);
-    	    }
-    	}
+        // Check core validation status
+        if (coreValidity == false) {
+            // check the validation status of each Reference
+            Iterator i = signature.getSignedInfo().getReferences().iterator();
+            for (int j=0; i.hasNext(); j++) {
+                Reference reference = (Reference) i.next();
+                reference.validate(vc);
+            }
+        }
         return coreValidity;
     }
 

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignedInfoTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignedInfoTest.java?rev=1056263&r1=1056262&r2=1056263&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignedInfoTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignedInfoTest.java Fri Jan  7 11:23:09 2011
@@ -44,97 +44,97 @@ public class SignedInfoTest extends Test
     }
 
     public SignedInfoTest() {
-	super("SignedInfoTest");
+        super("SignedInfoTest");
     }
 
     public SignedInfoTest(String name) {
-	super(name);
+        super(name);
     }
 
     public void setUp() throws Exception {
         fac = XMLSignatureFactory.getInstance
             ("DOM", new org.jcp.xml.dsig.internal.dom.XMLDSigRI());
-	cm = fac.newCanonicalizationMethod
-	    (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS, 
-	     (C14NMethodParameterSpec) null);
-	sm = fac.newSignatureMethod(SignatureMethod.DSA_SHA1, null);
-	references = new Vector();
-	references.add(fac.newReference
-		       ("http://www.sun.com/index.html", 
-			fac.newDigestMethod(DigestMethod.SHA1, null)));
+        cm = fac.newCanonicalizationMethod
+            (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS, 
+             (C14NMethodParameterSpec) null);
+        sm = fac.newSignatureMethod(SignatureMethod.DSA_SHA1, null);
+        references = new Vector();
+        references.add(fac.newReference
+                       ("http://www.sun.com/index.html", 
+                        fac.newDigestMethod(DigestMethod.SHA1, null)));
     }
 
     public void tearDown() {}
     
     public void testConstructor() {
-	// test XMLSignatureFactory.newSignedInfo(
-	//	CanonicalizationMethod cm, 
-	//      SignatureMethod sm, List references)
-	SignedInfo si;
-	
-	for (int i = 0; i < 3; i++) {
-	    try {
-		switch (i) {
-		case 0:
-		    si = fac.newSignedInfo(null, sm, references);
-		    break;
-		case 1:
-		    si = fac.newSignedInfo(cm, null, references);
-		    break;
-		case 2:
-		    si = fac.newSignedInfo(cm, sm, null);
-		    break;
-		}
-		fail("Should throw a NPE for null parameter");
-	    } catch(NullPointerException npe) {
-	    } catch(Exception ex) {
-		fail("Should throw a NPE instead of " + ex +
-		     " for null parameter");
-	    }
-	}
-
-	List empty = new Vector();
-	try {
-	    si = fac.newSignedInfo(cm, sm, empty);
-	    fail("Should throw an IAE for empty references");
-	} catch(IllegalArgumentException iae) {
-	} catch(Exception ex) {
-	    fail("Should throw an IAE instead of " + ex + 
-		 " for empty references");
-	}
-	
-	empty.add("String");
-	try {
-	    si = fac.newSignedInfo(cm, sm, empty);
-	    fail("Should throw an CCE for illegal references");
-	} catch(ClassCastException cce) {
-	} catch(Exception ex) {
-	    fail("Should throw an IAE instead of " + ex + 
-		 " for empty references");
-	}
-
-	si = fac.newSignedInfo(cm, sm, references);
-	assertNotNull(si);
-	assertEquals(si.getCanonicalizationMethod().getAlgorithm(), 
-		     cm.getAlgorithm());
-	assertEquals(si.getCanonicalizationMethod().getParameterSpec(), 
-		     cm.getParameterSpec());
-	assertEquals(si.getSignatureMethod().getAlgorithm(), 
-		     sm.getAlgorithm());
-	assertEquals(si.getSignatureMethod().getParameterSpec(), 
-		     sm.getParameterSpec());
-	assertTrue(Arrays.equals(si.getReferences().toArray(), 
-				 references.toArray()));
-	assertNull(si.getId());
+        // test XMLSignatureFactory.newSignedInfo(
+        //	CanonicalizationMethod cm, 
+        //      SignatureMethod sm, List references)
+        SignedInfo si;
+        
+        for (int i = 0; i < 3; i++) {
+            try {
+                switch (i) {
+                case 0:
+                    si = fac.newSignedInfo(null, sm, references);
+                    break;
+                case 1:
+                    si = fac.newSignedInfo(cm, null, references);
+                    break;
+                case 2:
+                    si = fac.newSignedInfo(cm, sm, null);
+                    break;
+                }
+                fail("Should throw a NPE for null parameter");
+            } catch(NullPointerException npe) {
+            } catch(Exception ex) {
+                fail("Should throw a NPE instead of " + ex +
+                     " for null parameter");
+            }
+        }
+
+        List empty = new Vector();
+        try {
+            si = fac.newSignedInfo(cm, sm, empty);
+            fail("Should throw an IAE for empty references");
+        } catch(IllegalArgumentException iae) {
+        } catch(Exception ex) {
+            fail("Should throw an IAE instead of " + ex + 
+                 " for empty references");
+        }
+        
+        empty.add("String");
+        try {
+            si = fac.newSignedInfo(cm, sm, empty);
+            fail("Should throw an CCE for illegal references");
+        } catch(ClassCastException cce) {
+        } catch(Exception ex) {
+            fail("Should throw an IAE instead of " + ex + 
+                 " for empty references");
+        }
+
+        si = fac.newSignedInfo(cm, sm, references);
+        assertNotNull(si);
+        assertEquals(si.getCanonicalizationMethod().getAlgorithm(), 
+                     cm.getAlgorithm());
+        assertEquals(si.getCanonicalizationMethod().getParameterSpec(), 
+                     cm.getParameterSpec());
+        assertEquals(si.getSignatureMethod().getAlgorithm(), 
+                     sm.getAlgorithm());
+        assertEquals(si.getSignatureMethod().getParameterSpec(), 
+                     sm.getParameterSpec());
+        assertTrue(Arrays.equals(si.getReferences().toArray(), 
+                                 references.toArray()));
+        assertNull(si.getId());
 
         // test XMLSignatureFactory.newSignedInfo(
         //      CanonicalizationMethod cm,
         //      SignatureMethod sm, List references, String id)
-	si = fac.newSignedInfo(cm, sm, references, null);
-	assertNotNull(si);
+        si = fac.newSignedInfo(cm, sm, references, null);
+        assertNotNull(si);
 
-	si = fac.newSignedInfo(cm, sm, references, "id");
-	assertNotNull(si);
-	assertEquals(si.getId(), "id");
+        si = fac.newSignedInfo(cm, sm, references, "id");
+        assertNotNull(si);
+        assertEquals(si.getId(), "id");
     }
 }

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java?rev=1056263&r1=1056262&r2=1056263&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java Fri Jan  7 11:23:09 2011
@@ -55,161 +55,161 @@ public class TestUtils {
     private TestUtils() {}
     
     public static PublicKey getPublicKey(String algo) 
-	throws InvalidKeySpecException, NoSuchAlgorithmException {
-	KeyFactory kf = KeyFactory.getInstance(algo);
-	KeySpec kspec;
-	if (algo.equalsIgnoreCase("DSA")) {
-	    kspec = new DSAPublicKeySpec(new BigInteger(DSA_Y), 
-					 new BigInteger(DSA_P), 
-					 new BigInteger(DSA_Q), 
-					 new BigInteger(DSA_G));
-	} else if (algo.equalsIgnoreCase("RSA")) {
-	    kspec = new RSAPublicKeySpec(new BigInteger(RSA_MOD), 
-					 new BigInteger(RSA_PUB));
-	} else throw new RuntimeException("Unsupported key algorithm " + algo);
-	return kf.generatePublic(kspec);
+        throws InvalidKeySpecException, NoSuchAlgorithmException {
+        KeyFactory kf = KeyFactory.getInstance(algo);
+        KeySpec kspec;
+        if (algo.equalsIgnoreCase("DSA")) {
+            kspec = new DSAPublicKeySpec(new BigInteger(DSA_Y), 
+                                         new BigInteger(DSA_P), 
+                                         new BigInteger(DSA_Q), 
+                                         new BigInteger(DSA_G));
+        } else if (algo.equalsIgnoreCase("RSA")) {
+            kspec = new RSAPublicKeySpec(new BigInteger(RSA_MOD), 
+                                         new BigInteger(RSA_PUB));
+        } else throw new RuntimeException("Unsupported key algorithm " + algo);
+        return kf.generatePublic(kspec);
     }
 
     public static PrivateKey getPrivateKey(String algo) 
-	throws InvalidKeySpecException, NoSuchAlgorithmException {
-	KeyFactory kf = KeyFactory.getInstance(algo);
-	KeySpec kspec;
-	if (algo.equalsIgnoreCase("DSA")) {
-	    kspec = new DSAPrivateKeySpec
-		(new BigInteger(DSA_X), new BigInteger(DSA_P), 
-		 new BigInteger(DSA_Q), new BigInteger(DSA_G));
-	} else if (algo.equalsIgnoreCase("RSA")) {
-	    kspec = new RSAPrivateKeySpec
-		(new BigInteger(RSA_MOD), new BigInteger(RSA_PRIV));
-	} else throw new RuntimeException("Unsupported key algorithm " + algo);
-	return kf.generatePrivate(kspec);
+        throws InvalidKeySpecException, NoSuchAlgorithmException {
+        KeyFactory kf = KeyFactory.getInstance(algo);
+        KeySpec kspec;
+        if (algo.equalsIgnoreCase("DSA")) {
+            kspec = new DSAPrivateKeySpec
+                (new BigInteger(DSA_X), new BigInteger(DSA_P), 
+                 new BigInteger(DSA_Q), new BigInteger(DSA_G));
+        } else if (algo.equalsIgnoreCase("RSA")) {
+            kspec = new RSAPrivateKeySpec
+                (new BigInteger(RSA_MOD), new BigInteger(RSA_PRIV));
+        } else throw new RuntimeException("Unsupported key algorithm " + algo);
+        return kf.generatePrivate(kspec);
     }
 
     public static SecretKey getSecretKey(final byte[] secret) {
-	return new SecretKey() {
-	    public String getFormat()	{ return "RAW"; }
-	    public byte[] getEncoded()	{ return secret; }
-	    public String getAlgorithm(){ return "SECRET"; }
-	};
+        return new SecretKey() {
+            public String getFormat()	{ return "RAW"; }
+            public byte[] getEncoded()	{ return secret; }
+            public String getAlgorithm(){ return "SECRET"; }
+        };
     }
     
     public static Document newDocument() {
-	try {
-	    DocumentBuilderFactory docFac =
+        try {
+            DocumentBuilderFactory docFac =
                 DocumentBuilderFactory.newInstance();
-	    docFac.setNamespaceAware(true);
+            docFac.setNamespaceAware(true);
             DocumentBuilder docBuilder = docFac.newDocumentBuilder();
-	    return docBuilder.newDocument();
-	} catch (Exception ex) {
-	    return null;
-	}
+            return docBuilder.newDocument();
+        } catch (Exception ex) {
+            return null;
+        }
     }
 
     public static class MyOwnC14nParameterSpec implements C14NMethodParameterSpec {}
     
     public static class MyOwnDigestMethodParameterSpec 
-	implements DigestMethodParameterSpec {}
+        implements DigestMethodParameterSpec {}
     
     public static class MyOwnSignatureMethodParameterSpec 
-	implements SignatureMethodParameterSpec {}
+        implements SignatureMethodParameterSpec {}
 
     public static XMLValidateContext getXMLValidateContext(String type, 
-						       File input, 
-						       String tag) 
-	throws Exception {
-	if (type.equalsIgnoreCase("dom")) {
-	    DocumentBuilderFactory docFactory =
-		DocumentBuilderFactory.newInstance();
-	    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
-	    Document doc = docBuilder.parse(input);
-	    if (tag == null) {
-		return new DOMValidateContext
-		    (TestUtils.getPublicKey("RSA"), doc.getDocumentElement());
-	    } else {
-		NodeList list = doc.getElementsByTagName(tag);
-		return new DOMValidateContext
-		    (TestUtils.getPublicKey("RSA"), list.item(0));
-	    }
-	} else {
-	    throw new Exception("Unsupported XMLValidateContext type: " + 
-				type);
-	}
+                                                       File input, 
+                                                       String tag) 
+        throws Exception {
+        if (type.equalsIgnoreCase("dom")) {
+            DocumentBuilderFactory docFactory =
+                DocumentBuilderFactory.newInstance();
+            DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+            Document doc = docBuilder.parse(input);
+            if (tag == null) {
+                return new DOMValidateContext
+                    (TestUtils.getPublicKey("RSA"), doc.getDocumentElement());
+            } else {
+                NodeList list = doc.getElementsByTagName(tag);
+                return new DOMValidateContext
+                    (TestUtils.getPublicKey("RSA"), list.item(0));
+            }
+        } else {
+            throw new Exception("Unsupported XMLValidateContext type: " + 
+                                type);
+        }
     }
 
     public static class MyOwnDOMReference extends DOMStructure 
-	implements Reference {
-	private String id;
-	private boolean status;
-	private byte[] digest;
-	private static MessageDigest MD;
-	private static DigestMethod DIG_METHOD;
-	private Data derefData;
-	private InputStream dis;
-	static {
-	    try {
-		MD = MessageDigest.getInstance("SHA");
-		XMLSignatureFactory factory = XMLSignatureFactory.getInstance
-       		    ("DOM", new org.jcp.xml.dsig.internal.dom.XMLDSigRI());
-		DIG_METHOD = 
-		    factory.newDigestMethod(DigestMethod.SHA1, null);
-	    } catch (Exception ex) {
-		// should never be thrown
-	    }
-	};
-	
-	public MyOwnDOMReference(String id, boolean status) {
-	    super(newDocument());
-	    this.id = id;
-	    this.status = status;
-	    digest = null;
-	}
-
-	public byte[] getDigestValue() {
-	    if (digest == null) {
-		byte[] inBytes = id.getBytes();
-		digest = new byte[20];
-		if (status) {
-		    digest = MD.digest(inBytes);
-		}
-	    }
-	    return digest;
-	}
-	public byte[] getCalculatedDigestValue() {
-	    return null;
-	}
-	public DigestMethod getDigestMethod() { return DIG_METHOD; }
-	public String getId() {
-	    return id;
-	}
-	public String getType() {
-	    return null;
-	}
-	public String getURI() {
-	    return null;
-	}
-	public List getTransforms() {
-	    return Collections.EMPTY_LIST;
-	}
-	public boolean validate(XMLValidateContext vCtx) 
-	    throws XMLSignatureException {
-	    this.dis = new ByteArrayInputStream(id.getBytes());
-	    this.derefData = new OctetStreamData(this.dis);
-	    return status;
-	}
-	public Data getDereferencedData() {
-	    return derefData;
-	}
-	public InputStream getDigestInputStream() {
-	    return dis;
+        implements Reference {
+        private String id;
+        private boolean status;
+        private byte[] digest;
+        private static MessageDigest MD;
+        private static DigestMethod DIG_METHOD;
+        private Data derefData;
+        private InputStream dis;
+        static {
+            try {
+                MD = MessageDigest.getInstance("SHA");
+                XMLSignatureFactory factory = XMLSignatureFactory.getInstance
+                    ("DOM", new org.jcp.xml.dsig.internal.dom.XMLDSigRI());
+                DIG_METHOD = 
+                    factory.newDigestMethod(DigestMethod.SHA1, null);
+            } catch (Exception ex) {
+                // should never be thrown
+            }
+        };
+        
+        public MyOwnDOMReference(String id, boolean status) {
+            super(newDocument());
+            this.id = id;
+            this.status = status;
+            digest = null;
+        }
+
+        public byte[] getDigestValue() {
+            if (digest == null) {
+                byte[] inBytes = id.getBytes();
+                digest = new byte[20];
+                if (status) {
+                    digest = MD.digest(inBytes);
+                }
+            }
+            return digest;
+        }
+        public byte[] getCalculatedDigestValue() {
+            return null;
+        }
+        public DigestMethod getDigestMethod() { return DIG_METHOD; }
+        public String getId() {
+            return id;
+        }
+        public String getType() {
+            return null;
+        }
+        public String getURI() {
+            return null;
+        }
+        public List getTransforms() {
+            return Collections.EMPTY_LIST;
+        }
+        public boolean validate(XMLValidateContext vCtx) 
+            throws XMLSignatureException {
+            this.dis = new ByteArrayInputStream(id.getBytes());
+            this.derefData = new OctetStreamData(this.dis);
+            return status;
+        }
+        public Data getDereferencedData() {
+            return derefData;
+        }
+        public InputStream getDigestInputStream() {
+            return dis;
         }
     }
 
     public static class MyOwnXMLStructure implements XMLStructure {
-	public boolean isFeatureSupported(String feature) 
-	    throws NullPointerException {
-	    if (feature == null) throw new NullPointerException();
-	    return false;
-	}
+        public boolean isFeatureSupported(String feature) 
+            throws NullPointerException {
+            if (feature == null) throw new NullPointerException();
+            return false;
+        }
     }
 
     public static class OctetStreamURIDereferencer implements URIDereferencer {
@@ -251,9 +251,9 @@ public class TestUtils {
     }
 
     public static void dumpDocument(Document doc, String outName)
-	throws Exception {
+        throws Exception {
         DOMSource source = new DOMSource(doc);
-	File path = new File(System.getProperty("test.dir"), outName);
+        File path = new File(System.getProperty("test.dir"), outName);
         Result result = new StreamResult(new FileOutputStream(path));
         Transformer trans = TransformerFactory.newInstance().newTransformer();
         trans.setOutputProperty(OutputKeys.INDENT, "yes");

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TransformTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TransformTest.java?rev=1056263&r1=1056262&r2=1056263&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TransformTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TransformTest.java Fri Jan  7 11:23:09 2011
@@ -42,11 +42,11 @@ public class TransformTest extends TestC
     XMLSignatureFactory factory;
 
     private static final String TRANSFORM_ALGOS[] = {
-	Transform.BASE64,
-	Transform.ENVELOPED,
-	Transform.XPATH,
-	Transform.XPATH2,
-	Transform.XSLT
+        Transform.BASE64,
+        Transform.ENVELOPED,
+        Transform.XPATH,
+        Transform.XPATH2,
+        Transform.XSLT
     };
 
     static {
@@ -55,101 +55,101 @@ public class TransformTest extends TestC
     }
 
     public TransformTest() {
-	super("TransformTest");
+        super("TransformTest");
     }
 
     public TransformTest(String name) {
-	super(name);
+        super(name);
     }
 
     public void setUp() throws Exception { 
-	factory = XMLSignatureFactory.getInstance
+        factory = XMLSignatureFactory.getInstance
             ("DOM", new org.jcp.xml.dsig.internal.dom.XMLDSigRI());
     }
 
     public void tearDown() { }
 
     public void testisFeatureSupported() throws Exception {
-	Transform tm; 
-	for (int i = 0; i < TRANSFORM_ALGOS.length; i++) {
-	    String algo = TRANSFORM_ALGOS[i];
-	    TransformParameterSpec params = null;
-	    if (algo.equals(Transform.XPATH)) {
-		params = new XPathFilterParameterSpec("xPath");
-	    } else if (algo.equals(Transform.XPATH2)) {
-		params = new XPathFilter2ParameterSpec
-		    (Collections.singletonList(new XPathType
-			("xPath2", XPathType.Filter.INTERSECT)));
-	    } else if (algo.equals(Transform.XSLT)) {
-		params = new XSLTTransformParameterSpec(new XSLTStructure());
-	    }
-	    tm = factory.newTransform(algo, params);
-	    try {
-		tm.isFeatureSupported(null); 
-		fail(TRANSFORM_ALGOS[i] + 
-		     ": Should raise a NPE for null feature"); 
-	    } catch (NullPointerException npe) {}
-	    
-	    assertTrue(!tm.isFeatureSupported("not supported"));
-	}
+        Transform tm; 
+        for (int i = 0; i < TRANSFORM_ALGOS.length; i++) {
+            String algo = TRANSFORM_ALGOS[i];
+            TransformParameterSpec params = null;
+            if (algo.equals(Transform.XPATH)) {
+                params = new XPathFilterParameterSpec("xPath");
+            } else if (algo.equals(Transform.XPATH2)) {
+                params = new XPathFilter2ParameterSpec
+                    (Collections.singletonList(new XPathType
+                        ("xPath2", XPathType.Filter.INTERSECT)));
+            } else if (algo.equals(Transform.XSLT)) {
+                params = new XSLTTransformParameterSpec(new XSLTStructure());
+            }
+            tm = factory.newTransform(algo, params);
+            try {
+                tm.isFeatureSupported(null); 
+                fail(TRANSFORM_ALGOS[i] + 
+                     ": Should raise a NPE for null feature"); 
+            } catch (NullPointerException npe) {}
+            
+            assertTrue(!tm.isFeatureSupported("not supported"));
+        }
     }
 
     public void testConstructor() throws Exception {
-	// test newTransform(String algorithm, 
-	//                   AlgorithmParameterSpec params)
-	// for generating Transform objects
-	Transform tm; 
-	for (int i = 0; i < TRANSFORM_ALGOS.length; i++) {
-	    String algo = TRANSFORM_ALGOS[i];
-	    TransformParameterSpec params = null;
-	    if (algo.equals(Transform.XPATH)) {
-		params = new XPathFilterParameterSpec("xPath");
-	    } else if (algo.equals(Transform.XPATH2)) {
-		params = new XPathFilter2ParameterSpec
-		    (Collections.singletonList(new XPathType
-			("xPath2", XPathType.Filter.INTERSECT)));
-	    } else if (algo.equals(Transform.XSLT)) {
-		params = new XSLTTransformParameterSpec(new XSLTStructure());
-	    }
-	    try {
-		tm = factory.newTransform(algo, params);
-		assertNotNull(tm);
-		assertEquals(tm.getAlgorithm(), algo);
-		assertEquals(tm.getParameterSpec(), params);
-	    } catch (Exception ex) {
-		fail(TRANSFORM_ALGOS[i] + ": Unexpected exception " + ex); 
-	    }
-	    try {
-		tm = factory.newTransform
-		    (algo, new TestUtils.MyOwnC14nParameterSpec());
-		fail(TRANSFORM_ALGOS[i] + 
-		     ": Should raise an IAPE for invalid parameters"); 
-	    } catch (InvalidAlgorithmParameterException iape) {
-	    } catch (Exception ex) {
-		fail(TRANSFORM_ALGOS[i] + 
-		     ": Should raise a IAPE instead of " + ex); 
-	    }
-	}
-
-	try {
-	    tm = factory.newTransform(null, (TransformParameterSpec) null); 
-	    fail("Should raise a NPE for null algo"); 
-	} catch (NullPointerException npe) {
-	} catch (Exception ex) {
-	    fail("Should raise a NPE instead of " + ex); 
-	}
-
-	try {
-	    tm = factory.newTransform
-		("non-existent", (TransformParameterSpec) null); 
-	    fail("Should raise an NSAE for non-existent algos"); 
-	} catch (NoSuchAlgorithmException nsae) {
-	} catch (Exception ex) {
-	    fail("Should raise an NSAE instead of " + ex); 
-	}
+        // test newTransform(String algorithm, 
+        //                   AlgorithmParameterSpec params)
+        // for generating Transform objects
+        Transform tm; 
+        for (int i = 0; i < TRANSFORM_ALGOS.length; i++) {
+            String algo = TRANSFORM_ALGOS[i];
+            TransformParameterSpec params = null;
+            if (algo.equals(Transform.XPATH)) {
+                params = new XPathFilterParameterSpec("xPath");
+            } else if (algo.equals(Transform.XPATH2)) {
+                params = new XPathFilter2ParameterSpec
+                    (Collections.singletonList(new XPathType
+                        ("xPath2", XPathType.Filter.INTERSECT)));
+            } else if (algo.equals(Transform.XSLT)) {
+                params = new XSLTTransformParameterSpec(new XSLTStructure());
+            }
+            try {
+                tm = factory.newTransform(algo, params);
+                assertNotNull(tm);
+                assertEquals(tm.getAlgorithm(), algo);
+                assertEquals(tm.getParameterSpec(), params);
+            } catch (Exception ex) {
+                fail(TRANSFORM_ALGOS[i] + ": Unexpected exception " + ex); 
+            }
+            try {
+                tm = factory.newTransform
+                    (algo, new TestUtils.MyOwnC14nParameterSpec());
+                fail(TRANSFORM_ALGOS[i] + 
+                     ": Should raise an IAPE for invalid parameters"); 
+            } catch (InvalidAlgorithmParameterException iape) {
+            } catch (Exception ex) {
+                fail(TRANSFORM_ALGOS[i] + 
+                     ": Should raise a IAPE instead of " + ex); 
+            }
+        }
+
+        try {
+            tm = factory.newTransform(null, (TransformParameterSpec) null); 
+            fail("Should raise a NPE for null algo"); 
+        } catch (NullPointerException npe) {
+        } catch (Exception ex) {
+            fail("Should raise a NPE instead of " + ex); 
+        }
+
+        try {
+            tm = factory.newTransform
+                ("non-existent", (TransformParameterSpec) null); 
+            fail("Should raise an NSAE for non-existent algos"); 
+        } catch (NoSuchAlgorithmException nsae) {
+        } catch (Exception ex) {
+            fail("Should raise an NSAE instead of " + ex); 
+        }
     }
 
     private static class XSLTStructure implements XMLStructure {
-	public boolean isFeatureSupported(String feature) { return false; }
+        public boolean isFeatureSupported(String feature) { return false; }
     }
 }

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ValidateSignatureTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ValidateSignatureTest.java?rev=1056263&r1=1056262&r2=1056263&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ValidateSignatureTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ValidateSignatureTest.java Fri Jan  7 11:23:09 2011
@@ -51,12 +51,12 @@ public class ValidateSignatureTest exten
 
     public ValidateSignatureTest(String name) {
         super(name);
-	String fs = System.getProperty("file.separator");
-	String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
-	
-	dir = new File(base + fs + "data" + fs 
-	    + "javax" + fs + "xml" + fs + "crypto", "dsig");
-	validator = new SignatureValidator(dir);
+        String fs = System.getProperty("file.separator");
+        String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
+        
+        dir = new File(base + fs + "data" + fs 
+            + "javax" + fs + "xml" + fs + "crypto", "dsig");
+        validator = new SignatureValidator(dir);
     }
 
     /** 
@@ -66,21 +66,21 @@ public class ValidateSignatureTest exten
     public void test_signature_with_ID() throws Exception {
         String file = "envelopingSignature.xml";
 
-	DOMValidateContext vc = validator.getValidateContext
-	    (file, new KeySelectors.KeyValueKeySelector());
-	Document doc = vc.getNode().getOwnerDocument();
-	NodeList nl = doc.getElementsByTagName("Assertion");
-	vc.setIdAttributeNS((Element) nl.item(0), null, "AssertionID");
-	boolean coreValidity = validator.validate(vc);
-	assertTrue("Signature failed core validation", coreValidity);
+        DOMValidateContext vc = validator.getValidateContext
+            (file, new KeySelectors.KeyValueKeySelector());
+        Document doc = vc.getNode().getOwnerDocument();
+        NodeList nl = doc.getElementsByTagName("Assertion");
+        vc.setIdAttributeNS((Element) nl.item(0), null, "AssertionID");
+        boolean coreValidity = validator.validate(vc);
+        assertTrue("Signature failed core validation", coreValidity);
     }
 
     public void test_signature_external_c14n_xmlattrs() throws Exception {
-	String file = "signature-external-c14n-xmlatrs.xml";
+        String file = "signature-external-c14n-xmlatrs.xml";
 
-	boolean coreValidity = validator.validate(file, 
-	    new KeySelectors.SecretKeySelector("secret".getBytes("ASCII")));
-	assertTrue("Signature failed core validation", coreValidity);
+        boolean coreValidity = validator.validate(file, 
+            new KeySelectors.SecretKeySelector("secret".getBytes("ASCII")));
+        assertTrue("Signature failed core validation", coreValidity);
     }
 
     /**
@@ -90,9 +90,9 @@ public class ValidateSignatureTest exten
         InvalidURIDereferencer ud = new InvalidURIDereferencer();
 
         boolean coreValidity = validator.validate("invalid-signature.xml", 
-	    new KeySelectors.KeyValueKeySelector(), ud);
-	assertFalse("Invalid signature should fail!", coreValidity);
-	assertTrue("References validated before signature", ud.dereferenced);
+            new KeySelectors.KeyValueKeySelector(), ud);
+        assertFalse("Invalid signature should fail!", coreValidity);
+        assertTrue("References validated before signature", ud.dereferenced);
     }
 
     public void test_signature_enveloping_hmac_sha1_trunclen_0() throws Exception {
@@ -123,10 +123,10 @@ public class ValidateSignatureTest exten
     // Bug 47761: validates an xml signature containing a reference with
     // xmlns:xml attributes. C14n should not emit these attributes.
     public void test_signature_exclc14n_xmlnamespace() throws Exception {
-	String file = "demo.signed.xml";
-	boolean coreValidity = validator.validate(file, 
-	    new KeySelectors.RawX509KeySelector());
-	assertTrue("Signature failed core validation", coreValidity);
+        String file = "demo.signed.xml";
+        boolean coreValidity = validator.validate(file, 
+            new KeySelectors.RawX509KeySelector());
+        assertTrue("Signature failed core validation", coreValidity);
     }
 
     /**



Mime
View raw message