Add default keystore in case of no input

This commit is contained in:
chubtub 2020-11-10 08:04:41 -05:00
parent d35aaac41d
commit 43208332ae
3 changed files with 20 additions and 7 deletions

View File

@ -63,6 +63,9 @@ public class Main {
gateway.setDefaultCredentials(false);
gateway.setPemCertificateFile(certificateFile);
gateway.setPemPrivateKeyFile(privateKeyFile);
} else {
gateway.setDefaultCredentials(true);
gateway.setJksKeystoreFile(SwidTagConstants.DEFAULT_KEYSTORE_FILE);
}
if (rimEventLog.isEmpty()) {
System.out.println("Error: a support RIM is required!");

View File

@ -12,6 +12,7 @@ import javax.xml.namespace.QName;
*/
public class SwidTagConstants {
public static final String DEFAULT_KEYSTORE_FILE = "/opt/hirs/rimtool/keystore.jks";
public static final String DEFAULT_KEYSTORE_PASSWORD = "password";
public static final String DEFAULT_PRIVATE_KEY_ALIAS = "selfsigned";
public static final String DEFAULT_ATTRIBUTES_FILE = "rim_fields.json";

View File

@ -7,6 +7,7 @@ import java.nio.file.InvalidPathException;
import java.nio.file.Paths;
import com.beust.jcommander.Parameter;
import hirs.swid.SwidTagConstants;
/**
* Commander is a class that handles the command line arguments for the SWID
@ -115,13 +116,21 @@ public class Commander {
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Creating: " + getCreateType() + System.lineSeparator());
sb.append("Using attributes file: " + getAttributesFile() + System.lineSeparator());
sb.append("Write to: " + getOutFile() + System.lineSeparator());
sb.append("Verify file: " + getVerifyFile() + System.lineSeparator());
sb.append("Private key file: " + getPrivateKeyFile() + System.lineSeparator());
sb.append("Public certificate: " + getPublicCertificate() + System.lineSeparator());
sb.append("Event log support RIM: " + getRimEventLog() + System.lineSeparator());
sb.append("Creating: " + this.getCreateType() + System.lineSeparator());
sb.append("Using attributes file: " + this.getAttributesFile() + System.lineSeparator());
sb.append("Write to: " + this.getOutFile() + System.lineSeparator());
sb.append("Verify file: " + this.getVerifyFile() + System.lineSeparator());
if (!this.getKeystoreFile().isEmpty()) {
sb.append("Keystore file: " + this.getKeystoreFile() + System.lineSeparator());
} else if (!this.getPrivateKeyFile().isEmpty() &&
!this.getPublicCertificate().isEmpty()) {
sb.append("Private key file: " + this.getPrivateKeyFile() + System.lineSeparator());
sb.append("Public certificate: " + this.getPublicCertificate() + System.lineSeparator());
} else {
sb.append("Keystore file: default (" + SwidTagConstants.DEFAULT_KEYSTORE_FILE + ")"
+ System.lineSeparator());
}
sb.append("Event log support RIM: " + this.getRimEventLog() + System.lineSeparator());
/*
sb.append("TPM PCRs support RIM: " + getRimPcrs() + System.lineSeparator());
sb.append("Base RIM to be signed: " + getToBeSigned() + System.lineSeparator());