From 3269e817835fe739ab52864e799c0cfbed5ff93e Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Tue, 29 Jun 2021 12:04:22 -0400 Subject: [PATCH] All components were failing on tests specifically set up to match components and pass. This happened because the int value of the component class value was being translated with SHORT.size. This is odd because it worked before but stopped. --- .../certificate/attributes/ComponentClass.java | 16 ++++++---------- .../SupplyChainCredentialValidator.java | 4 ++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/HIRS_Utils/src/main/java/hirs/data/persist/certificate/attributes/ComponentClass.java b/HIRS_Utils/src/main/java/hirs/data/persist/certificate/attributes/ComponentClass.java index e96b398e..2fa7c139 100644 --- a/HIRS_Utils/src/main/java/hirs/data/persist/certificate/attributes/ComponentClass.java +++ b/HIRS_Utils/src/main/java/hirs/data/persist/certificate/attributes/ComponentClass.java @@ -102,11 +102,6 @@ public class ComponentClass { */ public ComponentClass(final Path componentClassPath, final String componentIdentifier) { this(TCG_COMPONENT_REGISTRY, componentClassPath, getComponentIntValue(componentIdentifier)); - if (componentIdentifier != null && componentIdentifier.contains("#")) { - this.classValueString = componentIdentifier.replaceAll("#", ""); - } else { - this.classValueString = componentIdentifier; - } } /** @@ -152,6 +147,8 @@ public class ComponentClass { getCategory(JsonUtils.getSpecificJsonObject(componentClassPath, registryType)); break; } + + this.classValueString = String.valueOf(componentIdentifier); } /** @@ -276,12 +273,11 @@ public class ComponentClass { componentValue = Integer.decode(component); } else { if (component.contains("#")) { - componentValue = Integer.valueOf( - component.replace("#", ""), - Short.SIZE); + componentValue = Integer.parseInt( + component.replace("#", "")); } else { - componentValue = Integer.valueOf( - component, Short.SIZE); + componentValue = Integer.parseInt( + component); } } } catch (NumberFormatException nfEx) { diff --git a/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java b/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java index 3bf33049..0a181ef9 100644 --- a/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java +++ b/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java @@ -750,8 +750,8 @@ public final class SupplyChainCredentialValidator implements CredentialValidator for (ComponentInfo cInfo : allDeviceInfoComponents) { for (ComponentIdentifier cId : fullDeltaChainComponents) { ciV2 = (ComponentIdentifierV2) cId; - if (ciV2.getComponentClass().getClassValueString() - .contains(cInfo.getComponentClass()) + if (cInfo.getComponentClass().contains( + ciV2.getComponentClass().getClassValueString()) && isMatch(cId, cInfo)) { subCompIdList.remove(cId); subCompInfoList.remove(cInfo);