You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by vd...@apache.org on 2003/12/30 10:43:57 UTC

cvs commit: xml-security/src_unitTests/org/apache/xml/security/test/interop IAIKTest.java BaltimoreTest.java RSASecurityTest.java

vdkoogh     2003/12/30 01:43:57

  Modified:    src_unitTests/org/apache/xml/security/test/utils/resolver
                        OfflineResolver.java
               src_unitTests/org/apache/xml/security/test/encryption
                        BaltimoreEncTest.java
               src_unitTests/org/apache/xml/security/test/c14n/implementations
                        Canonicalizer20010315ExclusiveTest.java
                        ExclusiveC14NInterop.java
                        Canonicalizer20010315Test.java
               src_unitTests/org/apache/xml/security/test/interop
                        IAIKTest.java BaltimoreTest.java
                        RSASecurityTest.java
  Log:
  Prefix all file access with the system property 'basedir' if set.
  This is needed to make it work in Eclipse.
  
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.6       +14 -6     xml-security/src_unitTests/org/apache/xml/security/test/utils/resolver/OfflineResolver.java
  
  Index: OfflineResolver.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src_unitTests/org/apache/xml/security/test/utils/resolver/OfflineResolver.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- OfflineResolver.java	29 Apr 2003 21:37:00 -0000	1.5
  +++ OfflineResolver.java	30 Dec 2003 09:43:57 -0000	1.6
  @@ -187,21 +187,29 @@
   
         OfflineResolver._uriMap = new HashMap();
         OfflineResolver._mimeMap = new HashMap();
  +      
  +      String basedir = System.getProperty("basedir");
  +      if(basedir == null) {
  +      	basedir = "/";
  +      }
  +      else {
  +      	basedir = basedir + "/";
  +      }
   
         OfflineResolver.register("http://www.w3.org/TR/xml-stylesheet",
  -                               "data/org/w3c/www/TR/xml-stylesheet.html",
  +                               basedir + "data/org/w3c/www/TR/xml-stylesheet.html",
                                  "text/html");
         OfflineResolver.register("http://www.w3.org/TR/2000/REC-xml-20001006",
  -                               "data/org/w3c/www/TR/2000/REC-xml-20001006",
  +                               basedir + "data/org/w3c/www/TR/2000/REC-xml-20001006",
                                  "text/xml");
         OfflineResolver.register("http://www.nue.et-inf.uni-siegen.de/index.html",
  -                               "data/org/apache/xml/security/temp/nuehomepage",
  +                               basedir + "data/org/apache/xml/security/temp/nuehomepage",
                                  "text/html");
         OfflineResolver.register(
            "http://www.nue.et-inf.uni-siegen.de/~geuer-pollmann/id2.xml",
  -         "data/org/apache/xml/security/temp/id2.xml", "text/xml");
  +         basedir + "data/org/apache/xml/security/temp/id2.xml", "text/xml");
         OfflineResolver.register(
            "http://xmldsig.pothole.com/xml-stylesheet.txt",
  -         "data/com/pothole/xmldsig/xml-stylesheet.txt", "text/xml");
  +         basedir + "data/com/pothole/xmldsig/xml-stylesheet.txt", "text/xml");
      }
   }
  
  
  
  1.12      +20 -6     xml-security/src_unitTests/org/apache/xml/security/test/encryption/BaltimoreEncTest.java
  
  Index: BaltimoreEncTest.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src_unitTests/org/apache/xml/security/test/encryption/BaltimoreEncTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- BaltimoreEncTest.java	26 Dec 2003 11:20:39 -0000	1.11
  +++ BaltimoreEncTest.java	30 Dec 2003 09:43:57 -0000	1.12
  @@ -60,7 +60,6 @@
   
   import java.io.ByteArrayOutputStream;
   import java.io.File;
  -import java.io.FileInputStream;
   import java.io.IOException;
   import java.security.Key;
   import java.security.KeyFactory;
  @@ -86,6 +85,7 @@
   import org.apache.xml.security.keys.content.X509Data;
   import org.apache.xml.security.keys.content.x509.XMLX509Certificate;
   import org.apache.xml.security.keys.keyresolver.KeyResolver;
  +import org.apache.xml.security.utils.JavaUtils;
   import org.apache.xml.security.utils.XMLUtils;
   import org.apache.xml.serialize.DOMSerializer;
   import org.apache.xml.serialize.Method;
  @@ -177,6 +177,10 @@
   		
   		String filename = 
   			"data/ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml";
  +		String basedir = System.getProperty("basedir");
  +		if(basedir != null && !"".equals(basedir)) {
  +			filename = basedir + "/" + filename;
  +		}
   		File f = new File(filename);
   	
   		DocumentBuilder db = dbf.newDocumentBuilder();
  @@ -202,10 +206,12 @@
   		rsaCertSerialNumber = new String("1014918766910");
   	
   		// rsaKey
  -		FileInputStream infile = 
  -			new FileInputStream("data/ie/baltimore/merlin-examples/merlin-xmlenc-five/rsa.p8");
  -		byte[] pkcs8Bytes = new byte[10240];
  -		infile.close();
  +		filename = "data/ie/baltimore/merlin-examples/merlin-xmlenc-five/rsa.p8";
  +		if(basedir != null && !"".equals(basedir)) {
  +			filename = basedir + "/" + filename;
  +		}
  +		
  +		byte[] pkcs8Bytes = JavaUtils.getBytesFromFile(filename);
   	
   		PKCS8EncodedKeySpec pkcs8Spec = 
   			new PKCS8EncodedKeySpec(pkcs8Bytes);
  @@ -213,7 +219,7 @@
   		// Create a key factory 
   		KeyFactory keyFactory = 
   			KeyFactory.getInstance("RSA");
  -			rsaKey = keyFactory.generatePrivate(pkcs8Spec);
  +		rsaKey = keyFactory.generatePrivate(pkcs8Spec);
   	
   		// Initialise the library
   	
  @@ -463,6 +469,10 @@
   			javax.xml.parsers.DocumentBuilderFactory.newInstance();
   		dbf.setNamespaceAware(true);
   		dbf.setAttribute("http://xml.org/sax/features/namespaces", Boolean.TRUE);
  +		String basedir = System.getProperty("basedir");
  +		if(basedir != null && !"".equals(basedir)) {
  +			filename = basedir + "/" + filename;
  +		}
   		File f = new File(filename);
   
   		DocumentBuilder db = dbf.newDocumentBuilder();
  @@ -511,6 +521,10 @@
   			javax.xml.parsers.DocumentBuilderFactory.newInstance();
   		dbf.setNamespaceAware(true);
   		dbf.setAttribute("http://xml.org/sax/features/namespaces", Boolean.TRUE);
  +		String basedir = System.getProperty("basedir");
  +		if(basedir != null || !"".equals(basedir)) {
  +			filename = basedir + "/" + filename;
  +		}
   		File f = new File(filename);
   
   		DocumentBuilder db = dbf.newDocumentBuilder();
  
  
  
  1.9       +25 -16    xml-security/src_unitTests/org/apache/xml/security/test/c14n/implementations/Canonicalizer20010315ExclusiveTest.java
  
  Index: Canonicalizer20010315ExclusiveTest.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src_unitTests/org/apache/xml/security/test/c14n/implementations/Canonicalizer20010315ExclusiveTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Canonicalizer20010315ExclusiveTest.java	22 Nov 2003 12:01:27 -0000	1.8
  +++ Canonicalizer20010315ExclusiveTest.java	30 Dec 2003 09:43:57 -0000	1.9
  @@ -182,8 +182,8 @@
                     org.apache.xml.security.keys.keyresolver
                        .KeyResolverException {
   
  -      File fileIn = new File(
  -         "data/ie/baltimore/merlin-examples/ec-merlin-iaikTests-two/signature.xml");
  +      File fileIn = new File(getAbsolutePath(
  +         "data/ie/baltimore/merlin-examples/ec-merlin-iaikTests-two/signature.xml") );
   
         // File fileIn = new File("signature.xml");
         assertTrue("file exists", fileIn.exists());
  @@ -234,12 +234,12 @@
   
         Document doc =
            this.db
  -            .parse("data/org/apache/xml/security/c14n/inExcl/example2_2_1.xml");
  +            .parse(getAbsolutePath("data/org/apache/xml/security/c14n/inExcl/example2_2_1.xml") );
         Node root = doc.getElementsByTagNameNS("http://example.net",
                                                "elem2").item(0);
         Canonicalizer20010315 c = new Canonicalizer20010315WithComments();
  -      byte[] reference = JavaUtils.getBytesFromFile(
  -         "data/org/apache/xml/security/c14n/inExcl/example2_2_1_c14nized.xml");
  +      byte[] reference = JavaUtils.getBytesFromFile(getAbsolutePath(
  +         "data/org/apache/xml/security/c14n/inExcl/example2_2_1_c14nized.xml") );
         byte[] result = c.engineCanonicalizeSubTree(root);
         boolean equals = JavaUtils.binaryCompare(reference, result);
   
  @@ -273,12 +273,12 @@
   
         Document doc =
            this.db
  -            .parse("data/org/apache/xml/security/c14n/inExcl/example2_2_2.xml");
  +            .parse(getAbsolutePath("data/org/apache/xml/security/c14n/inExcl/example2_2_2.xml"));
         Node root = doc.getElementsByTagNameNS("http://example.net",
                                                "elem2").item(0);
         Canonicalizer20010315 c = new Canonicalizer20010315WithComments();
  -      byte[] reference = JavaUtils.getBytesFromFile(
  -         "data/org/apache/xml/security/c14n/inExcl/example2_2_2_c14nized.xml");
  +      byte[] reference = JavaUtils.getBytesFromFile(getAbsolutePath(
  +         "data/org/apache/xml/security/c14n/inExcl/example2_2_2_c14nized.xml"));
         byte[] result = c.engineCanonicalizeSubTree(root);
         boolean equals = JavaUtils.binaryCompare(reference, result);
   
  @@ -306,12 +306,12 @@
   
         Document doc =
            this.db
  -            .parse("data/org/apache/xml/security/c14n/inExcl/example2_2_1.xml");
  +            .parse(getAbsolutePath("data/org/apache/xml/security/c14n/inExcl/example2_2_1.xml"));
         Node root = doc.getElementsByTagNameNS("http://example.net",
                                                "elem2").item(0);
         Canonicalizer20010315Excl c = new Canonicalizer20010315ExclWithComments();
  -      byte[] reference = JavaUtils.getBytesFromFile(
  -         "data/org/apache/xml/security/c14n/inExcl/example2_2_c14nized_exclusive.xml");
  +      byte[] reference = JavaUtils.getBytesFromFile(getAbsolutePath(
  +         "data/org/apache/xml/security/c14n/inExcl/example2_2_c14nized_exclusive.xml") );
         byte[] result = c.engineCanonicalizeSubTree(root);
         boolean equals = JavaUtils.binaryCompare(reference, result);
   
  @@ -339,12 +339,12 @@
   
         Document doc =
            this.db
  -            .parse("data/org/apache/xml/security/c14n/inExcl/example2_2_2.xml");
  +            .parse(getAbsolutePath("data/org/apache/xml/security/c14n/inExcl/example2_2_2.xml"));
         Node root = doc.getElementsByTagNameNS("http://example.net",
                                                "elem2").item(0);
         Canonicalizer20010315Excl c = new Canonicalizer20010315ExclWithComments();
  -      byte[] reference = JavaUtils.getBytesFromFile(
  -         "data/org/apache/xml/security/c14n/inExcl/example2_2_c14nized_exclusive.xml");
  +      byte[] reference = JavaUtils.getBytesFromFile(getAbsolutePath(
  +         "data/org/apache/xml/security/c14n/inExcl/example2_2_c14nized_exclusive.xml") );
         byte[] result = c.engineCanonicalizeSubTree(root);
         boolean equals = JavaUtils.binaryCompare(reference, result);
   
  @@ -374,19 +374,28 @@
   
         Document doc =
            this.db
  -            .parse("data/org/apache/xml/security/c14n/inExcl/example2_2_3.xml");
  +            .parse(getAbsolutePath("data/org/apache/xml/security/c14n/inExcl/example2_2_3.xml"));
         XMLUtils.circumventBug2650(doc);
         NodeList nodes = XPathAPI.selectNodeList(doc.getDocumentElement(),
                                    "(//. | //@* | //namespace::*)[ancestor-or-self::p]");
         Canonicalizer20010315Excl c = new Canonicalizer20010315ExclWithComments();
         byte[] reference = JavaUtils.getBytesFromFile(
  -         "data/org/apache/xml/security/c14n/inExcl/example2_2_3_c14nized_exclusive.xml");
  +      		getAbsolutePath("data/org/apache/xml/security/c14n/inExcl/example2_2_3_c14nized_exclusive.xml") );
         byte[] result = c.engineCanonicalizeXPathNodeSet(nodes);
         boolean equals = JavaUtils.binaryCompare(reference, result);
         if (!equals) {
             log.warn("Error output = " + new String(result));
         }
         assertTrue(equals);
  +   }
  +   
  +   private String getAbsolutePath(String path)
  +   {
  +   	  String basedir = System.getProperty("basedir");
  +   	  if(basedir != null && !"".equals(basedir)) {
  +   		path = basedir + "/" + path;
  +   	  }
  +   	  return path;
      }
      
   }
  
  
  
  1.10      +6 -1      xml-security/src_unitTests/org/apache/xml/security/test/c14n/implementations/ExclusiveC14NInterop.java
  
  Index: ExclusiveC14NInterop.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src_unitTests/org/apache/xml/security/test/c14n/implementations/ExclusiveC14NInterop.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ExclusiveC14NInterop.java	29 Apr 2003 21:36:58 -0000	1.9
  +++ ExclusiveC14NInterop.java	30 Dec 2003 09:43:57 -0000	1.10
  @@ -181,7 +181,12 @@
       *
       * @throws Exception
       */
  -   public String t(String directory, String file) throws Exception {
  +   public String t(String directory, String file) throws Exception
  +   {
  +   	  String basedir = System.getProperty("basedir");
  +   	  if(basedir != null && !"".equals(basedir)) {
  +   	  	directory = basedir + "/" + directory;
  +   	  }
   
         File f = new File(directory + "/" + file);
         javax.xml.parsers.DocumentBuilderFactory dbf =
  
  
  
  1.18      +13 -5     xml-security/src_unitTests/org/apache/xml/security/test/c14n/implementations/Canonicalizer20010315Test.java
  
  Index: Canonicalizer20010315Test.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src_unitTests/org/apache/xml/security/test/c14n/implementations/Canonicalizer20010315Test.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Canonicalizer20010315Test.java	26 Dec 2003 11:20:39 -0000	1.17
  +++ Canonicalizer20010315Test.java	30 Dec 2003 09:43:57 -0000	1.18
  @@ -387,13 +387,15 @@
       * @throws SAXException
       * @see #test34validatingParser
       * @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-Chars">the example from the spec</A>
  -    * $todo$ Check what we have to do to get this f*cking test working!!!
       * @throws TransformerException
       */
  -   public static void _test34()
  +   public static void test34()
              throws IOException, FileNotFoundException, SAXException,
                     ParserConfigurationException, CanonicalizationException,
  -                  InvalidCanonicalizerException, TransformerException {
  +                  InvalidCanonicalizerException, TransformerException
  +   {
  +   	
  +   	  //TODO Check what we have to do to get this f*cking test working!!!
   
         String descri =
            "3.4 Character Modifications and Character References. (uncommented)";
  @@ -865,7 +867,7 @@
         org.xml.sax.EntityResolver resolver = new TestVectorResolver();
         InputStream refStream = resolver.resolveEntity(
            null,
  -            "data/org/apache/xml/security/c14n/in/testTranslationFromUTF16toUTF8.xml")
  +            prefix + "/in/testTranslationFromUTF16toUTF8.xml")
                  .getByteStream();
         byte refBytes[] = JavaUtils.getBytesFromStream(refStream);
         boolean equal = JavaUtils.binaryCompare(refBytes, c14nBytes);
  @@ -1172,6 +1174,7 @@
         // org.xml.sax.EntityResolver resolver = new TestVectorResolver();
         // documentBuilder.setEntityResolver(resolver);
         // Document doc = documentBuilder.parse(resolver.resolveEntity(null, fileIn));
  +            
         Document doc = documentBuilder.parse(fileIn);
   
         XMLUtils.circumventBug2650(doc);
  @@ -1266,7 +1269,12 @@
            throw new RuntimeException(urlEx.getMessage());
         }
         */
  -      prefix = "data/org/apache/xml/security/c14n/";
  +   	  prefix = "data/org/apache/xml/security/c14n/";
  +   	  String basedir = System.getProperty("basedir");
  +   	  if(basedir != null && !"".equals(basedir)) {
  +   		prefix = basedir + "/" + prefix;
  +      }
  +      
         org.apache.xml.security.Init.init();
      }
   }
  
  
  
  1.9       +6 -2      xml-security/src_unitTests/org/apache/xml/security/test/interop/IAIKTest.java
  
  Index: IAIKTest.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src_unitTests/org/apache/xml/security/test/interop/IAIKTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- IAIKTest.java	29 Apr 2003 21:36:58 -0000	1.8
  +++ IAIKTest.java	30 Dec 2003 09:43:57 -0000	1.9
  @@ -84,7 +84,7 @@
                       IAIKTest.class.getName());
   
      /** Field gregorsDir */
  -   static final String gregorsDir = "data/at/iaik/ixsil/";
  +   static String gregorsDir = "data/at/iaik/ixsil/";
   
      /**
       * Method suite
  @@ -468,6 +468,10 @@
      }
   
      static {
  +   	String basedir = System.getProperty("basedir");
  +   	if(basedir != null && !"".equals(basedir)) {
  +   		gregorsDir = basedir + "/" + gregorsDir;
  +   	}
         org.apache.xml.security.Init.init();
      }
   }
  
  
  
  1.9       +11 -3     xml-security/src_unitTests/org/apache/xml/security/test/interop/BaltimoreTest.java
  
  Index: BaltimoreTest.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src_unitTests/org/apache/xml/security/test/interop/BaltimoreTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BaltimoreTest.java	29 Apr 2003 21:36:58 -0000	1.8
  +++ BaltimoreTest.java	30 Dec 2003 09:43:57 -0000	1.9
  @@ -82,8 +82,10 @@
           org.apache.commons.logging.LogFactory.getLog(BaltimoreTest.class.getName());
   
      /** Field merlinsDir15           */
  -   static final String merlinsDir15 =
  +   static String merlinsDir15 =
         "data/ie/baltimore/merlin-examples/merlin-xmldsig-fifteen/";
  +   static String merlinsDir16 =
  +   	"data/ie/baltimore/merlin-examples/merlin-xmldsig-sixteen";
   
      /**
       * Method suite
  @@ -326,7 +328,7 @@
      public void test_sixteen_external_dsa() throws Exception {
   
         String filename =
  -         "data/ie/baltimore/merlin-examples/merlin-xmldsig-sixteen/signature.xml";
  +         merlinsDir16 + "/signature.xml";
         ResourceResolverSpi resolver = new OfflineResolver();
         boolean followManifests = false;
         boolean verify = false;
  @@ -346,6 +348,12 @@
      }
   
      static {
  +   	
  +   	  String basedir = System.getProperty("basedir");
  +   	  if(basedir != null && !"".equals(basedir)) {
  +   		merlinsDir15 = basedir + "/" + merlinsDir15;
  +   		merlinsDir16 = basedir + "/" + merlinsDir16;
  +   	  }
         org.apache.xml.security.Init.init();
      }
   }
  
  
  
  1.6       +6 -2      xml-security/src_unitTests/org/apache/xml/security/test/interop/RSASecurityTest.java
  
  Index: RSASecurityTest.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src_unitTests/org/apache/xml/security/test/interop/RSASecurityTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RSASecurityTest.java	29 Apr 2003 21:36:58 -0000	1.5
  +++ RSASecurityTest.java	30 Dec 2003 09:43:57 -0000	1.6
  @@ -81,7 +81,7 @@
           org.apache.commons.logging.LogFactory.getLog(RSASecurityTest.class.getName());
   
      /** Field blakesDir           */
  -   static final String blakesDir =
  +   static String blakesDir =
         "data/com/rsasecurity/bdournaee/";
   
      /**
  @@ -145,6 +145,10 @@
      }
   
      static {
  +   	  String basedir = System.getProperty("basedir");
  +   	  if(basedir != null && !"".equals(basedir)) {
  +   		blakesDir = basedir + "/" + blakesDir;
  +   	  }
         org.apache.xml.security.Init.init();
      }
   }