aboutsummaryrefslogtreecommitdiff
path: root/src/main/model/ca/CACertificate.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/model/ca/CACertificate.java')
-rw-r--r--src/main/model/ca/CACertificate.java54
1 files changed, 28 insertions, 26 deletions
diff --git a/src/main/model/ca/CACertificate.java b/src/main/model/ca/CACertificate.java
index 36a9ac5..1bd53c9 100644
--- a/src/main/model/ca/CACertificate.java
+++ b/src/main/model/ca/CACertificate.java
@@ -5,8 +5,9 @@ import model.asn1.exceptions.ParseException;
import model.csr.*;
import model.pki.AlgorithmIdentifier;
import model.pki.SubjectPublicKeyInfo;
-import model.pki.cert.*;
import model.pki.cert.Certificate;
+import model.pki.cert.TbsCertificate;
+import model.pki.cert.Validity;
import model.pki.crl.CertificateList;
import model.pki.crl.CertificateListContent;
import model.pki.crl.RevokedCertificate;
@@ -17,12 +18,13 @@ import ui.Utils;
import java.math.BigInteger;
import java.security.*;
-import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
-import java.security.spec.RSAPrivateKeySpec;
import java.time.ZoneId;
import java.time.ZonedDateTime;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
import java.util.stream.Stream;
/**
@@ -57,7 +59,7 @@ public class CACertificate {
/**
* EFFECT: Init with a null key and null certificate, empty signed and revoked list, and serial at 1.
*/
- public CACertificate() {
+ public CACertificate() {
this.key = null;
this.certificate = null;
this.serial = 1;
@@ -79,11 +81,11 @@ public class CACertificate {
* EFFECT: Install the CA certificate.
* MODIFIES: this
* REQUIRES:
- * - The new certificate must have the same algorithm and public key as getPublicKey(), except for testing purpose
- * - It must be a v3 certificate
- * - It must have basicConstraints { cA = TRUE }
- * - It must contain key usage Digital Signature, Certificate Sign, CRL Sign
- * - getCertificate() must be null (i.e., no certificate is installed yet).
+ * - The new certificate must have the same algorithm and public key as getPublicKey(), except for testing purpose
+ * - It must be a v3 certificate
+ * - It must have basicConstraints { cA = TRUE }
+ * - It must contain key usage Digital Signature, Certificate Sign, CRL Sign
+ * - getCertificate() must be null (i.e., no certificate is installed yet).
*/
public void installCertificate(Certificate certificate) {
this.certificate = certificate;
@@ -109,7 +111,7 @@ public class CACertificate {
new Attribute[]{
new Attribute(ASN1Object.TAG_SEQUENCE, null,
new ObjectIdentifier(ObjectIdentifier.TAG, null,
- new Integer[]{ 1, 3, 6, 1, 4, 1, 311, 13, 2, 3 }),
+ new Integer[]{1, 3, 6, 1, 4, 1, 311, 13, 2, 3}),
new Values(ASN1Object.TAG_SET, null,
new ASN1Object[]{
new IA5String(IA5String.TAG, null,
@@ -200,26 +202,26 @@ public class CACertificate {
/**
* EFFECTS: Apply the template.
* For the new certificate:
- * - Issuer will be set to CA#getCertificate()#getSubject()
- * - The template will be applied (subject, validity, cdp)
- * - A serial number will be generated
+ * - Issuer will be set to CA#getCertificate()#getSubject()
+ * - The template will be applied (subject, validity, cdp)
+ * - A serial number will be generated
*/
private TbsCertificate generateCert(CertificationRequestInfo req, Template template) {
final ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
return new TbsCertificate(ASN1Object.TAG_SEQUENCE, null,
- new Int(Int.TAG, new Tag(TagClass.CONTEXT_SPECIFIC, true, 0),
- TbsCertificate.VERSION_V3),
- new Int(Int.TAG, null, serial++),
- getSigningAlgorithm(),
- certificate.getCertificate().getSubject(),
- new Validity(ASN1Object.TAG_SEQUENCE, null,
- new GeneralizedTime(GeneralizedTime.TAG, null, now),
- new UtcTime(UtcTime.TAG, null,
- now.plusDays(template.getValidity()))),
- template.getSubject() == null ? req.getSubject() :
+ new Int(Int.TAG, new Tag(TagClass.CONTEXT_SPECIFIC, true, 0),
+ TbsCertificate.VERSION_V3),
+ new Int(Int.TAG, null, serial++),
+ getSigningAlgorithm(),
+ certificate.getCertificate().getSubject(),
+ new Validity(ASN1Object.TAG_SEQUENCE, null,
+ new GeneralizedTime(GeneralizedTime.TAG, null, now),
+ new UtcTime(UtcTime.TAG, null,
+ now.plusDays(template.getValidity()))),
+ template.getSubject() == null ? req.getSubject() :
template.getSubject(),
- req.getSubjectPKInfo(),
- null);
+ req.getSubjectPKInfo(),
+ null);
}
/**