aboutsummaryrefslogtreecommitdiff
path: root/src/main/model/ca
diff options
context:
space:
mode:
authorYuuta Liang <yuutaw@students.cs.ubc.ca>2023-10-14 05:35:17 +0800
committerYuuta Liang <yuutaw@students.cs.ubc.ca>2023-10-14 05:35:17 +0800
commit28fa18278c1f3a87722d5e8b78f581526a30bb38 (patch)
tree2f23f6e2e222a78f40809ec37e8b28a29cba3d3c /src/main/model/ca
parent0bcc057e741af3fbc108f42b75f9d42f48f6a51e (diff)
downloadjca-28fa18278c1f3a87722d5e8b78f581526a30bb38.tar
jca-28fa18278c1f3a87722d5e8b78f581526a30bb38.tar.gz
jca-28fa18278c1f3a87722d5e8b78f581526a30bb38.tar.bz2
jca-28fa18278c1f3a87722d5e8b78f581526a30bb38.zip
Fix lint
Signed-off-by: Yuuta Liang <yuutaw@students.cs.ubc.ca>
Diffstat (limited to 'src/main/model/ca')
-rw-r--r--src/main/model/ca/CACertificate.java54
-rw-r--r--src/main/model/ca/Template.java9
2 files changed, 32 insertions, 31 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);
}
/**
diff --git a/src/main/model/ca/Template.java b/src/main/model/ca/Template.java
index ff2510e..af751dc 100644
--- a/src/main/model/ca/Template.java
+++ b/src/main/model/ca/Template.java
@@ -1,14 +1,13 @@
package model.ca;
-import model.asn1.*;
+import model.asn1.ASN1Object;
+import model.asn1.ObjectIdentifier;
+import model.asn1.PrintableString;
import model.asn1.exceptions.ParseException;
-import model.pki.cert.TbsCertificate;
import model.x501.AttributeTypeAndValue;
import model.x501.Name;
import model.x501.RelativeDistinguishedName;
-import java.util.List;
-
/**
* Represents a certificate template. Certificate templates are like policies the define part of the issued certificates
* of what to have in common.
@@ -74,7 +73,7 @@ public class Template {
/**
* EFFECTS: Set the subject to CN=commonName,C=CA
- * Throws {@link ParseException} if commonName is not a valid PrintableString
+ * Throws {@link ParseException} if commonName is not a valid PrintableString
*/
public void setSubject(String commonName) throws ParseException {
if (commonName == null) {