Updating code to use a different format for identifying failed components.

This commit is contained in:
Cyrus 2020-11-09 13:59:19 -05:00
parent bdb32d13ad
commit e8f5107137
2 changed files with 25 additions and 1 deletions
HIRS_AttestationCA/src/main/java/hirs/attestationca/service
HIRS_Utils/src/main/java/hirs/validation

@ -84,6 +84,7 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
private static final Logger LOGGER
= LogManager.getLogger(SupplyChainValidationServiceImpl.class);
private static final int VALUE_INDEX = 1;
/**
* Constructor.
@ -270,6 +271,29 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
return summary;
}
private String updateUnmatchedComponents(final String unmatchedString) {
StringBuilder updatedFailures = new StringBuilder();
String manufacturer = "";
String model = "";
for (String rows : unmatchedString.split(";")) {
for (String str : rows.split(",")) {
String[] manufacturerSplit;
String[] modelSplit;
if (str.contains("Manufacturer")) {
manufacturerSplit = str.split("=");
manufacturer = manufacturerSplit[VALUE_INDEX];
}
if (str.contains("Model")) {
modelSplit = str.split("=");
model = modelSplit[VALUE_INDEX];
}
}
updatedFailures.append(String.format("%s%s;", manufacturer, model));
}
return updatedFailures.toString();
}
/**
* This method is a sub set of the validate supply chain method and focuses
* on the specific multibase validation check for a delta chain. This method

@ -856,7 +856,7 @@ public final class SupplyChainCredentialValidator implements CredentialValidator
for (ComponentIdentifier unmatchedComponent : pcUnmatchedComponents) {
LOGGER.error("Unmatched component " + unmatchedComponentCounter++ + ": "
+ unmatchedComponent);
sb.append(String.format("Manufacturer=%s, Model=%s, Serial=%s, Revision=%s%n",
sb.append(String.format("Manufacturer=%s, Model=%s, Serial=%s, Revision=%s;%n",
unmatchedComponent.getComponentManufacturer(),
unmatchedComponent.getComponentModel(),
unmatchedComponent.getComponentSerial(),