From 580079f26d01405efa4ee8b4c358f44421192f21 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 21 Apr 2023 12:25:54 +0800 Subject: [PATCH] allow to prohibit network access from within code --- .../fhir/utilities/settings/FhirSettings.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/settings/FhirSettings.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/settings/FhirSettings.java index 73a14f900..2f4e74c5a 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/settings/FhirSettings.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/settings/FhirSettings.java @@ -16,6 +16,7 @@ public class FhirSettings { public static final String FHIR_SETTINGS_PATH = "fhir.settings.path"; private static String explicitFilePath = null; + private static Boolean prohibitNetworkAccess; public static void setExplicitFilePath(String explicitFilePath) { if (instance != null) { @@ -114,14 +115,27 @@ public class FhirSettings { } public static boolean hasProhibitNetworkAccess() { + if (prohibitNetworkAccess != null) { + return true; + } getInstance(); - return instance.fhirSettings.getProhibitNetworkAccess() != null; } + return instance.fhirSettings.getProhibitNetworkAccess() != null; + } public static boolean isProhibitNetworkAccess() { + if (prohibitNetworkAccess != null) { + return prohibitNetworkAccess; + } getInstance(); return instance.fhirSettings.getProhibitNetworkAccess() == null ? false - : instance.fhirSettings.getProhibitNetworkAccess(); } + : instance.fhirSettings.getProhibitNetworkAccess(); + } + + public static void setProhibitNetworkAccess(boolean value) { + prohibitNetworkAccess = value; + } + private static FhirSettings instance = null; private static FhirSettings getInstance() {