diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/PlatformCredential.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/PlatformCredential.java index 4a7d654f..e78af595 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/PlatformCredential.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/PlatformCredential.java @@ -477,12 +477,15 @@ public class PlatformCredential extends DeviceAssociatedCertificate { if (subjectAlternativeNameExtension != null) { GeneralNames gnames = GeneralNames.getInstance( subjectAlternativeNameExtension.getParsedValue()); - for (GeneralName gname : gnames.getNames()) { + GeneralName[] allGnames = gnames.getNames(); + for (GeneralName gname : allGnames) { // Check if it's a directoryName [4] Name type if (gname.getTagNo() == GeneralName.directoryName) { X500Name name = X500Name.getInstance(gname.getName()); - for (RDN rdn : name.getRDNs()) { - for (AttributeTypeAndValue attTV : rdn.getTypesAndValues()) { + RDN[] rdns = name.getRDNs(); + for (RDN rdn : rdns) { + AttributeTypeAndValue[] attributeTypeAndValues = rdn.getTypesAndValues(); + for (AttributeTypeAndValue attTV : attributeTypeAndValues) { switch (attTV.getType().toString()) { case PLATFORM_MANUFACTURER_2_0: this.manufacturer = attTV.getValue().toString(); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentClass.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentClass.java index 4987e95f..1ce68dd5 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentClass.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentClass.java @@ -149,7 +149,16 @@ ComponentClass { default: this.category = this.componentIdentifier.substring(0, MID_INDEX) + this.category; this.component = OTHER + this.componentIdentifier.substring(MID_INDEX); - findStringValues(JsonUtils.getSpecificJsonObject(componentClassPath, registryType)); + + // if the registry type is of type PCIE, attempt to use the included library to parse the string values + if (this.registryType.equals("PCIE")) { + findStringValuesForPCIE(); + } + // for all other registry types, attempt to retrieve the string values using the component class json file + else { + findStringValuesFromJSONObject( + JsonUtils.getSpecificJsonObject(componentClassPath, registryType)); + } break; } } @@ -191,22 +200,29 @@ ComponentClass { */ @Override public String toString() { - String resultString; if (componentStr.equals(UNKNOWN_STRING) || component.equals(OTHER_STRING)) { - resultString = String.format("%s%n%s", registryType, categoryStr); - } else { - resultString = String.format("%s%n%s - %s", registryType, categoryStr, componentStr); + return String.format("%s%n%s", registryType, categoryStr); } - return resultString; + return String.format("%s%n%s - %s", registryType, categoryStr, componentStr); } /** - * Getter for the Category mapped to the associated value in. - * - * @param categories a JSON object associated with mapped categories in file - * {}@link componentIdentifier}. + * Helper method that attempts to find and set the category and component string using the provided library. This method + * will be used only for the PCIE registry types. */ - private void findStringValues(final JsonObject categories) { + private void findStringValuesForPCIE() { + //TODO placeholders + this.categoryStr = NONE_STRING; + this.componentStr = UNKNOWN_STRING; + } + + /** + * Helper method that attempts to find and set the category and component string using the provided JSON object. This + * method will typically be used for the SMBIOS and TCG registry types. + * + * @param categories a JSON object associated with mapped categories in file. + */ + private void findStringValuesFromJSONObject(final JsonObject categories) { String categoryID; String componentMask; boolean found = false; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/IdentityClaimProcessor.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/IdentityClaimProcessor.java index 1850a1cd..7d880fc2 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/IdentityClaimProcessor.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/IdentityClaimProcessor.java @@ -753,8 +753,10 @@ public class IdentityClaimProcessor extends AbstractProcessor { ComponentResult componentResult; if (platformCredential.getPlatformConfigurationV1() != null) { - for (ComponentIdentifier componentIdentifier : platformCredential - .getComponentIdentifiers()) { + List<ComponentIdentifier> componentIdentifiers = platformCredential + .getComponentIdentifiers(); + + for (ComponentIdentifier componentIdentifier : componentIdentifiers) { componentResult = new ComponentResult(platformCredential.getPlatformSerial(), platformCredential.getSerialNumber().toString(), platformCredential.getPlatformChainType(), @@ -764,8 +766,10 @@ public class IdentityClaimProcessor extends AbstractProcessor { componentResultRepository.save(componentResult); } } else if (platformCredential.getPlatformConfigurationV2() != null) { - for (ComponentIdentifierV2 componentIdentifierV2 : platformCredential - .getComponentIdentifiersV2()) { + List<ComponentIdentifierV2> componentIdentifiersV2 = platformCredential + .getComponentIdentifiersV2(); + + for (ComponentIdentifierV2 componentIdentifierV2 : componentIdentifiersV2) { componentResult = new ComponentResult(platformCredential.getPlatformSerial(), platformCredential.getSerialNumber().toString(), platformCredential.getPlatformChainType(),