1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
Description: iText 2.1.7 was developped for Bouncy Castle 1.38 and no longer works
with the recent versions. This patch addresses this issue and fixes the
compilation errors with Bouncy Castle 1.47 and later.
http://www.bouncycastle.org/wiki/display/JA1/Porting+from+earlier+BC+releases+to+1.47+and+later
Author: Emmanuel Bourg <ebourg@apache.org>
Origin: vendor
Forwarded: not-needed
--- a/core/com/lowagie/text/pdf/PdfPKCS7.java
+++ b/core/com/lowagie/text/pdf/PdfPKCS7.java
@@ -77,21 +77,22 @@
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
+import org.bouncycastle.asn1.ASN1Encoding;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1OutputStream;
+import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1Set;
+import org.bouncycastle.asn1.ASN1String;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DEREnumerated;
import org.bouncycastle.asn1.DERInteger;
import org.bouncycastle.asn1.DERNull;
-import org.bouncycastle.asn1.DERObject;
import org.bouncycastle.asn1.DERObjectIdentifier;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DEROutputStream;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.DERSet;
-import org.bouncycastle.asn1.DERString;
import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.DERUTCTime;
import org.bouncycastle.asn1.cms.AttributeTable;
@@ -379,7 +380,7 @@
//
// Basic checks to make sure it's a PKCS#7 SignedData Object
//
- DERObject pkcs;
+ ASN1Primitive pkcs;
try {
pkcs = din.readObject();
@@ -464,7 +465,7 @@
if (signerInfo.getObjectAt(next) instanceof ASN1TaggedObject) {
ASN1TaggedObject tagsig = (ASN1TaggedObject)signerInfo.getObjectAt(next);
ASN1Set sseq = ASN1Set.getInstance(tagsig, false);
- sigAttr = sseq.getEncoded(ASN1Encodable.DER);
+ sigAttr = sseq.getEncoded(ASN1Encoding.DER);
for (int k = 0; k < sseq.size(); ++k) {
ASN1Sequence seq2 = (ASN1Sequence)sseq.getObjectAt(k);
@@ -949,7 +950,7 @@
*/
public static String getOCSPURL(X509Certificate certificate) throws CertificateParsingException {
try {
- DERObject obj = getExtensionValue(certificate, X509Extensions.AuthorityInfoAccess.getId());
+ ASN1Primitive obj = getExtensionValue(certificate, X509Extensions.AuthorityInfoAccess.getId());
if (obj == null) {
return null;
}
@@ -961,7 +962,7 @@
continue;
} else {
if ((AccessDescription.getObjectAt(0) instanceof DERObjectIdentifier) && ((DERObjectIdentifier)AccessDescription.getObjectAt(0)).getId().equals("1.3.6.1.5.5.7.48.1")) {
- String AccessLocation = getStringFromGeneralName((DERObject)AccessDescription.getObjectAt(1));
+ String AccessLocation = getStringFromGeneralName((ASN1Primitive)AccessDescription.getObjectAt(1));
if ( AccessLocation == null ) {
return "" ;
} else {
@@ -999,7 +1000,7 @@
return false;
}
- private static DERObject getExtensionValue(X509Certificate cert, String oid) throws IOException {
+ private static ASN1Primitive getExtensionValue(X509Certificate cert, String oid) throws IOException {
byte[] bytes = cert.getExtensionValue(oid);
if (bytes == null) {
return null;
@@ -1010,7 +1011,7 @@
return aIn.readObject();
}
- private static String getStringFromGeneralName(DERObject names) throws IOException {
+ private static String getStringFromGeneralName(ASN1Primitive names) throws IOException {
DERTaggedObject taggedObject = (DERTaggedObject) names ;
return new String(ASN1OctetString.getInstance(taggedObject, false).getOctets(), "ISO-8859-1");
}
@@ -1020,11 +1021,11 @@
* @param enc a TBSCertificate in a byte array
* @return a DERObject
*/
- private static DERObject getIssuer(byte[] enc) {
+ private static ASN1Primitive getIssuer(byte[] enc) {
try {
ASN1InputStream in = new ASN1InputStream(new ByteArrayInputStream(enc));
ASN1Sequence seq = (ASN1Sequence)in.readObject();
- return (DERObject)seq.getObjectAt(seq.getObjectAt(0) instanceof DERTaggedObject ? 3 : 2);
+ return (ASN1Primitive)seq.getObjectAt(seq.getObjectAt(0) instanceof DERTaggedObject ? 3 : 2);
}
catch (IOException e) {
throw new ExceptionConverter(e);
@@ -1036,11 +1037,11 @@
* @param enc A TBSCertificate in a byte array
* @return a DERObject
*/
- private static DERObject getSubject(byte[] enc) {
+ private static ASN1Primitive getSubject(byte[] enc) {
try {
ASN1InputStream in = new ASN1InputStream(new ByteArrayInputStream(enc));
ASN1Sequence seq = (ASN1Sequence)in.readObject();
- return (DERObject)seq.getObjectAt(seq.getObjectAt(0) instanceof DERTaggedObject ? 5 : 4);
+ return (ASN1Primitive)seq.getObjectAt(seq.getObjectAt(0) instanceof DERTaggedObject ? 5 : 4);
}
catch (IOException e) {
throw new ExceptionConverter(e);
@@ -1340,7 +1341,7 @@
*/
public byte[] getAuthenticatedAttributeBytes(byte secondDigest[], Calendar signingTime, byte[] ocsp) {
try {
- return getAuthenticatedAttributeSet(secondDigest, signingTime, ocsp).getEncoded(ASN1Encodable.DER);
+ return getAuthenticatedAttributeSet(secondDigest, signingTime, ocsp).getEncoded(ASN1Encoding.DER);
}
catch (Exception e) {
throw new ExceptionConverter(e);
@@ -1575,7 +1576,7 @@
vs = new ArrayList();
values.put(id, vs);
}
- vs.add(((DERString)s.getObjectAt(1)).getString());
+ vs.add(((ASN1String)s.getObjectAt(1)).getString());
}
}
}
--- a/core/com/lowagie/text/pdf/PdfPublicKeySecurityHandler.java
+++ b/core/com/lowagie/text/pdf/PdfPublicKeySecurityHandler.java
@@ -108,7 +108,7 @@
import javax.crypto.SecretKey;
import org.bouncycastle.asn1.ASN1InputStream;
-import org.bouncycastle.asn1.DERObject;
+import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.DERObjectIdentifier;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DEROutputStream;
@@ -244,7 +244,7 @@
pkcs7input[22] = two;
pkcs7input[23] = one;
- DERObject obj = createDERForRecipient(pkcs7input, (X509Certificate)certificate);
+ ASN1Primitive obj = createDERForRecipient(pkcs7input, (X509Certificate)certificate);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -276,7 +276,7 @@
return EncodedRecipients;
}
- private DERObject createDERForRecipient(byte[] in, X509Certificate cert)
+ private ASN1Primitive createDERForRecipient(byte[] in, X509Certificate cert)
throws IOException,
GeneralSecurityException
{
@@ -287,7 +287,7 @@
AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters();
ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1"));
ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream);
- DERObject derobject = asn1inputstream.readObject();
+ ASN1Primitive derobject = asn1inputstream.readObject();
KeyGenerator keygenerator = KeyGenerator.getInstance(s);
keygenerator.init(128);
SecretKey secretkey = keygenerator.generateKey();
@@ -300,10 +300,10 @@
AlgorithmIdentifier algorithmidentifier = new AlgorithmIdentifier(new DERObjectIdentifier(s), derobject);
EncryptedContentInfo encryptedcontentinfo =
new EncryptedContentInfo(PKCSObjectIdentifiers.data, algorithmidentifier, deroctetstring);
- EnvelopedData env = new EnvelopedData(null, derset, encryptedcontentinfo, null);
+ EnvelopedData env = new EnvelopedData(null, derset, encryptedcontentinfo, (org.bouncycastle.asn1.ASN1Set) null);
ContentInfo contentinfo =
new ContentInfo(PKCSObjectIdentifiers.envelopedData, env);
- return contentinfo.getDERObject();
+ return contentinfo.toASN1Primitive();
}
private KeyTransRecipientInfo computeRecipientInfo(X509Certificate x509certificate, byte[] abyte0)
|