Try to catch more network-unavailable cases in TestSignatureInfo
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1742422 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
26de463419
commit
56c5bd05e1
@ -36,10 +36,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.ConnectException;
|
import java.net.*;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.security.Key;
|
import java.security.Key;
|
||||||
import java.security.KeyPair;
|
import java.security.KeyPair;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
@ -82,13 +79,13 @@ import org.apache.xmlbeans.XmlObject;
|
|||||||
import org.bouncycastle.asn1.x509.KeyUsage;
|
import org.bouncycastle.asn1.x509.KeyUsage;
|
||||||
import org.bouncycastle.cert.ocsp.OCSPResp;
|
import org.bouncycastle.cert.ocsp.OCSPResp;
|
||||||
import org.etsi.uri.x01903.v13.DigestAlgAndValueType;
|
import org.etsi.uri.x01903.v13.DigestAlgAndValueType;
|
||||||
import org.etsi.uri.x01903.v13.QualifyingPropertiesType;
|
import org.etsi.uri.x01903.v13.QualifyingPropertiesType;
|
||||||
import org.junit.Assume;
|
import org.junit.Assume;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.w3.x2000.x09.xmldsig.ReferenceType;
|
import org.w3.x2000.x09.xmldsig.ReferenceType;
|
||||||
import org.w3.x2000.x09.xmldsig.SignatureDocument;
|
import org.w3.x2000.x09.xmldsig.SignatureDocument;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
public class TestSignatureInfo {
|
public class TestSignatureInfo {
|
||||||
@ -105,6 +102,7 @@ public class TestSignatureInfo {
|
|||||||
|
|
||||||
/*** 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 = LocaleUtil.getLocaleCalendar(LocaleUtil.TIMEZONE_UTC);
|
cal = LocaleUtil.getLocaleCalendar(LocaleUtil.TIMEZONE_UTC);
|
||||||
|
assertNotNull(cal);
|
||||||
// cal.set(2014, 7, 6, 21, 42, 12);
|
// cal.set(2014, 7, 6, 21, 42, 12);
|
||||||
// cal.clear(Calendar.MILLISECOND);
|
// cal.clear(Calendar.MILLISECOND);
|
||||||
|
|
||||||
@ -390,10 +388,11 @@ public class TestSignatureInfo {
|
|||||||
if(e.getCause() == null) {
|
if(e.getCause() == null) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
if(!(e.getCause() instanceof ConnectException)) {
|
if(!(e.getCause() instanceof ConnectException) && !(e.getCause() instanceof SocketTimeoutException)) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
assertTrue("Only allowing ConnectException with 'timed out' as message here, but had: " + e, e.getCause().getMessage().contains("timed out"));
|
assertTrue("Only allowing ConnectException with 'timed out' as message here, but had: " + e,
|
||||||
|
e.getCause().getMessage().contains("timed out"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify
|
// verify
|
||||||
@ -577,28 +576,31 @@ public class TestSignatureInfo {
|
|||||||
si.confirmSignature();
|
si.confirmSignature();
|
||||||
assertTrue("invalid signature", si.verifySignature());
|
assertTrue("invalid signature", si.verifySignature());
|
||||||
|
|
||||||
pkg.close();
|
pkg.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void testMultiSign() throws Exception {
|
public void testMultiSign() throws Exception {
|
||||||
initKeyPair("KeyA", "CN=KeyA");
|
initKeyPair("KeyA", "CN=KeyA");
|
||||||
KeyPair keyPairA = keyPair;
|
//KeyPair keyPairA = keyPair;
|
||||||
X509Certificate x509A = x509;
|
//X509Certificate x509A = x509;
|
||||||
initKeyPair("KeyB", "CN=KeyB");
|
initKeyPair("KeyB", "CN=KeyB");
|
||||||
KeyPair keyPairB = keyPair;
|
//KeyPair keyPairB = keyPair;
|
||||||
X509Certificate x509B = x509;
|
//X509Certificate x509B = x509;
|
||||||
|
|
||||||
File tpl = copy(testdata.getFile("bug58630.xlsx"));
|
File tpl = copy(testdata.getFile("bug58630.xlsx"));
|
||||||
OPCPackage pkg = OPCPackage.open(tpl);
|
OPCPackage pkg = OPCPackage.open(tpl);
|
||||||
SignatureConfig signatureConfig = new SignatureConfig();
|
try {
|
||||||
|
//SignatureConfig signatureConfig = new SignatureConfig();
|
||||||
|
assertNotNull(pkg);
|
||||||
}
|
} finally {
|
||||||
|
pkg.close();
|
||||||
private void sign(OPCPackage pkgCopy, String alias, String signerDn, int signerCount) throws Exception {
|
}
|
||||||
initKeyPair(alias, signerDn);
|
}
|
||||||
|
|
||||||
|
private void sign(OPCPackage pkgCopy, String alias, String signerDn, int signerCount) throws Exception {
|
||||||
|
initKeyPair(alias, signerDn);
|
||||||
|
|
||||||
SignatureConfig signatureConfig = new SignatureConfig();
|
SignatureConfig signatureConfig = new SignatureConfig();
|
||||||
signatureConfig.setKey(keyPair.getPrivate());
|
signatureConfig.setKey(keyPair.getPrivate());
|
||||||
|
Loading…
Reference in New Issue
Block a user