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
This commit is contained in:
parent
802bc7cd8a
commit
14f3200486
31
build.xml
31
build.xml
@ -36,7 +36,7 @@ under the License.
|
|||||||
|
|
||||||
LIBRARY LOCATION
|
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
|
To build the documentation you will need to install forrest and set
|
||||||
the FORREST_HOME environment variable. Forrest 0.5.1 required.
|
the FORREST_HOME environment variable. Forrest 0.5.1 required.
|
||||||
@ -259,7 +259,8 @@ under the License.
|
|||||||
<pathelement location="${main.output.dir}"/>
|
<pathelement location="${main.output.dir}"/>
|
||||||
<pathelement location="${scratchpad.output.dir}"/>
|
<pathelement location="${scratchpad.output.dir}"/>
|
||||||
<pathelement location="${ooxml.encryption.jar}"/>
|
<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>
|
||||||
|
|
||||||
<path id="test.classpath">
|
<path id="test.classpath">
|
||||||
@ -727,7 +728,10 @@ under the License.
|
|||||||
encoding="${java.source.encoding}"
|
encoding="${java.source.encoding}"
|
||||||
fork="yes"
|
fork="yes"
|
||||||
includeantruntime="false">
|
includeantruntime="false">
|
||||||
<classpath refid="ooxml.classpath"/>
|
<classpath>
|
||||||
|
<path refid="ooxml.classpath"/>
|
||||||
|
<path refid="ooxml.xmlsec.classpath"/>
|
||||||
|
</classpath>
|
||||||
</javac>
|
</javac>
|
||||||
<javac target="${jdk.version.class}"
|
<javac target="${jdk.version.class}"
|
||||||
source="${jdk.version.source}"
|
source="${jdk.version.source}"
|
||||||
@ -739,6 +743,7 @@ under the License.
|
|||||||
includeantruntime="false">
|
includeantruntime="false">
|
||||||
<classpath>
|
<classpath>
|
||||||
<path refid="ooxml.classpath"/>
|
<path refid="ooxml.classpath"/>
|
||||||
|
<path refid="ooxml.xmlsec.classpath"/>
|
||||||
<path refid="test.ooxml.classpath"/>
|
<path refid="test.ooxml.classpath"/>
|
||||||
<pathelement path="${ooxml.output.dir}"/>
|
<pathelement path="${ooxml.output.dir}"/>
|
||||||
<pathelement path="${main.output.test.dir}"/>
|
<pathelement path="${main.output.test.dir}"/>
|
||||||
@ -986,6 +991,26 @@ under the License.
|
|||||||
<include name="**/${testpattern}.java"/>
|
<include name="**/${testpattern}.java"/>
|
||||||
<exclude name="**/TestUnfixedBugs.java"/>
|
<exclude name="**/TestUnfixedBugs.java"/>
|
||||||
<exclude name="**/All*Tests.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>
|
</fileset>
|
||||||
</batchtest>
|
</batchtest>
|
||||||
</junit>
|
</junit>
|
||||||
|
@ -131,11 +131,14 @@ public class TSPTimeStampService implements TimeStampService {
|
|||||||
huc.setRequestProperty("Authorization", "Basic " + encoding);
|
huc.setRequestProperty("Authorization", "Basic " + encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
huc.setRequestMethod("POST");
|
||||||
|
huc.setConnectTimeout(20000);
|
||||||
|
huc.setReadTimeout(20000);
|
||||||
huc.setDoOutput(true); // also sets method to POST.
|
huc.setDoOutput(true); // also sets method to POST.
|
||||||
huc.setRequestProperty("User-Agent", signatureConfig.getUserAgent());
|
huc.setRequestProperty("User-Agent", signatureConfig.getUserAgent());
|
||||||
huc.setRequestProperty("Content-Type", signatureConfig.isTspOldProtocol()
|
huc.setRequestProperty("Content-Type", signatureConfig.isTspOldProtocol()
|
||||||
? "application/timestamp-request"
|
? "application/timestamp-request"
|
||||||
: "application/timestamp-query;charset=ISO-8859-1");
|
: "application/timestamp-query"); // "; charset=ISO-8859-1");
|
||||||
|
|
||||||
OutputStream hucOut = huc.getOutputStream();
|
OutputStream hucOut = huc.getOutputStream();
|
||||||
hucOut.write(encodedRequest);
|
hucOut.write(encodedRequest);
|
||||||
|
@ -23,7 +23,10 @@
|
|||||||
================================================================= */
|
================================================================= */
|
||||||
package org.apache.poi.poifs.crypt;
|
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.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -32,8 +35,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.security.Key;
|
import java.security.Key;
|
||||||
import java.security.KeyPair;
|
import java.security.KeyPair;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
@ -88,26 +89,15 @@ public class TestSignatureInfo {
|
|||||||
private KeyPair keyPair = null;
|
private KeyPair keyPair = null;
|
||||||
private X509Certificate x509 = null;
|
private X509Certificate x509 = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initBouncy() throws IOException {
|
public static void initBouncy() throws IOException {
|
||||||
File bcProvJar = new File("lib/bcprov-ext-jdk15on-1.51.jar");
|
CryptoFunctions.registerBouncyCastle();
|
||||||
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 ... */
|
/*** TODO : set cal to now ... only set to fixed date for debugging ... */
|
||||||
cal = Calendar.getInstance();
|
cal = Calendar.getInstance();
|
||||||
cal.clear();
|
cal.clear();
|
||||||
cal.setTimeZone(TimeZone.getTimeZone("UTC"));
|
cal.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
cal.set(2014, 7, 6, 21, 42, 12);
|
cal.set(2014, 7, 6, 21, 42, 12);
|
||||||
} finally {
|
|
||||||
ucl.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -303,8 +293,12 @@ public class TestSignatureInfo {
|
|||||||
boolean mockTsp = false;
|
boolean mockTsp = false;
|
||||||
// http://timestamping.edelweb.fr/service/tsp
|
// http://timestamping.edelweb.fr/service/tsp
|
||||||
// http://tsa.belgium.be/connect
|
// http://tsa.belgium.be/connect
|
||||||
signatureConfig.setTspUrl("http://timestamping.edelweb.fr/service/tsp");
|
// http://timestamp.comodoca.com/authenticode
|
||||||
signatureConfig.setTspOldProtocol(true);
|
// 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) {
|
if (mockTsp) {
|
||||||
TimeStampService tspService = new TimeStampService(){
|
TimeStampService tspService = new TimeStampService(){
|
||||||
|
Loading…
Reference in New Issue
Block a user