]> source.dussan.org Git - poi.git/commitdiff
Removed some custom classloading code, which doesn't make sense anymore
authorAndreas Beeker <kiwiwings@apache.org>
Sat, 18 Oct 2014 23:19:49 +0000 (23:19 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sat, 18 Oct 2014 23:19:49 +0000 (23:19 +0000)
Tested a few other timestamp providers
limited the use of the additional libraries to xml dsign classes while running the junit tests

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1632858 13f79535-47bb-0310-9956-ffa450edef68

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

index 2b4c5ec0f55b41c6faee54d614ee59184d493735..cebb06aab67c340bcc2ba2b1a39e0b6ff377dd1b 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -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>
index 0937b0f3607f46c76825a5fecc31c7d5c6bba605..99a0e29982b835ebdd61ec6d584f0d83311e9f13 100644 (file)
@@ -131,11 +131,14 @@ public class TSPTimeStampService implements TimeStampService {
             huc.setRequestProperty("Authorization", "Basic " + encoding);\r
         }\r
 \r
+        huc.setRequestMethod("POST");\r
+        huc.setConnectTimeout(20000);\r
+        huc.setReadTimeout(20000);\r
         huc.setDoOutput(true); // also sets method to POST.\r
         huc.setRequestProperty("User-Agent", signatureConfig.getUserAgent());\r
         huc.setRequestProperty("Content-Type", signatureConfig.isTspOldProtocol()\r
             ? "application/timestamp-request"\r
-            : "application/timestamp-query;charset=ISO-8859-1");\r
+            : "application/timestamp-query"); // "; charset=ISO-8859-1");\r
         \r
         OutputStream hucOut = huc.getOutputStream();\r
         hucOut.write(encodedRequest);\r
index a9fa25f4e3a1e4b9cdb4d7df7b7a66e602ff5f47..e7c58eed48000fc84038f2792b94cd35e57709ad 100644 (file)
    ================================================================= */ \r
 package org.apache.poi.poifs.crypt;\r
 \r
-import static org.junit.Assert.*;\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertFalse;\r
+import static org.junit.Assert.assertNotNull;\r
+import static org.junit.Assert.assertTrue;\r
 \r
 import java.io.File;\r
 import java.io.FileInputStream;\r
@@ -32,8 +35,6 @@ import java.io.IOException;
 import java.io.InputStream;\r
 import java.lang.reflect.Method;\r
 import java.net.ConnectException;\r
-import java.net.URL;\r
-import java.net.URLClassLoader;\r
 import java.security.Key;\r
 import java.security.KeyPair;\r
 import java.security.KeyStore;\r
@@ -88,28 +89,17 @@ public class TestSignatureInfo {
     private KeyPair keyPair = null;\r
     private X509Certificate x509 = null;\r
     \r
-\r
-    \r
     @BeforeClass\r
     public static void initBouncy() throws IOException {\r
-        File bcProvJar = new File("lib/bcprov-ext-jdk15on-1.51.jar");\r
-        File bcPkixJar = new File("lib/bcpkix-jdk15on-151.jar");\r
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();\r
-        URLClassLoader ucl = new URLClassLoader(new URL[]{bcProvJar.toURI().toURL(),bcPkixJar.toURI().toURL()}, cl);\r
-        try {\r
-            Thread.currentThread().setContextClassLoader(ucl);\r
-            CryptoFunctions.registerBouncyCastle();\r
-    \r
-            /*** TODO : set cal to now ... only set to fixed date for debugging ... */ \r
-            cal = Calendar.getInstance();\r
-            cal.clear();\r
-            cal.setTimeZone(TimeZone.getTimeZone("UTC"));\r
-            cal.set(2014, 7, 6, 21, 42, 12);\r
-        } finally {\r
-            ucl.close();\r
-        }\r
-    }\r
+        CryptoFunctions.registerBouncyCastle();\r
 \r
+        /*** TODO : set cal to now ... only set to fixed date for debugging ... */ \r
+        cal = Calendar.getInstance();\r
+        cal.clear();\r
+        cal.setTimeZone(TimeZone.getTimeZone("UTC"));\r
+        cal.set(2014, 7, 6, 21, 42, 12);\r
+    }\r
+    \r
     @Test\r
     public void getSignerUnsigned() throws Exception {\r
         String testFiles[] = { \r
@@ -303,8 +293,12 @@ public class TestSignatureInfo {
         boolean mockTsp = false;\r
         // http://timestamping.edelweb.fr/service/tsp\r
         // http://tsa.belgium.be/connect\r
-        signatureConfig.setTspUrl("http://timestamping.edelweb.fr/service/tsp");\r
-        signatureConfig.setTspOldProtocol(true);\r
+        // http://timestamp.comodoca.com/authenticode\r
+        // http://timestamp.comodoca.com/rfc3161\r
+        // http://services.globaltrustfinder.com/adss/tsa\r
+        signatureConfig.setTspUrl("http://timestamp.comodoca.com/rfc3161");\r
+        signatureConfig.setTspRequestPolicy(null); // comodoca request fails, if default policy is set ...\r
+        signatureConfig.setTspOldProtocol(false);\r
 \r
         if (mockTsp) {\r
             TimeStampService tspService = new TimeStampService(){\r