diff options
-rw-r--r-- | README.md | 13 | ||||
-rw-r--r-- | src/main/model/ca/CertificationAuthority.java | 3 | ||||
-rw-r--r-- | src/main/ui/Main.java | 23 |
3 files changed, 39 insertions, 0 deletions
@@ -88,6 +88,19 @@ container, upon each successful sign. The CA public key will also be rendered as a QR code on the "CA" tab, for easier transfer between computers. The encoded data is PEM-encoded PKCS#1 public key. +## Phase 4: Task 2 + +``` +Tue Nov 28 11:51:46 PST 2023 - yuuta: Generated CA private key. +Tue Nov 28 11:51:50 PST 2023 - yuuta: Signed CA csr +Tue Nov 28 11:52:12 PST 2023 - yuuta: CA certificate is installed. +Tue Nov 28 11:52:38 PST 2023 - yuuta: Added a new template: TLS Server +Tue Nov 28 11:52:43 PST 2023 - yuuta: Template TLS Server has been enabled +Tue Nov 28 11:52:50 PST 2023 - yuuta: Signed a cert with serial number 1 +Tue Nov 28 11:53:01 PST 2023 - yuuta: Certificate 1 is revoked with reason KEY_COMPROMISE at 2023-11-28T19:52:57.124440191 +Tue Nov 28 11:53:06 PST 2023 - yuuta: Signed CRL with 1 revoked certs. +``` + ## Author Yuuta Liang <yuutaw@student.ubc.ca> diff --git a/src/main/model/ca/CertificationAuthority.java b/src/main/model/ca/CertificationAuthority.java index 5181f1a..b118637 100644 --- a/src/main/model/ca/CertificationAuthority.java +++ b/src/main/model/ca/CertificationAuthority.java @@ -1,5 +1,7 @@ package model.ca; +import model.Event; +import model.EventLog; import model.Observer; import model.asn1.*; import model.asn1.exceptions.InvalidCAException; @@ -473,6 +475,7 @@ public class CertificationAuthority { final AuditLogEntry i = new AuditLogEntry(user, ZonedDateTime.now(), message); this.logs.add(i); notif(i, Observer.DIRECTION_ADD, logs.size() - 1); + EventLog.getInstance().logEvent(new Event(user + ": " + message)); } /** diff --git a/src/main/ui/Main.java b/src/main/ui/Main.java index ab275c1..4dbcea1 100644 --- a/src/main/ui/Main.java +++ b/src/main/ui/Main.java @@ -1,18 +1,41 @@ package ui; import com.formdev.flatlaf.FlatIntelliJLaf; +import model.EventLog; import javax.swing.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.Spliterator; +import java.util.Spliterators; +import java.util.stream.StreamSupport; public class Main { public static void main(String[] args) throws Throwable { if (args.length >= 1 && args[0].equals("-c")) { new JCA().run(); + printLogs(); } else { FlatIntelliJLaf.setup(); final JFrame frame = new MainUI(); frame.pack(); + frame.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + printLogs(); + } + }); frame.setVisible(true); } } + + /** + * EFFECTS: Print logs to stdout, separated by LF, in the format of "date - descr". + */ + private static void printLogs() { + StreamSupport.stream(Spliterators.spliteratorUnknownSize(EventLog.getInstance().iterator(), + Spliterator.ORDERED), false) + .map(e -> String.format("%s - %s", e.getDate(), e.getDescription())) + .forEach(System.out::println); + } } |