mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-31 00:24:00 +00:00
Modify gateway class to handle a directory override argument
This commit is contained in:
parent
23f2b0a47a
commit
cb9b93a47a
@ -80,9 +80,6 @@ public class Main {
|
||||
System.out.println("A private key (-k) and public certificate (-p) " +
|
||||
"are required, or the default key (-d) must be indicated.");
|
||||
System.exit(1);
|
||||
}
|
||||
if (!directory.isEmpty()) {
|
||||
|
||||
}
|
||||
List<String> timestampArguments = commander.getTimestampArguments();
|
||||
if (timestampArguments.size() > 0) {
|
||||
@ -95,6 +92,7 @@ public class Main {
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
gateway.setDirectoryOverride(directory);
|
||||
gateway.generateSwidTag(commander.getOutFile());
|
||||
break;
|
||||
default:
|
||||
|
@ -93,6 +93,7 @@ public class SwidTagGateway {
|
||||
private String rimEventLog;
|
||||
private String timestampFormat;
|
||||
private String timestampArgument;
|
||||
private String directoryOverride;
|
||||
private String errorRequiredFields;
|
||||
|
||||
/**
|
||||
@ -109,6 +110,7 @@ public class SwidTagGateway {
|
||||
rimEventLog = "";
|
||||
timestampFormat = "";
|
||||
timestampArgument = "";
|
||||
directoryOverride = "";
|
||||
errorRequiredFields = "";
|
||||
} catch (JAXBException e) {
|
||||
System.out.println("Error initializing jaxbcontext: " + e.getMessage());
|
||||
@ -195,6 +197,15 @@ public class SwidTagGateway {
|
||||
this.timestampArgument = timestampArgument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for directory path to search for required files
|
||||
*
|
||||
* @param directoryOverride
|
||||
*/
|
||||
public void setDirectoryOverride(String directoryOverride) {
|
||||
this.directoryOverride = directoryOverride;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method generates a base RIM from the values in a JSON file.
|
||||
*
|
||||
@ -524,7 +535,7 @@ public class SwidTagGateway {
|
||||
jsonObject.getString(SwidTagConstants.SUPPORT_RIM_TYPE, ""));
|
||||
addNonNullAttribute(attributes, SwidTagConstants._SUPPORT_RIM_URI_GLOBAL,
|
||||
jsonObject.getString(SwidTagConstants.SUPPORT_RIM_URI_GLOBAL, ""));
|
||||
String filepath = jsonObject.getString(SwidTagConstants.NAME);
|
||||
String filepath = directoryOverride + jsonObject.getString(SwidTagConstants.NAME);
|
||||
File fileToAdd = new File(filepath);
|
||||
file.setName(filepath);
|
||||
file.setSize(new BigInteger(Long.toString(fileToAdd.length())));
|
||||
|
@ -5,6 +5,11 @@ import com.beust.jcommander.ParameterException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* This class validates a directory argument. If the directory is neither valid nor
|
||||
* read-accessible then an error is thrown.
|
||||
*/
|
||||
|
||||
public class DirectoryArgumentValidator implements IParameterValidator {
|
||||
public void validate(String name, String value) throws ParameterException {
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user