mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-03-11 06:54:14 +00:00
Add frontend support for --directory option
This commit is contained in:
parent
1b1cbb6f8e
commit
32edd6ce48
@ -23,11 +23,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);
|
||||
@ -52,6 +56,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()) {
|
||||
@ -75,11 +80,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()) {
|
||||
|
||||
}
|
||||
gateway.generateSwidTag(commander.getOutFile());
|
||||
break;
|
||||
|
@ -45,6 +45,9 @@ 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 = {"--directory"}, validateWith = DirectoryArgumentValidator.class,
|
||||
description = "The directory in which to locate required files.")
|
||||
private String directoryOverride = "";
|
||||
|
||||
public boolean isHelp() {
|
||||
return help;
|
||||
@ -82,6 +85,8 @@ public class Commander {
|
||||
|
||||
public String getRimEventLog() { return rimEventLog; }
|
||||
|
||||
public String getDirectoryOverride() { return directoryOverride; }
|
||||
|
||||
public String printHelpExamples() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Create a base RIM using the values in attributes.json; " +
|
||||
@ -122,7 +127,8 @@ public class Commander {
|
||||
} else {
|
||||
sb.append("Signing credential: (none given)" + System.lineSeparator());
|
||||
}
|
||||
sb.append("Event log support RIM: " + this.getRimEventLog() + System.lineSeparator());
|
||||
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