From 33316e850eef882d58e7f45b121f2e97d65ce044 Mon Sep 17 00:00:00 2001 From: iadgovuser58 <124906646+iadgovuser58@users.noreply.github.com> Date: Tue, 14 May 2024 18:08:47 -0400 Subject: [PATCH] trying to get code file to open --- .../utils/tpm/eventlog/uefi/UefiGuid.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) 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 e0feae84..83adcc27 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 @@ -4,9 +4,13 @@ import com.eclipsesource.json.JsonObject; import hirs.utils.HexUtils; import hirs.utils.JsonUtils; +import java.io.IOException; import java.math.BigInteger; +import java.net.URISyntaxException; +import java.net.URL; import java.nio.file.FileSystems; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.UUID; /** @@ -25,6 +29,8 @@ public class UefiGuid { private static final Path JSON_PATH = FileSystems.getDefault().getPath("/etc", "hirs", "aca", "default-properties", "vendor-table.json"); + +// Path fPath = Paths.get(this.getClass().getResource(filename).toURI()); private JsonObject uefiVendorRef; /** * guid byte array. @@ -44,7 +50,36 @@ public class UefiGuid { guid = new byte[UefiConstants.SIZE_16]; System.arraycopy(guidBytes, 0, guid, 0, UefiConstants.SIZE_16); uuid = processGuid(guidBytes); - uefiVendorRef = JsonUtils.getSpecificJsonObject(JSON_PATH, "VendorTable"); +// uefiVendorRef = JsonUtils.getSpecificJsonObject(JSON_PATH, "VendorTable"); + + + Path bad = FileSystems.getDefault().getPath("/etc", + "hirs", "aca", "default-properties", "vendor-tableBAD.json"); + uefiVendorRef = JsonUtils.getSpecificJsonObject(bad, + "VendorTable"); + + if(isVendorTableReferenceHandleEmpty()) { + System.out.println("XXXX EMPTYYYYYYY, before trying to grab file from code"); + try { + + URL url = ClassLoader.getSystemResources("vendor-table.json").nextElement(); +// URL url = ClassLoader.getSystemResources("vendor-table.json"); + Path codePath = Paths.get(url.toURI()); + uefiVendorRef = JsonUtils.getSpecificJsonObject(codePath, + "VendorTable"); + + } catch (IOException e) { + System.out.print("XXXX IOException"); + throw new RuntimeException(e); + } catch (URISyntaxException e) { + System.out.print("XXXX URISyntaxException"); + throw new RuntimeException(e); + } + } + + if(isVendorTableReferenceHandleEmpty()) { + System.out.println("YYYY EMPTY STILL, after trying to grab file from code"); + } } /**