diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2014-10-18 23:19:49 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2014-10-18 23:19:49 +0000 |
commit | 90359aefff2b593f83377981b33ab6911079f072 (patch) | |
tree | cb336edbfbb0c77e6e10ba2a524671eb7f636cdd | |
parent | ac777eb7c89488dc08e16577a4ff3e2bf4970edc (diff) | |
download | poi-90359aefff2b593f83377981b33ab6911079f072.tar.gz poi-90359aefff2b593f83377981b33ab6911079f072.zip |
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
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1632858 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | build.xml | 31 | ||||
-rw-r--r-- | src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java | 5 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java | 42 |
3 files changed, 50 insertions, 28 deletions
@@ -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> diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java index 0937b0f360..99a0e29982 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java @@ -131,11 +131,14 @@ public class TSPTimeStampService implements TimeStampService { 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);
diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java index a9fa25f4e3..e7c58eed48 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java @@ -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(){
|