aboutsummaryrefslogtreecommitdiff
path: root/src/main/ui/MainScreen.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/ui/MainScreen.java')
-rw-r--r--src/main/ui/MainScreen.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/ui/MainScreen.java b/src/main/ui/MainScreen.java
index 4d77022..b6e4372 100644
--- a/src/main/ui/MainScreen.java
+++ b/src/main/ui/MainScreen.java
@@ -18,6 +18,9 @@ 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;
@@ -28,6 +31,9 @@ public class MainScreen implements UIHandler {
this.session = session;
}
+ /**
+ * EFFECTS: Print help
+ */
@Override
public void help() {
System.out.print("mgmt\tView and manage the CA certificate\n"
@@ -42,6 +48,9 @@ public class MainScreen implements UIHandler {
+ "help\tPrint this message\n");
}
+ /**
+ * EFFECTS: Print each issued cert in Subject Serial Status format.
+ */
@Override
public void show() {
session.getCa().getSigned().forEach(cert -> {
@@ -53,6 +62,9 @@ public class MainScreen implements UIHandler {
});
}
+ /**
+ * EFFECTS: Read the input CSR.
+ */
private CertificationRequest handleIssueInputCSR() {
try {
return new CertificationRequest(new BytesReader(session.handleInputPEM("CERTIFICATE REQUEST")),
@@ -63,6 +75,9 @@ public class MainScreen implements UIHandler {
}
}
+ /**
+ * EFFECTS: Handle the issue command. Read CSR, find template, switch to issue screen.
+ */
private void handleIssue(String... args) {
if (!session.checkCA(true)) {
return;
@@ -104,6 +119,10 @@ public class MainScreen implements UIHandler {
return c.get();
}
+ /**
+ * EFFECTS: Handle the revoke command and log it.
+ * MODIFIES: session
+ */
private void handleRevoke(String... args) {
if (args.length < 3) {
System.out.println("Usage: revoke <serial> <reason>");
@@ -125,6 +144,9 @@ public class MainScreen implements UIHandler {
}
}
+ /**
+ * EFFECTS: Export a cert to file
+ */
private void handleExport(String... args) {
if (args.length < 3) {
System.out.println("Usage: export <serial> <path>");
@@ -147,6 +169,10 @@ public class MainScreen implements UIHandler {
}
}
+ /**
+ * EFFECTS: Issue a CRL and do audit log.
+ * MODIFIES: session
+ */
private void handleCRL() {
if (!session.checkCA(true)) {
return;
@@ -159,6 +185,9 @@ public class MainScreen implements UIHandler {
}
}
+ /**
+ * EFFECTS: Handle commands
+ */
@Override
public void command(String... args) {
switch (args[0]) {
@@ -184,11 +213,17 @@ public class MainScreen implements UIHandler {
help();
}
+ /**
+ * EFFECTS: Exit the program
+ */
@Override
public Screen exit() {
return null;
}
+ /**
+ * EFFECTS: return "/ %"
+ */
@Override
public String getPS1() {
return "/ %";