Checkstyle changes to SwidTagConstants class

This commit is contained in:
chubtub 2025-02-24 18:36:29 -05:00
parent 9f1fbc942a
commit 612a819fad
2 changed files with 62 additions and 67 deletions
tools/tcg_rim_tool/src/main/java/hirs/swid

@ -9,8 +9,7 @@ import javax.xml.namespace.QName;
* class. It is expected that member properties of this class will expand as
* more functionality is added to SwidTagGateway.
*/
public class SwidTagConstants {
public final class SwidTagConstants {
public static final String INSTALLATION_DIRECTORY = "/opt/rimtool";
public static final String VERSION_FILE = INSTALLATION_DIRECTORY + "/VERSION";
public static final String DEFAULT_KEYSTORE_FILE =
@ -20,15 +19,12 @@ public class SwidTagConstants {
public static final String DEFAULT_ATTRIBUTES_FILE =
INSTALLATION_DIRECTORY + "/data/rim_fields.json";
public static final String DEFAULT_ENGLISH = "en";
public static final String SIGNATURE_ALGORITHM_RSA_SHA256 =
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";
public static final String SCHEMA_PACKAGE = "hirs.utils.xjc";
public static final String SCHEMA_LANGUAGE = XMLConstants.W3C_XML_SCHEMA_NS_URI;
public static final String SCHEMA_URL = "swid_schema.xsd";
public static final String SWIDTAG_NAMESPACE = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd";
public static final String SOFTWARE_IDENTITY = "SoftwareIdentity";
public static final String ENTITY = "Entity";
public static final String LINK = "Link";
@ -77,67 +73,66 @@ public class SwidTagConstants {
public static final String SUPPORT_RIM_FORMAT_MISSING = "supportRIMFormat missing";
public static final String SUPPORT_RIM_URI_GLOBAL = "supportRIMURIGlobal";
public static final String DATETIME = "dateTime";
public static final String NIST_NS = "http://csrc.nist.gov/ns/swid/2015-extensions/1.0";
public static final String TCG_NS = "https://trustedcomputinggroup.org/wp-content/uploads/TCG_RIM_Model";
public static final String RFC3852_NS = "https://www.ietf.org/rfc/rfc3852.txt";
public static final String RFC3339_NS = "https://www.ietf.org/rfc/rfc3339.txt";
public static final String N8060_PFX = "n8060";
public static final String RIM_PFX = "rim";
public static final String RFC3852_PFX = "rcf3852";
public static final String RFC3339_PFX = "rcf3339";
public static final QName _SHA256_HASH = new QName(
public static final QName SHA256_HASH = new QName(
"http://www.w3.org/2001/04/xmlenc#sha256", HASH, "SHA256");
public static final QName _COLLOQUIAL_VERSION = new QName(
public static final QName N8060_COLLOQUIAL_VERSION = new QName(
NIST_NS, COLLOQUIAL_VERSION, N8060_PFX);
public static final QName _EDITION = new QName(
public static final QName N8060_EDITION = new QName(
NIST_NS, EDITION, N8060_PFX);
public static final QName _PRODUCT = new QName(
public static final QName N8060_PRODUCT = new QName(
NIST_NS, PRODUCT, N8060_PFX);
public static final QName _REVISION = new QName(
public static final QName N8060_REVISION = new QName(
NIST_NS, REVISION, N8060_PFX);
public static final QName _PAYLOAD_TYPE = new QName(
public static final QName RIM_PAYLOAD_TYPE = new QName(
TCG_NS, PAYLOAD_TYPE, RIM_PFX);
public static final QName _PLATFORM_MANUFACTURER_STR = new QName(
public static final QName RIM_PLATFORM_MANUFACTURER_STR = new QName(
TCG_NS, PLATFORM_MANUFACTURER_STR, RIM_PFX);
public static final QName _PLATFORM_MANUFACTURER_ID = new QName(
public static final QName RIM_PLATFORM_MANUFACTURER_ID = new QName(
TCG_NS, PLATFORM_MANUFACTURER_ID, RIM_PFX);
public static final QName _PLATFORM_MODEL = new QName(
public static final QName RIM_PLATFORM_MODEL = new QName(
TCG_NS, PLATFORM_MODEL, RIM_PFX);
public static final QName _PLATFORM_VERSION = new QName(
public static final QName RIM_PLATFORM_VERSION = new QName(
TCG_NS, PLATFORM_VERSION, RIM_PFX);
public static final QName _FIRMWARE_MANUFACTURER_STR = new QName(
public static final QName RIM_FIRMWARE_MANUFACTURER_STR = new QName(
TCG_NS, FIRMWARE_MANUFACTURER_STR, RIM_PFX);
public static final QName _FIRMWARE_MANUFACTURER_ID = new QName(
public static final QName RIM_FIRMWARE_MANUFACTURER_ID = new QName(
TCG_NS, FIRMWARE_MANUFACTURER_ID, RIM_PFX);
public static final QName _FIRMWARE_MODEL = new QName(
public static final QName RIM_FIRMWARE_MODEL = new QName(
TCG_NS, FIRMWARE_MODEL, RIM_PFX);
public static final QName _FIRMWARE_VERSION = new QName(
public static final QName RIM_FIRMWARE_VERSION = new QName(
TCG_NS, FIRMWARE_VERSION, RIM_PFX);
public static final QName _BINDING_SPEC = new QName(
public static final QName RIM_BINDING_SPEC = new QName(
TCG_NS, BINDING_SPEC, RIM_PFX);
public static final QName _BINDING_SPEC_VERSION = new QName(
public static final QName RIM_BINDING_SPEC_VERSION = new QName(
TCG_NS, BINDING_SPEC_VERSION, RIM_PFX);
public static final QName _PC_URI_LOCAL = new QName(
public static final QName RIM_PC_URI_LOCAL = new QName(
TCG_NS, PC_URI_LOCAL, RIM_PFX);
public static final QName _PC_URI_GLOBAL = new QName(
public static final QName RIM_PC_URI_GLOBAL = new QName(
TCG_NS, PC_URI_GLOBAL, RIM_PFX);
public static final QName _RIM_LINK_HASH = new QName(
public static final QName RIM_RIM_LINK_HASH = new QName(
TCG_NS, RIM_LINK_HASH, RIM_PFX);
public static final QName _SUPPORT_RIM_TYPE = new QName(
public static final QName RIM_SUPPORT_RIM_TYPE = new QName(
TCG_NS, SUPPORT_RIM_TYPE, RIM_PFX);
public static final QName _SUPPORT_RIM_FORMAT = new QName(
public static final QName RIM_SUPPORT_RIM_FORMAT = new QName(
TCG_NS, SUPPORT_RIM_FORMAT, RIM_PFX);
public static final QName _SUPPORT_RIM_URI_GLOBAL = new QName(
public static final QName RIM_SUPPORT_RIM_URI_GLOBAL = new QName(
TCG_NS, SUPPORT_RIM_URI_GLOBAL, RIM_PFX);
public static final QName _N8060_ENVVARPREFIX = new QName(
public static final QName N8060_ENVVARPREFIX = new QName(
NIST_NS, "envVarPrefix", N8060_PFX);
public static final QName _N8060_ENVVARSUFFIX = new QName(
public static final QName N8060_ENVVARSUFFIX = new QName(
NIST_NS, "envVarSuffix", N8060_PFX);
public static final QName _N8060_PATHSEPARATOR = new QName(
public static final QName N8060_PATHSEPARATOR = new QName(
NIST_NS, "pathSeparator", N8060_PFX);
public static final String CA_ISSUERS = "1.3.6.1.5.5.7.48.2";
private SwidTagConstants() {
}
}

@ -390,41 +390,41 @@ public class SwidTagGateway {
private SoftwareMeta createSoftwareMeta(final JsonObject jsonObject) {
SoftwareMeta softwareMeta = objectFactory.createSoftwareMeta();
Map<QName, String> attributes = softwareMeta.getOtherAttributes();
addNonNullAttribute(attributes, SwidTagConstants._COLLOQUIAL_VERSION,
addNonNullAttribute(attributes, SwidTagConstants.N8060_COLLOQUIAL_VERSION,
jsonObject.getString(SwidTagConstants.COLLOQUIAL_VERSION, ""));
addNonNullAttribute(attributes, SwidTagConstants._EDITION,
addNonNullAttribute(attributes, SwidTagConstants.N8060_EDITION,
jsonObject.getString(SwidTagConstants.EDITION, ""));
addNonNullAttribute(attributes, SwidTagConstants._PRODUCT,
addNonNullAttribute(attributes, SwidTagConstants.N8060_PRODUCT,
jsonObject.getString(SwidTagConstants.PRODUCT, ""));
addNonNullAttribute(attributes, SwidTagConstants._REVISION,
addNonNullAttribute(attributes, SwidTagConstants.N8060_REVISION,
jsonObject.getString(SwidTagConstants.REVISION, ""));
addNonNullAttribute(attributes, SwidTagConstants._PAYLOAD_TYPE,
addNonNullAttribute(attributes, SwidTagConstants.RIM_PAYLOAD_TYPE,
jsonObject.getString(SwidTagConstants.PAYLOAD_TYPE, ""));
addNonNullAttribute(attributes, SwidTagConstants._PLATFORM_MANUFACTURER_STR,
addNonNullAttribute(attributes, SwidTagConstants.RIM_PLATFORM_MANUFACTURER_STR,
jsonObject.getString(SwidTagConstants.PLATFORM_MANUFACTURER_STR, ""), true);
addNonNullAttribute(attributes, SwidTagConstants._PLATFORM_MANUFACTURER_ID,
addNonNullAttribute(attributes, SwidTagConstants.RIM_PLATFORM_MANUFACTURER_ID,
jsonObject.getString(SwidTagConstants.PLATFORM_MANUFACTURER_ID, ""), true);
addNonNullAttribute(attributes, SwidTagConstants._PLATFORM_MODEL,
addNonNullAttribute(attributes, SwidTagConstants.RIM_PLATFORM_MODEL,
jsonObject.getString(SwidTagConstants.PLATFORM_MODEL, ""), true);
addNonNullAttribute(attributes, SwidTagConstants._PLATFORM_VERSION,
addNonNullAttribute(attributes, SwidTagConstants.RIM_PLATFORM_VERSION,
jsonObject.getString(SwidTagConstants.PLATFORM_VERSION, ""));
addNonNullAttribute(attributes, SwidTagConstants._FIRMWARE_MANUFACTURER_STR,
addNonNullAttribute(attributes, SwidTagConstants.RIM_FIRMWARE_MANUFACTURER_STR,
jsonObject.getString(SwidTagConstants.FIRMWARE_MANUFACTURER_STR, ""));
addNonNullAttribute(attributes, SwidTagConstants._FIRMWARE_MANUFACTURER_ID,
addNonNullAttribute(attributes, SwidTagConstants.RIM_FIRMWARE_MANUFACTURER_ID,
jsonObject.getString(SwidTagConstants.FIRMWARE_MANUFACTURER_ID, ""));
addNonNullAttribute(attributes, SwidTagConstants._FIRMWARE_MODEL,
addNonNullAttribute(attributes, SwidTagConstants.RIM_FIRMWARE_MODEL,
jsonObject.getString(SwidTagConstants.FIRMWARE_MODEL, ""));
addNonNullAttribute(attributes, SwidTagConstants._FIRMWARE_VERSION,
addNonNullAttribute(attributes, SwidTagConstants.RIM_FIRMWARE_VERSION,
jsonObject.getString(SwidTagConstants.FIRMWARE_VERSION, ""));
addNonNullAttribute(attributes, SwidTagConstants._BINDING_SPEC,
addNonNullAttribute(attributes, SwidTagConstants.RIM_BINDING_SPEC,
jsonObject.getString(SwidTagConstants.BINDING_SPEC, ""));
addNonNullAttribute(attributes, SwidTagConstants._BINDING_SPEC_VERSION,
addNonNullAttribute(attributes, SwidTagConstants.RIM_BINDING_SPEC_VERSION,
jsonObject.getString(SwidTagConstants.BINDING_SPEC_VERSION, ""));
addNonNullAttribute(attributes, SwidTagConstants._PC_URI_LOCAL,
addNonNullAttribute(attributes, SwidTagConstants.RIM_PC_URI_LOCAL,
jsonObject.getString(SwidTagConstants.PC_URI_LOCAL, ""));
addNonNullAttribute(attributes, SwidTagConstants._PC_URI_GLOBAL,
addNonNullAttribute(attributes, SwidTagConstants.RIM_PC_URI_GLOBAL,
jsonObject.getString(SwidTagConstants.PC_URI_GLOBAL, ""));
addNonNullAttribute(attributes, SwidTagConstants._RIM_LINK_HASH,
addNonNullAttribute(attributes, SwidTagConstants.RIM_RIM_LINK_HASH,
jsonObject.getString(SwidTagConstants.RIM_LINK_HASH, ""));
return softwareMeta;
@ -442,12 +442,12 @@ public class SwidTagGateway {
if (jsonObject == null) {
errorRequiredFields += SwidTagConstants.PAYLOAD + ", ";
} else {
addNonNullAttribute(attributes, SwidTagConstants._N8060_ENVVARPREFIX,
jsonObject.getString(SwidTagConstants._N8060_ENVVARPREFIX.getLocalPart(), ""));
addNonNullAttribute(attributes, SwidTagConstants._N8060_ENVVARSUFFIX,
jsonObject.getString(SwidTagConstants._N8060_ENVVARSUFFIX.getLocalPart(), ""));
addNonNullAttribute(attributes, SwidTagConstants._N8060_PATHSEPARATOR,
jsonObject.getString(SwidTagConstants._N8060_PATHSEPARATOR.getLocalPart(), ""));
addNonNullAttribute(attributes, SwidTagConstants.N8060_ENVVARPREFIX,
jsonObject.getString(SwidTagConstants.N8060_ENVVARPREFIX.getLocalPart(), ""));
addNonNullAttribute(attributes, SwidTagConstants.N8060_ENVVARSUFFIX,
jsonObject.getString(SwidTagConstants.N8060_ENVVARSUFFIX.getLocalPart(), ""));
addNonNullAttribute(attributes, SwidTagConstants.N8060_PATHSEPARATOR,
jsonObject.getString(SwidTagConstants.N8060_PATHSEPARATOR.getLocalPart(), ""));
}
return payload;
@ -467,15 +467,15 @@ public class SwidTagGateway {
SwidTagConstants.SUPPORT_RIM_FORMAT_MISSING);
if (!supportRimFormat.equals(SwidTagConstants.SUPPORT_RIM_FORMAT_MISSING)) {
if (supportRimFormat.isEmpty()) {
attributes.put(SwidTagConstants._SUPPORT_RIM_FORMAT,
attributes.put(SwidTagConstants.RIM_SUPPORT_RIM_FORMAT,
SwidTagConstants.TCG_EVENTLOG_ASSERTION);
} else {
attributes.put(SwidTagConstants._SUPPORT_RIM_FORMAT, supportRimFormat);
attributes.put(SwidTagConstants.RIM_SUPPORT_RIM_FORMAT, supportRimFormat);
}
}
addNonNullAttribute(attributes, SwidTagConstants._SUPPORT_RIM_TYPE,
addNonNullAttribute(attributes, SwidTagConstants.RIM_SUPPORT_RIM_TYPE,
jsonObject.getString(SwidTagConstants.SUPPORT_RIM_TYPE, ""));
addNonNullAttribute(attributes, SwidTagConstants._SUPPORT_RIM_URI_GLOBAL,
addNonNullAttribute(attributes, SwidTagConstants.RIM_SUPPORT_RIM_URI_GLOBAL,
jsonObject.getString(SwidTagConstants.SUPPORT_RIM_URI_GLOBAL, ""));
return directory;
@ -497,19 +497,19 @@ public class SwidTagGateway {
SwidTagConstants.SUPPORT_RIM_FORMAT_MISSING);
if (!supportRimFormat.equals(SwidTagConstants.SUPPORT_RIM_FORMAT_MISSING)) {
if (supportRimFormat.isEmpty()) {
attributes.put(SwidTagConstants._SUPPORT_RIM_FORMAT,
attributes.put(SwidTagConstants.RIM_SUPPORT_RIM_FORMAT,
SwidTagConstants.TCG_EVENTLOG_ASSERTION);
} else {
attributes.put(SwidTagConstants._SUPPORT_RIM_FORMAT, supportRimFormat);
attributes.put(SwidTagConstants.RIM_SUPPORT_RIM_FORMAT, supportRimFormat);
}
}
addNonNullAttribute(attributes, SwidTagConstants._SUPPORT_RIM_TYPE,
addNonNullAttribute(attributes, SwidTagConstants.RIM_SUPPORT_RIM_TYPE,
jsonObject.getString(SwidTagConstants.SUPPORT_RIM_TYPE, ""));
addNonNullAttribute(attributes, SwidTagConstants._SUPPORT_RIM_URI_GLOBAL,
addNonNullAttribute(attributes, SwidTagConstants.RIM_SUPPORT_RIM_URI_GLOBAL,
jsonObject.getString(SwidTagConstants.SUPPORT_RIM_URI_GLOBAL, ""));
File rimEventLogFile = new File(rimEventLog);
file.setSize(new BigInteger(Long.toString(rimEventLogFile.length())));
addNonNullAttribute(attributes, SwidTagConstants._SHA256_HASH,
addNonNullAttribute(attributes, SwidTagConstants.SHA256_HASH,
jsonObject.getString(SwidTagConstants.HASH,
HashSwid.get256Hash(rimEventLog)), true);