Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hook <dgh@cryptoworkshop.com>2014-07-22 14:59:42 +0400
committerDavid Hook <dgh@cryptoworkshop.com>2014-07-22 14:59:42 +0400
commit054947daabc9c3a2354f80fbc955a572df2f9003 (patch)
tree0b955b1afb430a7c75f42958a10042bcc8a29d04 /pkix/src/main
parentd9a8181bf89386342fe16a34d800c75c5dddafa9 (diff)
J2ME compatibility updates
Diffstat (limited to 'pkix/src/main')
-rw-r--r--pkix/src/main/java/org/bouncycastle/cert/X509v1CertificateBuilder.java67
-rw-r--r--pkix/src/main/java/org/bouncycastle/cms/DefaultAuthenticatedAttributeTableGenerator.java10
2 files changed, 60 insertions, 17 deletions
diff --git a/pkix/src/main/java/org/bouncycastle/cert/X509v1CertificateBuilder.java b/pkix/src/main/java/org/bouncycastle/cert/X509v1CertificateBuilder.java
index 4a4e150f..3652ba9e 100644
--- a/pkix/src/main/java/org/bouncycastle/cert/X509v1CertificateBuilder.java
+++ b/pkix/src/main/java/org/bouncycastle/cert/X509v1CertificateBuilder.java
@@ -2,12 +2,15 @@ package org.bouncycastle.cert;
import java.math.BigInteger;
import java.util.Date;
+import java.util.Locale;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.x500.X500Name;
+import org.bouncycastle.asn1.x509.ExtensionsGenerator;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.asn1.x509.Time;
import org.bouncycastle.asn1.x509.V1TBSCertificateGenerator;
+import org.bouncycastle.asn1.x509.V3TBSCertificateGenerator;
import org.bouncycastle.operator.ContentSigner;
@@ -30,24 +33,56 @@ public class X509v1CertificateBuilder
*/
public X509v1CertificateBuilder(X500Name issuer, BigInteger serial, Date notBefore, Date notAfter, X500Name subject, SubjectPublicKeyInfo publicKeyInfo)
{
- if (issuer == null)
- {
- throw new IllegalArgumentException("issuer must not be null");
- }
+ this(issuer, serial, new Time(notBefore), new Time(notAfter), subject, publicKeyInfo);
+ }
- if (publicKeyInfo == null)
- {
- throw new IllegalArgumentException("publicKeyInfo must not be null");
- }
+ /**
+ * Create a builder for a version 1 certificate. You may need to use this constructor if the default locale
+ * doesn't use a Gregorian calender so that the Time produced is compatible with other ASN.1 implementations.
+ *
+ * @param issuer the certificate issuer
+ * @param serial the certificate serial number
+ * @param notBefore the date before which the certificate is not valid
+ * @param notAfter the date after which the certificate is not valid
+ * @param dateLocale locale to be used for date interpretation.
+ * @param subject the certificate subject
+ * @param publicKeyInfo the info structure for the public key to be associated with this certificate.
+ */
+ public X509v1CertificateBuilder(X500Name issuer, BigInteger serial, Date notBefore, Date notAfter, Locale dateLocale, X500Name subject, SubjectPublicKeyInfo publicKeyInfo)
+ {
+ this(issuer, serial, new Time(notBefore, dateLocale), new Time(notAfter, dateLocale), subject, publicKeyInfo);
+ }
- tbsGen = new V1TBSCertificateGenerator();
- tbsGen.setSerialNumber(new ASN1Integer(serial));
- tbsGen.setIssuer(issuer);
- tbsGen.setStartDate(new Time(notBefore));
- tbsGen.setEndDate(new Time(notAfter));
- tbsGen.setSubject(subject);
- tbsGen.setSubjectPublicKeyInfo(publicKeyInfo);
- }
+ /**
+ * Create a builder for a version 1 certificate.
+ *
+ * @param issuer the certificate issuer
+ * @param serial the certificate serial number
+ * @param notBefore the Time before which the certificate is not valid
+ * @param notAfter the Time after which the certificate is not valid
+ * @param subject the certificate subject
+ * @param publicKeyInfo the info structure for the public key to be associated with this certificate.
+ */
+ public X509v1CertificateBuilder(X500Name issuer, BigInteger serial, Time notBefore, Time notAfter, X500Name subject, SubjectPublicKeyInfo publicKeyInfo)
+ {
+ if (issuer == null)
+ {
+ throw new IllegalArgumentException("issuer must not be null");
+ }
+
+ if (publicKeyInfo == null)
+ {
+ throw new IllegalArgumentException("publicKeyInfo must not be null");
+ }
+
+ tbsGen = new V1TBSCertificateGenerator();
+ tbsGen.setSerialNumber(new ASN1Integer(serial));
+ tbsGen.setIssuer(issuer);
+ tbsGen.setStartDate(notBefore);
+ tbsGen.setEndDate(notAfter);
+ tbsGen.setSubject(subject);
+ tbsGen.setSubjectPublicKeyInfo(publicKeyInfo);
+ }
/**
* Generate an X509 certificate, based on the current issuer and subject
diff --git a/pkix/src/main/java/org/bouncycastle/cms/DefaultAuthenticatedAttributeTableGenerator.java b/pkix/src/main/java/org/bouncycastle/cms/DefaultAuthenticatedAttributeTableGenerator.java
index 66b61d12..fb37b4d8 100644
--- a/pkix/src/main/java/org/bouncycastle/cms/DefaultAuthenticatedAttributeTableGenerator.java
+++ b/pkix/src/main/java/org/bouncycastle/cms/DefaultAuthenticatedAttributeTableGenerator.java
@@ -1,5 +1,6 @@
package org.bouncycastle.cms;
+import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Map;
@@ -57,7 +58,14 @@ public class DefaultAuthenticatedAttributeTableGenerator
protected Hashtable createStandardAttributeTable(
Map parameters)
{
- Hashtable std = (Hashtable)table.clone();
+ Hashtable std = new Hashtable();
+
+ for (Enumeration en = table.keys(); en.hasMoreElements();)
+ {
+ Object key = en.nextElement();
+
+ std.put(key, table.get(key));
+ }
if (!std.containsKey(CMSAttributes.contentType))
{