Modify Main and Commander classes to support options for RFC3161 and RFC3339

This commit is contained in:
chubtub 2022-09-20 00:19:01 -04:00
parent 1fccd3a222
commit 97ccab0473
3 changed files with 32 additions and 0 deletions

View File

@ -81,6 +81,11 @@ public class Main {
} else {
gateway.setRimEventLog(rimEventLog);
}
if (commander.isRfc3161()) {
gateway.setTimestampFormat("RFC3161");
} else {
gateway.setTimestampFormat("RFC3339");
}
gateway.generateSwidTag(commander.getOutFile());
break;
default:

View File

@ -86,6 +86,7 @@ public class SwidTagGateway {
private String pemCertificateFile;
private boolean embeddedCert;
private String rimEventLog;
private String timestampFormat;
private String errorRequiredFields;
/**
@ -100,6 +101,7 @@ public class SwidTagGateway {
pemCertificateFile = "";
embeddedCert = false;
rimEventLog = "";
timestampFormat = "";
errorRequiredFields = "";
} catch (JAXBException e) {
System.out.println("Error initializing jaxbcontext: " + e.getMessage());
@ -170,6 +172,14 @@ public class SwidTagGateway {
this.rimEventLog = rimEventLog;
}
/**
* Setter for timestamp format in XML signature
* @param timestampFormat
*/
public void setTimestampFormat(String timestampFormat) {
this.timestampFormat = timestampFormat;
}
/**
* This method generates a base RIM from the values in a JSON file.
*

View File

@ -45,6 +45,12 @@ public class Commander {
@Parameter(names = {"-l", "--rimel <path>"}, order = 9,
description = "The TCG eventlog file to use as a support RIM.")
private String rimEventLog = "";
@Parameter(names = {"--rfc3161"}, order = 10,
description = "Add a timestamp to the signature that is compliant with RFC3161.")
private boolean rfc3161 = false;
@Parameter(names = {"--rfc3339"}, order = 11,
description = "Add a timestamp to the signature that is compliant with RFC3339.")
private boolean rfc3339 = false;
public boolean isHelp() {
return help;
@ -82,6 +88,10 @@ public class Commander {
public String getRimEventLog() { return rimEventLog; }
public boolean isRfc3161() { return rfc3161; }
public boolean isRfc3339() { return rfc3339; }
public String printHelpExamples() {
StringBuilder sb = new StringBuilder();
sb.append("Create a base RIM using the values in attributes.json; " +
@ -123,6 +133,13 @@ public class Commander {
sb.append("Signing credential: (none given)" + System.lineSeparator());
}
sb.append("Event log support RIM: " + this.getRimEventLog() + System.lineSeparator());
if (isRfc3161()) {
sb.append("Timestamp format: RFC3161");
} else if (isRfc3339()) {
sb.append("Timestamp format: RFC3339");
} else {
sb.append("Timestamp format: defaulting to RFC3339");
}
return sb.toString();
}
}