diff --git a/HIRS_Utils/src/main/java/hirs/utils/JsonUtils.java b/HIRS_Utils/src/main/java/hirs/utils/JsonUtils.java index 78dfb0d4..63140cf3 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/JsonUtils.java +++ b/HIRS_Utils/src/main/java/hirs/utils/JsonUtils.java @@ -101,6 +101,30 @@ public final class JsonUtils { return jsonObject; } + + + + public static JsonObject getSpecificJsonObject(final String jsonFilename, final String elementName) { + // find the file and load it + return getSpecificJsonObject(jsonFilename, elementName, StandardCharsets.UTF_8); + } + + public static JsonObject getSpecificJsonObject(final String jsonFilename, + final String elementName, + final Charset charset) { + // find the file and load it + JsonObject jsonObject = getJsonObject(jsonFilename, charset); + + if (jsonObject != null && jsonObject.get(elementName) != null) { + return jsonObject.get(elementName).asObject(); + } + + return new JsonObject(); + } + public static JsonObject getJsonObject(final String jsonFilename) { + return getJsonObject(jsonFilename, StandardCharsets.UTF_8); + } + public static JsonObject getJsonObject(final String jsonFilename, final Charset charset) { // find the file and load it JsonObject jsonObject = new JsonObject(); diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/uefi/UefiGuid.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/uefi/UefiGuid.java index c0357e49..00c22ce1 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/uefi/UefiGuid.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/uefi/UefiGuid.java @@ -72,9 +72,13 @@ public class UefiGuid { System.out.println("XXXX EMPTYYYYYYY, before trying to grab file from code"); - uefiVendorRef = JsonUtils.getJsonObject("vendor-table2.json", +// uefiVendorRef = JsonUtils.getJsonObject("vendor-table2.json", +// StandardCharsets.UTF_8); + + uefiVendorRef = JsonUtils.getSpecificJsonObject("vendor-table2.json", "VendorTable", StandardCharsets.UTF_8); + // System.out.println("XXXX getClass: " + getClass()); // System.out.println("XXXX getClassResource: " + getClass().getResource("/vendor-table2.json")); //