From 578b7d1db256d9a582cef45ae5d13d858a977416 Mon Sep 17 00:00:00 2001 From: Yuuta Liang Date: Thu, 26 Oct 2023 05:00:12 +0800 Subject: Add persistence Signed-off-by: Yuuta Liang --- src/main/model/ca/CertificationAuthority.java | 80 ++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 9 deletions(-) (limited to 'src/main/model/ca/CertificationAuthority.java') diff --git a/src/main/model/ca/CertificationAuthority.java b/src/main/model/ca/CertificationAuthority.java index feb557c..038d209 100644 --- a/src/main/model/ca/CertificationAuthority.java +++ b/src/main/model/ca/CertificationAuthority.java @@ -35,6 +35,8 @@ import java.util.stream.Stream; * Holds a CA private key, its certificate, signed / revoked list, template list, and logs list. */ public class CertificationAuthority { + public static final int SERIAL_DEFAULT = 1; + /** * The RSA2048 private key. */ @@ -81,14 +83,45 @@ public class CertificationAuthority { private final String user; /** - * EFFECT: Init with a null key and null certificate, empty signed, revoked template, and log list, serial at 1, and - * user "yuuta". + * EFFECT: Init with the given parameters and user "yuuta". + * Throws {@link NoSuchAlgorithmException} if the key is specified but RSA is not supported. + * Throws {@link InvalidKeySpecException} if the key specified is invalid. + * Throws {@link InvalidCAException} or {@link ParseException} if the CA specified is invalid. + * REQUIRES: n / p / e must be either all null or all non-null containing RSA2048 module and exponents. + * If certificate is non-null, n / p / e must be non-null. + */ + public CertificationAuthority(BigInteger n, BigInteger p, BigInteger e, + Certificate certificate, + List signed, + int serial, + List revoked, + List