diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/CredentialManagementHelper.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/CredentialManagementHelper.java index 44fab009..86a8ea5f 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/CredentialManagementHelper.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/CredentialManagementHelper.java @@ -113,7 +113,8 @@ public final class CredentialManagementHelper { PlatformCredential.parseWithPossibleHeader(platformBytes); if (platformCredential == null) { - log.error("The platform credential that was parsed was null"); + log.error("The platform credential that was parsed with the provided" + + "byte array was null"); return null; } @@ -155,6 +156,10 @@ public final class CredentialManagementHelper { } catch (Exception e) { log.error("Error parsing platform credential", e); } + + log.error("Due to an exception being thrown while " + + " attempting to store platform certificate(s) " + + "this method will return a null platform certificate."); return null; } } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java index 88d17922..7604a544 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java @@ -989,16 +989,17 @@ public class CertificateAttributeScvValidator extends SupplyChainCredentialValid final List componentInfos, final List compiledComponentList) { Map> deviceHashMap = new HashMap<>(); + componentInfos.forEach((componentInfo) -> { - List innerList; + List innerList = new ArrayList<>(); Integer compInfoHash = componentInfo.hashCommonElements(); + if (deviceHashMap.containsKey(compInfoHash)) { innerList = deviceHashMap.get(compInfoHash); - innerList.add(componentInfo); - } else { - innerList = new ArrayList<>(0); - innerList.add(componentInfo); } + + innerList.add(componentInfo); + deviceHashMap.put(compInfoHash, innerList); }); @@ -1028,23 +1029,37 @@ public class CertificateAttributeScvValidator extends SupplyChainCredentialValid // continue down the options, move to a different method. // create component class mapping to component info Map> componentDeviceMap = new HashMap<>(); + componentInfos.forEach((componentInfo) -> { - List innerList; + List innerList = new ArrayList<>(); String componentClass = componentInfo.getComponentClassValue(); + if (componentDeviceMap.containsKey(componentClass)) { innerList = componentDeviceMap.get(componentClass); - innerList.add(componentInfo); - } else { - innerList = new ArrayList<>(0); - innerList.add(componentInfo); } + + innerList.add(componentInfo); + componentDeviceMap.put(componentClass, innerList); }); List componentClassInfo; List attributeResults = new ArrayList<>(); + for (ComponentResult componentResult : remainingComponentResults) { + componentClassInfo = componentDeviceMap.get(componentResult.getComponentClassValue()); + + if (componentClassInfo == null) { + log.error("The retrieved list of component class info is null. The null list" + + "is associated with the component result's component class value of {}", + componentResult.getComponentClassValue()); + + //move on to the next iteration since there is nothing we can do with the null + // component class info + continue; + } + if (componentClassInfo.size() == 1) { attributeResults.addAll(generateComponentAttributeResults( componentClassInfo.get(0), componentResult));