mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-02-20 17:52:47 +00:00
Add frontend support for --directory option
This commit is contained in:
parent
ef6718af2a
commit
23f2b0a47a
@ -24,11 +24,15 @@ public class Main {
|
||||
System.out.println(commander.toString());
|
||||
String verifyFile = commander.getVerifyFile();
|
||||
String rimel = commander.getRimEventLog();
|
||||
String directory = commander.getDirectoryOverride();
|
||||
String certificateFile = commander.getPublicCertificate();
|
||||
String trustStore = commander.getTruststoreFile();
|
||||
if (!verifyFile.isEmpty()) {
|
||||
if (!rimel.isEmpty()) {
|
||||
validator.setRimEventLog(rimel);
|
||||
}
|
||||
if (!directory.isEmpty()) {
|
||||
|
||||
}
|
||||
if (!trustStore.isEmpty()) {
|
||||
validator.setTrustStoreFile(trustStore);
|
||||
@ -53,6 +57,7 @@ public class Main {
|
||||
boolean embeddedCert = commander.isEmbedded();
|
||||
boolean defaultKey = commander.isDefaultKey();
|
||||
String rimEventLog = commander.getRimEventLog();
|
||||
String directory = commander.getDirectoryOverride();
|
||||
switch (createType) {
|
||||
case "BASE":
|
||||
if (!attributesFile.isEmpty()) {
|
||||
@ -76,11 +81,8 @@ public class Main {
|
||||
"are required, or the default key (-d) must be indicated.");
|
||||
System.exit(1);
|
||||
}
|
||||
if (rimEventLog.isEmpty()) {
|
||||
System.out.println("Error: a support RIM is required!");
|
||||
System.exit(1);
|
||||
} else {
|
||||
gateway.setRimEventLog(rimEventLog);
|
||||
if (!directory.isEmpty()) {
|
||||
|
||||
}
|
||||
List<String> timestampArguments = commander.getTimestampArguments();
|
||||
if (timestampArguments.size() > 0) {
|
||||
|
@ -53,6 +53,9 @@ public class Commander {
|
||||
"Currently only RFC3339 and RFC3852 are supported:\n" +
|
||||
"\tRFC3339 [yyyy-MM-ddThh:mm:ssZ]\n\tRFC3852 <counterSignature.bin>")
|
||||
private List<String> timestampArguments = new ArrayList<String>(2);
|
||||
@Parameter(names = {"--directory"}, validateWith = DirectoryArgumentValidator.class,
|
||||
description = "The directory in which to locate required files.")
|
||||
private String directoryOverride = "";
|
||||
|
||||
public boolean isHelp() {
|
||||
return help;
|
||||
@ -93,6 +96,7 @@ public class Commander {
|
||||
public List<String> getTimestampArguments() {
|
||||
return timestampArguments;
|
||||
}
|
||||
public String getDirectoryOverride() { return directoryOverride; }
|
||||
|
||||
public String printHelpExamples() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@ -139,7 +143,6 @@ public class Commander {
|
||||
} else {
|
||||
sb.append("Signing credential: (none given)" + System.lineSeparator());
|
||||
}
|
||||
sb.append("Event log support RIM: " + this.getRimEventLog() + System.lineSeparator());
|
||||
List<String> timestampArguments = this.getTimestampArguments();
|
||||
if (timestampArguments.size() > 0) {
|
||||
sb.append("Timestamp format: " + timestampArguments.get(0));
|
||||
@ -149,6 +152,8 @@ public class Commander {
|
||||
} else {
|
||||
sb.append("No timestamp included");
|
||||
}
|
||||
sb.append("Override payload directory with: " + this.getDirectoryOverride()
|
||||
+ System.lineSeparator());
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package hirs.swid.utils;
|
||||
|
||||
import com.beust.jcommander.IParameterValidator;
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DirectoryArgumentValidator implements IParameterValidator {
|
||||
public void validate(String name, String value) throws ParameterException {
|
||||
try {
|
||||
File directory = new File(value);
|
||||
if (!directory.isDirectory()) {
|
||||
throw new ParameterException("Invalid directory given, " +
|
||||
"please provide a valid directory path.");
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
throw new ParameterException("Read access denied for " + value +
|
||||
", please verify permissions.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user