From 1073af21305360bd33903c533cdac57e9f936294 Mon Sep 17 00:00:00 2001 From: Yuuta Liang Date: Tue, 28 Nov 2023 18:19:39 -0800 Subject: Move TUI and GUI into separate packages Signed-off-by: Yuuta Liang --- src/main/ui/MainScreen.java | 233 -------------------------------------------- 1 file changed, 233 deletions(-) delete mode 100644 src/main/ui/MainScreen.java (limited to 'src/main/ui/MainScreen.java') diff --git a/src/main/ui/MainScreen.java b/src/main/ui/MainScreen.java deleted file mode 100644 index 8a85881..0000000 --- a/src/main/ui/MainScreen.java +++ /dev/null @@ -1,233 +0,0 @@ -package ui; - -import model.asn1.ASN1Object; -import model.asn1.UtcTime; -import model.asn1.exceptions.ParseException; -import model.asn1.parsing.BytesReader; -import model.ca.Template; -import model.csr.CertificationRequest; -import model.pki.cert.Certificate; -import model.pki.crl.CertificateList; -import model.pki.crl.Reason; -import model.pki.crl.RevokedCertificate; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.util.Optional; - -/** - * The main screen that handles submenus (mgmt / issue / template), list certs, revoke certs, generate CRLs. - */ -public class MainScreen implements UIHandler { - private final JCA session; - - /** - * EFFECTS: Init with the parent session. - */ - public MainScreen(JCA session) { - this.session = session; - } - - /** - * EFFECTS: Print help - */ - @Override - public void help() { - System.out.print("mgmt\tView and manage the CA certificate\n" - + "issue\tIssue a certificate\n" - + "show\tList all issued certificates\n" - + "export\tExport a certificate to file (DER)\n" - + "template\tManage templates\n" - + "revoke\tRevoke a certificate\n" - + "crl\t\tSign CRL\n" - + "log\t\tView audit logs\n" - + "exit\tExit\n" - + "help\tPrint this message\n"); - } - - /** - * EFFECTS: Print each issued cert in Subject Serial Status format. - */ - @Override - public void show() { - session.getCa().getSigned().forEach(cert -> { - System.out.printf("%s\t%d\t%s\n", - cert.getCertificate().getSubject().toString(), - cert.getCertificate().getSerialNumber().getLong(), - session.getCa().getRevoked().stream().anyMatch(rev -> rev.getSerialNumber().getLong() - == cert.getCertificate().getSerialNumber().getLong()) ? "REVOKED" : "OK"); - }); - } - - /** - * EFFECTS: Read the input CSR. - */ - private CertificationRequest handleIssueInputCSR() { - try { - return new CertificationRequest(new BytesReader(session.handleInputPEM("CERTIFICATE REQUEST")), - false); - } catch (ParseException e) { - System.out.println(e.getMessage()); - return null; - } - } - - /** - * EFFECTS: Handle the issue command. Read CSR, find template, switch to issue screen. - */ - private void handleIssue(String... args) { - if (!session.checkCA(true)) { - return; - } - if (args.length <= 1) { - System.out.println("Usage: issue