mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-29 09:19:00 +00:00
fixed file not found try/catch
This commit is contained in:
parent
cb12dce87d
commit
1c5bf6a48c
@ -3,6 +3,7 @@ package hirs.utils;
|
|||||||
import com.eclipsesource.json.Json;
|
import com.eclipsesource.json.Json;
|
||||||
import com.eclipsesource.json.JsonObject;
|
import com.eclipsesource.json.JsonObject;
|
||||||
import hirs.utils.tpm.eventlog.uefi.UefiGuid;
|
import hirs.utils.tpm.eventlog.uefi.UefiGuid;
|
||||||
|
import hirs.utils.xjc.Resource;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
@ -127,29 +128,18 @@ public final class JsonUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static JsonObject getJsonObject(final String jsonFilename, final Charset charset) {
|
public static JsonObject getJsonObject(final String jsonFilename, final Charset charset) {
|
||||||
// find the file and load it
|
|
||||||
JsonObject jsonObject = new JsonObject();
|
JsonObject jsonObject = new JsonObject();
|
||||||
|
|
||||||
try {
|
|
||||||
InputStream jsonIs = UefiGuid.class
|
InputStream jsonIs = UefiGuid.class
|
||||||
.getClassLoader().getResourceAsStream(jsonFilename);
|
.getClassLoader().getResourceAsStream(jsonFilename);
|
||||||
|
if (jsonIs != null) {
|
||||||
|
try {
|
||||||
jsonObject = Json.parse(new InputStreamReader(jsonIs,
|
jsonObject = Json.parse(new InputStreamReader(jsonIs,
|
||||||
charset)).asObject();
|
charset)).asObject();
|
||||||
} catch (IOException e) {
|
} catch (IOException ex) {
|
||||||
throw new RuntimeException(e);
|
jsonObject = new JsonObject();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// if (Files.notExists(jsonPath)) {
|
|
||||||
// log.warn(String.format("No file found at %s.", jsonPath.toString()));
|
|
||||||
// } else {
|
|
||||||
// try {
|
|
||||||
// InputStream inputStream = new FileInputStream(jsonPath.toString());
|
|
||||||
// jsonObject = Json.parse(new InputStreamReader(inputStream,
|
|
||||||
// charset)).asObject();
|
|
||||||
// } catch (IOException ex) {
|
|
||||||
// // add log file thing here indication issue with JSON File
|
|
||||||
// jsonObject = new JsonObject();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class UefiGuid {
|
|||||||
private static final Path JSON_PATH = FileSystems.getDefault().getPath("/etc",
|
private static final Path JSON_PATH = FileSystems.getDefault().getPath("/etc",
|
||||||
"hirs", "aca", "default-properties", "vendor-table.json");
|
"hirs", "aca", "default-properties", "vendor-table.json");
|
||||||
|
|
||||||
private static final String JSON_FILENAME = "vendor-table3.json";
|
private static final String JSON_FILENAME = "vendor-table2.json";
|
||||||
|
|
||||||
private JsonObject uefiVendorRef;
|
private JsonObject uefiVendorRef;
|
||||||
/** Track status of vendor-table.json */
|
/** Track status of vendor-table.json */
|
||||||
|
Loading…
Reference in New Issue
Block a user