mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-31 00:24:00 +00:00
Modify validator class to handle a directory override argument
This commit is contained in:
parent
d46091802c
commit
3722e97f8e
@ -41,7 +41,7 @@ public class Main {
|
||||
if (caValidator.isValid()) {
|
||||
validator.setRimEventLog(rimEventLogFile);
|
||||
if (!directory.isEmpty()) {
|
||||
|
||||
validator.setDirectoryOverride(directory);
|
||||
}
|
||||
validator.setTrustStoreFile(trustStoreFile);
|
||||
validator.validateSwidTag(verifyFile, caValidator.getFormat());
|
||||
|
@ -180,16 +180,15 @@ public class SwidTagGateway {
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for event log support RIM
|
||||
* Setter for rim event log file
|
||||
*
|
||||
* @param rimEventLog
|
||||
*/
|
||||
public void setRimEventLog(final String rimEventLog) {
|
||||
public void setRimEventLog(String rimEventLog) {
|
||||
this.rimEventLog = rimEventLog;
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* Setter for timestamp format in XML signature
|
||||
*
|
||||
* @param timestampFormat
|
||||
@ -208,9 +207,7 @@ public class SwidTagGateway {
|
||||
}
|
||||
|
||||
/**
|
||||
=======
|
||||
>>>>>>> fd32c9fc (Modify gateway class to handle a directory override argument)
|
||||
* Setter for directory path to search for required files
|
||||
p * Setter for directory path to search for required files
|
||||
*
|
||||
* @param directoryOverride
|
||||
*/
|
||||
|
@ -65,10 +65,11 @@ import java.util.List;
|
||||
*/
|
||||
public class SwidTagValidator {
|
||||
private Unmarshaller unmarshaller;
|
||||
private String rimEventLog;
|
||||
private String certificateFile;
|
||||
private String trustStoreFile;
|
||||
private String rimEventLog;
|
||||
private List<X509Certificate> trustStore;
|
||||
private String directoryOverride;
|
||||
|
||||
/**
|
||||
* Ensure that BouncyCastle is configured as a javax.security.Security provider, as this
|
||||
@ -96,13 +97,21 @@ public class SwidTagValidator {
|
||||
this.trustStoreFile = trustStoreFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for directory override path.
|
||||
* @param directoryOverride directory path
|
||||
*/
|
||||
public void setDirectoryOverride(String directoryOverride) {
|
||||
this.directoryOverride = directoryOverride;
|
||||
}
|
||||
|
||||
public SwidTagValidator() {
|
||||
try {
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(SwidTagConstants.SCHEMA_PACKAGE);
|
||||
unmarshaller = jaxbContext.createUnmarshaller();
|
||||
rimEventLog = "";
|
||||
certificateFile = "";
|
||||
trustStoreFile = SwidTagConstants.DEFAULT_KEYSTORE_FILE;
|
||||
directoryOverride = "";
|
||||
} catch (JAXBException e) {
|
||||
System.out.println("Error initializing JAXBContext: " + e.getMessage());
|
||||
}
|
||||
@ -203,7 +212,7 @@ public class SwidTagValidator {
|
||||
* This method validates a hirs.swid.xjc.File from an indirect payload
|
||||
*/
|
||||
private boolean validateFile(Element file) {
|
||||
String filepath = file.getAttribute(SwidTagConstants.NAME);
|
||||
String filepath = directoryOverride + file.getAttribute(SwidTagConstants.NAME);
|
||||
try {
|
||||
if (HashSwid.get256Hash(filepath).equals(
|
||||
file.getAttribute(SwidTagConstants._SHA256_HASH.getPrefix() + ":" +
|
||||
|
@ -113,7 +113,9 @@ public class Commander {
|
||||
return timestampArguments;
|
||||
}
|
||||
|
||||
public String getDirectoryOverride() { return directoryOverride; }
|
||||
public String getDirectoryOverride() {
|
||||
return directoryOverride;
|
||||
}
|
||||
|
||||
public String printHelpExamples() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@ -162,6 +164,8 @@ public class Commander {
|
||||
+ System.lineSeparator());
|
||||
sb.append("Embedded certificate: " + this.isEmbedded() + System.lineSeparator());
|
||||
}
|
||||
sb.append("Override payload directory with: " + this.getDirectoryOverride()
|
||||
+ System.lineSeparator());
|
||||
List<String> timestampArguments = this.getTimestampArguments();
|
||||
if (timestampArguments.size() > 0) {
|
||||
sb.append("Timestamp format: " + timestampArguments.get(0));
|
||||
@ -169,10 +173,8 @@ public class Commander {
|
||||
sb.append(", " + timestampArguments.get(1));
|
||||
}
|
||||
} else {
|
||||
sb.append("No timestamp included");
|
||||
sb.append("No timestamp included" + System.lineSeparator());
|
||||
}
|
||||
sb.append("Override payload directory with: " + this.getDirectoryOverride()
|
||||
+ System.lineSeparator());
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ public class DirectoryArgumentValidator implements IParameterValidator {
|
||||
try {
|
||||
File directory = new File(value);
|
||||
if (!directory.isDirectory()) {
|
||||
throw new ParameterException("Invalid directory given, " +
|
||||
"please provide a valid directory path.");
|
||||
throw new ParameterException("Invalid directory given: " + value +
|
||||
". Please provide a valid directory path.");
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
throw new ParameterException("Read access denied for " + value +
|
||||
|
Loading…
x
Reference in New Issue
Block a user