Author: kiwiwings
Date: Sat Oct 18 23:19:49 2014
New Revision: 1632858

URL: http://svn.apache.org/r1632858
Log:
Removed some custom classloading code, which doesn't make sense anymore
Tested a few other timestamp providers
limited the use of the additional libraries to xml dsign classes while running 
the junit tests

Modified:
    poi/trunk/build.xml
    
poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java

Modified: poi/trunk/build.xml
URL: 
http://svn.apache.org/viewvc/poi/trunk/build.xml?rev=1632858&r1=1632857&r2=1632858&view=diff
==============================================================================
--- poi/trunk/build.xml (original)
+++ poi/trunk/build.xml Sat Oct 18 23:19:49 2014
@@ -36,7 +36,7 @@ under the License.
 
     LIBRARY         LOCATION
     =======         ========
-    junit(3.8+)     http://www.junit.org
+    junit(4.11+)     http://www.junit.org
 
     To build the documentation you will need to install forrest and set
     the FORREST_HOME environment variable.  Forrest 0.5.1 required.
@@ -259,7 +259,8 @@ under the License.
         <pathelement location="${main.output.dir}"/>
         <pathelement location="${scratchpad.output.dir}"/>
         <pathelement location="${ooxml.encryption.jar}"/>
-        <path refid="ooxml.xmlsec.classpath"/>
+       <!-- classes are omitted on test cases outside the xml-dsign area to 
avoid classpath poisioning -->
+        <!--path refid="ooxml.xmlsec.classpath"/-->
     </path>
 
     <path id="test.classpath">
@@ -727,7 +728,10 @@ under the License.
                encoding="${java.source.encoding}"
                fork="yes"
                includeantruntime="false">
-            <classpath refid="ooxml.classpath"/>
+            <classpath>
+               <path refid="ooxml.classpath"/>
+               <path refid="ooxml.xmlsec.classpath"/>
+               </classpath>
         </javac>
         <javac target="${jdk.version.class}"
                source="${jdk.version.source}"
@@ -739,6 +743,7 @@ under the License.
                includeantruntime="false">
             <classpath>
                 <path refid="ooxml.classpath"/>
+               <path refid="ooxml.xmlsec.classpath"/>
                <path refid="test.ooxml.classpath"/>
                 <pathelement path="${ooxml.output.dir}"/>
                 <pathelement path="${main.output.test.dir}"/>
@@ -986,6 +991,26 @@ under the License.
                           <include name="**/${testpattern}.java"/>
                           <exclude name="**/TestUnfixedBugs.java"/>
                           <exclude name="**/All*Tests.java"/>
+                         <exclude name="**/TestSignatureInfo.java"/>
+                      </fileset>
+                  </batchtest>
+              </junit>
+            </jacoco:coverage>
+            <jacoco:coverage enabled="${coverage.enabled}" 
excludes="${coverage.excludes}" destfile="build/jacoco-@{type}-xmlsec.exec">
+              <junit printsummary="yes" fork="yes" forkmode="once" 
haltonfailure="${halt.on.test.failure}"
+                     failureproperty="ooxml.xmlsec.test.failed">
+                  <classpath>
+                       <path refid="@{classpath}"/>
+                       <path refid="ooxml.xmlsec.classpath"/>
+                  </classpath>
+                  <syspropertyset refid="junit.properties"/>
+                  <jvmarg value="${poi.test.locale}"/>
+                  <jvmarg value="-ea"/>
+                  <formatter type="plain"/>
+                  <formatter type="xml"/>
+                  <batchtest todir="${ooxml.reports.test}">
+                      <fileset dir="${ooxml.src.test}">
+                         <include name="**/TestSignatureInfo.java"/>
                       </fileset>
                   </batchtest>
               </junit>

Modified: 
poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java?rev=1632858&r1=1632857&r2=1632858&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java
 (original)
+++ 
poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java
 Sat Oct 18 23:19:49 2014
@@ -131,11 +131,14 @@ public class TSPTimeStampService impleme
             huc.setRequestProperty("Authorization", "Basic " + encoding);
         }
 
+        huc.setRequestMethod("POST");
+        huc.setConnectTimeout(20000);
+        huc.setReadTimeout(20000);
         huc.setDoOutput(true); // also sets method to POST.
         huc.setRequestProperty("User-Agent", signatureConfig.getUserAgent());
         huc.setRequestProperty("Content-Type", 
signatureConfig.isTspOldProtocol()
             ? "application/timestamp-request"
-            : "application/timestamp-query;charset=ISO-8859-1");
+            : "application/timestamp-query"); // "; charset=ISO-8859-1");
         
         OutputStream hucOut = huc.getOutputStream();
         hucOut.write(encodedRequest);

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java?rev=1632858&r1=1632857&r2=1632858&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java 
(original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java 
Sat Oct 18 23:19:49 2014
@@ -23,7 +23,10 @@
    ================================================================= */ 
 package org.apache.poi.poifs.crypt;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -32,8 +35,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Method;
 import java.net.ConnectException;
-import java.net.URL;
-import java.net.URLClassLoader;
 import java.security.Key;
 import java.security.KeyPair;
 import java.security.KeyStore;
@@ -88,28 +89,17 @@ public class TestSignatureInfo {
     private KeyPair keyPair = null;
     private X509Certificate x509 = null;
     
-
-    
     @BeforeClass
     public static void initBouncy() throws IOException {
-        File bcProvJar = new File("lib/bcprov-ext-jdk15on-1.51.jar");
-        File bcPkixJar = new File("lib/bcpkix-jdk15on-151.jar");
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        URLClassLoader ucl = new URLClassLoader(new 
URL[]{bcProvJar.toURI().toURL(),bcPkixJar.toURI().toURL()}, cl);
-        try {
-            Thread.currentThread().setContextClassLoader(ucl);
-            CryptoFunctions.registerBouncyCastle();
-    
-            /*** TODO : set cal to now ... only set to fixed date for 
debugging ... */ 
-            cal = Calendar.getInstance();
-            cal.clear();
-            cal.setTimeZone(TimeZone.getTimeZone("UTC"));
-            cal.set(2014, 7, 6, 21, 42, 12);
-        } finally {
-            ucl.close();
-        }
-    }
+        CryptoFunctions.registerBouncyCastle();
 
+        /*** TODO : set cal to now ... only set to fixed date for debugging 
... */ 
+        cal = Calendar.getInstance();
+        cal.clear();
+        cal.setTimeZone(TimeZone.getTimeZone("UTC"));
+        cal.set(2014, 7, 6, 21, 42, 12);
+    }
+    
     @Test
     public void getSignerUnsigned() throws Exception {
         String testFiles[] = { 
@@ -303,8 +293,12 @@ public class TestSignatureInfo {
         boolean mockTsp = false;
         // http://timestamping.edelweb.fr/service/tsp
         // http://tsa.belgium.be/connect
-        
signatureConfig.setTspUrl("http://timestamping.edelweb.fr/service/tsp";);
-        signatureConfig.setTspOldProtocol(true);
+        // http://timestamp.comodoca.com/authenticode
+        // http://timestamp.comodoca.com/rfc3161
+        // http://services.globaltrustfinder.com/adss/tsa
+        signatureConfig.setTspUrl("http://timestamp.comodoca.com/rfc3161";);
+        signatureConfig.setTspRequestPolicy(null); // comodoca request fails, 
if default policy is set ...
+        signatureConfig.setTspOldProtocol(false);
 
         if (mockTsp) {
             TimeStampService tspService = new TimeStampService(){



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to