mirror of https://github.com/apache/poi.git
some changes because of test errors
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/xml_signature@1618254 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
085f1f25ec
commit
ea5645e80f
|
@ -24,6 +24,7 @@
|
||||||
<classpathentry kind="lib" path="lib/junit-4.11.jar"/>
|
<classpathentry kind="lib" path="lib/junit-4.11.jar"/>
|
||||||
<classpathentry kind="lib" path="ooxml-lib/ooxml-schemas-1.1.jar" sourcepath="ooxml-lib/ooxml-schemas-src-1.1.jar"/>
|
<classpathentry kind="lib" path="ooxml-lib/ooxml-schemas-1.1.jar" sourcepath="ooxml-lib/ooxml-schemas-src-1.1.jar"/>
|
||||||
<classpathentry kind="lib" path="ooxml-lib/ooxml-encryption-1.2.jar" sourcepath="ooxml-lib/ooxml-encryption-src-1.2.jar"/>
|
<classpathentry kind="lib" path="ooxml-lib/ooxml-encryption-1.2.jar" sourcepath="ooxml-lib/ooxml-encryption-src-1.2.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/com.springsource.org.objenesis-1.0.0.jar"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="lib" path="lib/mockito-core-1.9.5.jar" sourcepath="E:/tmp/mavenRepo/org/mockito/mockito-core/1.9.5/mockito-core-1.9.5-sources.jar"/>
|
<classpathentry kind="lib" path="lib/mockito-core-1.9.5.jar" sourcepath="E:/tmp/mavenRepo/org/mockito/mockito-core/1.9.5/mockito-core-1.9.5-sources.jar"/>
|
||||||
<classpathentry kind="output" path="build/eclipse"/>
|
<classpathentry kind="output" path="build/eclipse"/>
|
||||||
|
|
|
@ -278,7 +278,9 @@ public class CryptoFunctions {
|
||||||
public static void registerBouncyCastle() {
|
public static void registerBouncyCastle() {
|
||||||
if (Security.getProvider("BC") != null) return;
|
if (Security.getProvider("BC") != null) return;
|
||||||
try {
|
try {
|
||||||
Class<Provider> clazz = (Class<Provider>)Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
|
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||||
|
String bcProviderName = "org.bouncycastle.jce.provider.BouncyCastleProvider";
|
||||||
|
Class<Provider> clazz = (Class<Provider>)cl.loadClass(bcProviderName);
|
||||||
Security.addProvider(clazz.newInstance());
|
Security.addProvider(clazz.newInstance());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new EncryptedDocumentException("Only the BouncyCastle provider supports your encryption settings - please add it to the classpath.");
|
throw new EncryptedDocumentException("Only the BouncyCastle provider supports your encryption settings - please add it to the classpath.");
|
||||||
|
|
|
@ -62,7 +62,7 @@ public interface HorribleProxies {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface BasicOCSPRespIf extends ProxyIf {
|
public interface BasicOCSPRespIf extends ProxyIf {
|
||||||
String delegateClass = "org.bouncycastle.cert.ocsp.BasicOCSPResp";
|
String delegateClass = "org.bouncycastle.ocsp.BasicOCSPResp";
|
||||||
Date getProducedAt();
|
Date getProducedAt();
|
||||||
RespIDIf getResponderId();
|
RespIDIf getResponderId();
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ public interface HorribleProxies {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OCSPRespIf extends ProxyIf {
|
public interface OCSPRespIf extends ProxyIf {
|
||||||
String delegateClass = "org.bouncycastle.cert.ocsp.OCSPResp";
|
String delegateClass = "org.bouncycastle.ocsp.OCSPResp";
|
||||||
BasicOCSPRespIf getResponseObject();
|
BasicOCSPRespIf getResponseObject();
|
||||||
byte[] getEncoded() throws IOException;
|
byte[] getEncoded() throws IOException;
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ public interface HorribleProxies {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface RespIDIf extends ProxyIf {
|
public interface RespIDIf extends ProxyIf {
|
||||||
String delegateClass = "org.bouncycastle.cert.ocsp.RespID";
|
String delegateClass = "org.bouncycastle.ocsp.RespID";
|
||||||
ResponderIDIf toASN1Object();
|
ResponderIDIf toASN1Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ public interface HorribleProxies {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OCSPReqIf extends ProxyIf {
|
public interface OCSPReqIf extends ProxyIf {
|
||||||
String delegateClass = "org.bouncycastle.cert.ocsp.OCSPReq";
|
String delegateClass = "org.bouncycastle.ocsp.OCSPReq";
|
||||||
|
|
||||||
ReqIf[] getRequestList();
|
ReqIf[] getRequestList();
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ public interface HorribleProxies {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface CertificateIDIf extends ProxyIf {
|
public interface CertificateIDIf extends ProxyIf {
|
||||||
String delegateClass = "org.bouncycastle.cert.ocsp.CertificateID";
|
String delegateClass = "org.bouncycastle.ocsp.CertificateID";
|
||||||
|
|
||||||
String HASH_SHA1();
|
String HASH_SHA1();
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ public interface HorribleProxies {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface X509V2CRLGeneratorIf extends ProxyIf {
|
public interface X509V2CRLGeneratorIf extends ProxyIf {
|
||||||
String delegateClass = "org.bouncycastle.asn1.x509.X509V2CRLGenerator";
|
String delegateClass = "org.bouncycastle.x509.X509V2CRLGenerator";
|
||||||
|
|
||||||
void setIssuerDN(X500Principal issuerDN);
|
void setIssuerDN(X500Principal issuerDN);
|
||||||
void setThisUpdate(Date date);
|
void setThisUpdate(Date date);
|
||||||
|
@ -348,19 +348,19 @@ public interface HorribleProxies {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ReqIf extends ProxyIf {
|
public interface ReqIf extends ProxyIf {
|
||||||
String delegateClass = "org.bouncycastle.cert.ocsp.Req";
|
String delegateClass = "org.bouncycastle.ocsp.Req";
|
||||||
|
|
||||||
CertificateIDIf getCertID();
|
CertificateIDIf getCertID();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface CertificateStatusIf extends ProxyIf {
|
public interface CertificateStatusIf extends ProxyIf {
|
||||||
String delegateClass = "org.bouncycastle.cert.ocsp.CertificateStatus";
|
String delegateClass = "org.bouncycastle.ocsp.CertificateStatus";
|
||||||
|
|
||||||
CertificateStatusIf GOOD();
|
CertificateStatusIf GOOD();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface RevokedStatusIf extends ProxyIf {
|
public interface RevokedStatusIf extends ProxyIf {
|
||||||
String delegateClass = "org.bouncycastle.cert.ocsp.RevokedStatus";
|
String delegateClass = "org.bouncycastle.ocsp.RevokedStatus";
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface CRLReasonIf extends ProxyIf {
|
public interface CRLReasonIf extends ProxyIf {
|
||||||
|
|
|
@ -146,6 +146,7 @@ public class HorribleProxy implements InvocationHandler {
|
||||||
try {
|
try {
|
||||||
Field f = delegateClass.getDeclaredField(methodName);
|
Field f = delegateClass.getDeclaredField(methodName);
|
||||||
ret = f.get(delegateRef);
|
ret = f.get(delegateRef);
|
||||||
|
if (ret == null) return null;
|
||||||
isStaticField = true;
|
isStaticField = true;
|
||||||
} catch (NoSuchFieldException e) {
|
} catch (NoSuchFieldException e) {
|
||||||
LOG.log(POILogger.DEBUG, "No static field '"+methodName+"' in class '"+delegateClass.getCanonicalName()+"' - trying method now.");
|
LOG.log(POILogger.DEBUG, "No static field '"+methodName+"' in class '"+delegateClass.getCanonicalName()+"' - trying method now.");
|
||||||
|
|
|
@ -50,7 +50,6 @@ import javax.xml.transform.TransformerFactory;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
import org.apache.poi.poifs.crypt.dsig.HorribleProxy;
|
|
||||||
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.ASN1InputStreamIf;
|
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.ASN1InputStreamIf;
|
||||||
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.AuthorityInformationAccessIf;
|
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.AuthorityInformationAccessIf;
|
||||||
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.AuthorityKeyIdentifierIf;
|
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.AuthorityKeyIdentifierIf;
|
||||||
|
@ -81,6 +80,7 @@ import org.apache.poi.poifs.crypt.dsig.HorribleProxies.X509ObjectIdentifiersIf;
|
||||||
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.X509PrincipalIf;
|
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.X509PrincipalIf;
|
||||||
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.X509V2CRLGeneratorIf;
|
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.X509V2CRLGeneratorIf;
|
||||||
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.X509V3CertificateGeneratorIf;
|
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.X509V3CertificateGeneratorIf;
|
||||||
|
import org.apache.poi.poifs.crypt.dsig.HorribleProxy;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
|
@ -282,7 +282,8 @@ public class PkiTestUtils {
|
||||||
// request
|
// request
|
||||||
OCSPReqGeneratorIf ocspReqGenerator = HorribleProxy.newProxy(OCSPReqGeneratorIf.class);
|
OCSPReqGeneratorIf ocspReqGenerator = HorribleProxy.newProxy(OCSPReqGeneratorIf.class);
|
||||||
CertificateIDIf certId = HorribleProxy.newProxy(CertificateIDIf.class);
|
CertificateIDIf certId = HorribleProxy.newProxy(CertificateIDIf.class);
|
||||||
certId = HorribleProxy.newProxy(CertificateIDIf.class, certId.HASH_SHA1(),
|
String hashSha1 = certId.HASH_SHA1();
|
||||||
|
certId = HorribleProxy.newProxy(CertificateIDIf.class, hashSha1,
|
||||||
issuerCertificate, certificate.getSerialNumber());
|
issuerCertificate, certificate.getSerialNumber());
|
||||||
ocspReqGenerator.addRequest(certId);
|
ocspReqGenerator.addRequest(certId);
|
||||||
OCSPReqIf ocspReq = ocspReqGenerator.generate();
|
OCSPReqIf ocspReq = ocspReqGenerator.generate();
|
||||||
|
|
|
@ -95,6 +95,7 @@ public class TestSignatureInfo {
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||||
URLClassLoader ucl = new URLClassLoader(new URL[]{bcJar.toURI().toURL()}, cl);
|
URLClassLoader ucl = new URLClassLoader(new URL[]{bcJar.toURI().toURL()}, cl);
|
||||||
Thread.currentThread().setContextClassLoader(ucl);
|
Thread.currentThread().setContextClassLoader(ucl);
|
||||||
|
CryptoFunctions.registerBouncyCastle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue