aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java/org/apache/poi/poifs/crypt
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2014-08-16 19:21:31 +0000
committerAndreas Beeker <kiwiwings@apache.org>2014-08-16 19:21:31 +0000
commit3bf0b0bd1046bd8a8044db45b5f662985f66dee3 (patch)
treec8a4f04acc20b800056fab7555b5fddc7b1644bb /src/ooxml/java/org/apache/poi/poifs/crypt
parentbf87859a207a21da38ce32b4d1d1a3ae6a03f17d (diff)
downloadpoi-3bf0b0bd1046bd8a8044db45b5f662985f66dee3.tar.gz
poi-3bf0b0bd1046bd8a8044db45b5f662985f66dee3.zip
- Updated to BC 1.51
- Download BC/test-libs in build.xml git-svn-id: https://svn.apache.org/repos/asf/poi/branches/xml_signature@1618403 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi/poifs/crypt')
-rw-r--r--src/ooxml/java/org/apache/poi/poifs/crypt/dsig/HorribleProxies.java111
-rw-r--r--src/ooxml/java/org/apache/poi/poifs/crypt/dsig/HorribleProxy.java16
-rw-r--r--src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java17
3 files changed, 107 insertions, 37 deletions
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/HorribleProxies.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/HorribleProxies.java
index 9a6d6c3bf6..8a0ce9694e 100644
--- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/HorribleProxies.java
+++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/HorribleProxies.java
@@ -30,13 +30,21 @@ public interface HorribleProxies {
ASN1OctetStringIf readObject$ASNString() throws IOException;
DEROctetStringIf readObject$DERString() throws IOException;
- DERIntegerIf readObject$Integer() throws IOException;
+ ASN1IntegerIf readObject$Integer() throws IOException;
ASN1SequenceIf readObject$Sequence() throws IOException;
Object readObject$Object() throws IOException;
}
+ public interface ASN1IntegerIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.asn1.ASN1Integer";
+
+ BigInteger getPositiveValue();
+ }
+
public interface ASN1ObjectIdentifierIf extends ProxyIf {
String delegateClass = "org.bouncycastle.asn1.ASN1ObjectIdentifier";
+
+ String getId();
}
public interface ASN1OctetStringIf extends ProxyIf {
@@ -62,7 +70,7 @@ public interface HorribleProxies {
}
public interface BasicOCSPRespIf extends ProxyIf {
- String delegateClass = "org.bouncycastle.ocsp.BasicOCSPResp";
+ String delegateClass = "org.bouncycastle.cert.ocsp.BasicOCSPResp";
Date getProducedAt();
RespIDIf getResponderId();
}
@@ -101,11 +109,6 @@ public interface HorribleProxies {
String delegateClass = "org.bouncycastle.asn1.DERIA5String";
}
- public interface DERIntegerIf extends ProxyIf {
- String delegateClass = "org.bouncycastle.asn1.DERInteger";
- BigInteger getPositiveValue();
- }
-
public interface DEROctetStringIf extends ProxyIf {
String delegateClass = "org.bouncycastle.asn1.DEROctetString";
byte[] getOctets();
@@ -152,6 +155,15 @@ public interface HorribleProxies {
void marshal(Node node, String prefix, DOMCryptoContext context) throws MarshalException;
}
+ public interface ExtensionsIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.asn1.x509.Extensions";
+ }
+
+ public interface ExtensionIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.asn1.x509.Extension";
+ }
+
+
public interface GeneralNameIf extends ProxyIf {
String delegateClass = "org.bouncycastle.asn1.x509.GeneralName";
@@ -168,13 +180,48 @@ public interface HorribleProxies {
void init();
}
+ public interface JcaDigestCalculatorProviderBuilderIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder";
+ JcaDigestCalculatorProviderBuilderIf setProvider(String provider);
+ DigestCalculatorProviderIf build();
+ }
+
+ public interface JcaContentSignerBuilderIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.operator.jcajce.JcaContentSignerBuilder";
+
+ JcaContentSignerBuilderIf setProvider(String provider);
+ ContentSignerIf build(PrivateKey paramPrivateKey);
+ }
+
+ public interface ContentSignerIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.operator.ContentSigner";
+ }
+
+ public interface DigestCalculatorProviderIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.operator.DigestCalculatorProvider";
+ DigestCalculatorIf get(AlgorithmIdentifierIf paramAlgorithmIdentifier);
+ }
+
+ public interface DigestCalculatorIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.operator.DigestCalculator";
+ }
+
+ public interface AlgorithmIdentifierIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.asn1.x509.AlgorithmIdentifier";
+ }
+
public interface KeyUsageIf extends ProxyIf {
String delegateClass = "org.bouncycastle.asn1.x509.KeyUsage";
int digitalSignature();
}
+ public interface OCSPObjectIdentifiersIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.asn1.ocsp.OCSPObjectIdentifiers";
+ ASN1ObjectIdentifierIf id_pkix_ocsp_nonce();
+ }
+
public interface OCSPRespIf extends ProxyIf {
- String delegateClass = "org.bouncycastle.ocsp.OCSPResp";
+ String delegateClass = "org.bouncycastle.cert.ocsp.OCSPResp";
BasicOCSPRespIf getResponseObject();
byte[] getEncoded() throws IOException;
}
@@ -185,7 +232,7 @@ public interface HorribleProxies {
}
public interface RespIDIf extends ProxyIf {
- String delegateClass = "org.bouncycastle.ocsp.RespID";
+ String delegateClass = "org.bouncycastle.cert.ocsp.RespID";
ResponderIDIf toASN1Object();
}
@@ -291,30 +338,39 @@ public interface HorribleProxies {
}
public interface OCSPReqIf extends ProxyIf {
- String delegateClass = "org.bouncycastle.ocsp.OCSPReq";
+ String delegateClass = "org.bouncycastle.cert.ocsp.OCSPReq";
ReqIf[] getRequestList();
}
- public interface OCSPReqGeneratorIf extends ProxyIf {
- String delegateClass = "org.bouncycastle.ocsp.OCSPReqGenerator";
-
- void addRequest(CertificateIDIf certId);
- OCSPReqIf generate();
+ public interface OCSPReqBuilderIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.cert.ocsp.OCSPReqBuilder";
+
+ OCSPReqBuilderIf addRequest(CertificateIDIf certId);
+ OCSPReqBuilderIf setRequestExtensions(ExtensionsIf paramExtensions);
+ OCSPReqIf build();
}
- public interface BasicOCSPRespGeneratorIf extends ProxyIf {
- String delegateClass = "org.bouncycastle.ocsp.BasicOCSPRespGenerator";
+ public interface OCSPRespBuilderIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.cert.ocsp.OCSPRespBuilder";
+
+ OCSPRespIf build(int status, BasicOCSPRespIf basicOcspResp);
+ int SUCCESSFUL();
+ }
+
+
+ public interface BasicOCSPRespBuilderIf extends ProxyIf {
+ String delegateClass = "org.bouncycastle.cert.ocsp.BasicOCSPRespBuilder";
- void addResponse(CertificateIDIf certificateID, CertificateStatusIf certificateStatus);
- BasicOCSPRespIf generate(String signatureAlgorithm, PrivateKey ocspResponderPrivateKey,
- X509Certificate chain[], Date date, String provider);
+ BasicOCSPRespBuilderIf addResponse(CertificateIDIf certificateID, CertificateStatusIf certificateStatus);
+ BasicOCSPRespBuilderIf setResponseExtensions(ExtensionsIf paramExtensions);
+ BasicOCSPRespIf build(ContentSignerIf paramContentSigner, X509CertificateHolderIf[] paramArrayOfX509CertificateHolder, Date paramDate);
}
public interface CertificateIDIf extends ProxyIf {
- String delegateClass = "org.bouncycastle.ocsp.CertificateID";
+ String delegateClass = "org.bouncycastle.cert.ocsp.CertificateID";
- String HASH_SHA1();
+ AlgorithmIdentifierIf HASH_SHA1();
}
public interface X509ExtensionsIf extends ProxyIf {
@@ -348,13 +404,13 @@ public interface HorribleProxies {
}
public interface ReqIf extends ProxyIf {
- String delegateClass = "org.bouncycastle.ocsp.Req";
+ String delegateClass = "org.bouncycastle.cert.ocsp.Req";
CertificateIDIf getCertID();
}
public interface CertificateStatusIf extends ProxyIf {
- String delegateClass = "org.bouncycastle.ocsp.CertificateStatus";
+ String delegateClass = "org.bouncycastle.cert.ocsp.CertificateStatus";
CertificateStatusIf GOOD();
}
@@ -366,11 +422,6 @@ public interface HorribleProxies {
public interface CRLReasonIf extends ProxyIf {
String delegateClass = "org.bouncycastle.asn1.x509.CRLReason";
int unspecified();
- }
-
- public interface OCSPRespGeneratorIf extends ProxyIf {
- String delegateClass = "org.bouncycastle.ocsp.OCSPRespGenerator";
- int SUCCESSFUL();
- OCSPRespIf generate(int status, BasicOCSPRespIf basicOCSPResp);
+ int privilegeWithdrawn();
}
}
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/HorribleProxy.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/HorribleProxy.java
index 7dd05db7cf..d64b4ebc78 100644
--- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/HorribleProxy.java
+++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/HorribleProxy.java
@@ -30,6 +30,7 @@ public class HorribleProxy implements InvocationHandler {
this.delegateClass = delegateClass;
// delegateRef can be null, then we have to deal with deferred initialisation
this.delegateRef = delegateRef;
+ initDeferred = (delegateRef == null);
}
/**
@@ -211,7 +212,20 @@ public class HorribleProxy implements InvocationHandler {
types[i] = args[i].getClass();
}
- if (ProxyIf.class.isAssignableFrom(types[i])) {
+ if (types[i].isArray()) {
+ // TODO: check for null arguments ...
+ if (ProxyIf.class.isAssignableFrom(types[i].getComponentType())) {
+ ProxyIf pifs[] = (ProxyIf[])args[i];
+ Class<?> dc = getDelegateClass((Class<? extends ProxyIf>)types[i].getComponentType());
+ int dcArrSize = (pifs==null ? 0 : pifs.length);
+ Object[] dcArr = (Object[])Array.newInstance(dc, dcArrSize);
+ for (int j=0;j<dcArrSize;j++) {
+ dcArr[j] = pifs[j].getDelegate();
+ }
+ args[i] = dcArr;
+ types[i] = dcArr.getClass();
+ }
+ } else if (ProxyIf.class.isAssignableFrom(types[i])) {
types[i] = getDelegateClass((Class<? extends ProxyIf>)types[i]);
if (args[i] != null) {
args[i] = ((ProxyIf)args[i]).getDelegate();
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java
index 44a0e24532..2d7946e777 100644
--- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java
+++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java
@@ -24,6 +24,8 @@
package org.apache.poi.poifs.crypt.dsig.facets;
+import static org.apache.poi.poifs.crypt.dsig.HorribleProxy.newProxy;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.math.BigInteger;
@@ -49,15 +51,16 @@ import javax.xml.crypto.dsig.XMLSignatureFactory;
import org.apache.poi.poifs.crypt.HashAlgorithm;
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.ASN1InputStreamIf;
+import org.apache.poi.poifs.crypt.dsig.HorribleProxies.ASN1IntegerIf;
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.ASN1OctetStringIf;
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.BasicOCSPRespIf;
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.CanonicalizerIf;
-import org.apache.poi.poifs.crypt.dsig.HorribleProxies.DERIntegerIf;
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.DERTaggedObjectIf;
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.InitIf;
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.OCSPRespIf;
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.RespIDIf;
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.ResponderIDIf;
+import org.apache.poi.poifs.crypt.dsig.HorribleProxies.X509ExtensionsIf;
import org.apache.poi.poifs.crypt.dsig.HorribleProxies.X509NameIf;
import org.apache.poi.poifs.crypt.dsig.HorribleProxy;
import org.apache.poi.poifs.crypt.dsig.SignatureInfo;
@@ -392,16 +395,18 @@ public class XAdESXLSignatureFacet implements SignatureFacet {
}
private BigInteger getCrlNumber(X509CRL crl) {
- byte[] crlNumberExtensionValue = crl.getExtensionValue("2.5.29.20" /*CRLNumber*/);
- if (null == crlNumberExtensionValue) {
- return null;
- }
try {
+ X509ExtensionsIf x509ext = newProxy(X509ExtensionsIf.class);
+ byte[] crlNumberExtensionValue = crl.getExtensionValue(x509ext.CRLNumber().getId());
+ if (null == crlNumberExtensionValue) {
+ return null;
+ }
+
ASN1InputStreamIf asn1InputStream = HorribleProxy.newProxy(ASN1InputStreamIf.class, crlNumberExtensionValue);
ASN1OctetStringIf octetString = asn1InputStream.readObject$ASNString();
byte[] octets = octetString.getOctets();
asn1InputStream = HorribleProxy.newProxy(ASN1InputStreamIf.class, octets);
- DERIntegerIf integer = asn1InputStream.readObject$Integer();
+ ASN1IntegerIf integer = asn1InputStream.readObject$Integer();
BigInteger crlNumber = integer.getPositiveValue();
return crlNumber;
} catch (Exception e) {