From 04408eab89fe7c1ff0ac6a5156e7289ddd681064 Mon Sep 17 00:00:00 2001 From: Wouter Ensink <46427708+w-ensink@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:57:00 +0100 Subject: [PATCH 01/10] Add separate email templates dir - so the templates can be in a different directory from the other configuration (to prevent overriding in ops) --- Dockerfile | 5 +++-- .../email/EmailConfiguration.java | 2 +- .../email/common/BaseConfiguration.java | 20 +++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 15ab38d..1d65b16 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,10 +27,11 @@ COPY --from=webappbuild /www/ /usr/local/tomee/webapps/ROOT/ # Copy the war file to the webapps directory COPY --from=javabuild /app/build/libs/irma_email_issuer.war /usr/local/tomee/webapps/ -COPY ./src/main/resources/email-en.html /config/email-en.html -COPY ./src/main/resources/email-nl.html /config/email-nl.html +COPY ./src/main/resources/email-en.html /email-templates/email-en.html +COPY ./src/main/resources/email-nl.html /email-templates/email-nl.html ENV IRMA_CONF="/config/" +ENV EMAIL_TEMPLATE_DIR="/email-templates/" EXPOSE 8080 # Copy the config file to the webapp. This is done at runtime so that the config file can be mounted as a volume. diff --git a/src/main/java/foundation/privacybydesign/email/EmailConfiguration.java b/src/main/java/foundation/privacybydesign/email/EmailConfiguration.java index a2c6ca9..a423b24 100644 --- a/src/main/java/foundation/privacybydesign/email/EmailConfiguration.java +++ b/src/main/java/foundation/privacybydesign/email/EmailConfiguration.java @@ -66,7 +66,7 @@ public static void load() { public String getVerifyEmailBody(String language) { try { - return new String(EmailConfiguration.getResource("email-" + language + ".html")); + return new String(EmailConfiguration.getEmailTemplate("email-" + language + ".html")); } catch (IOException e) { logger.error("Failed to read email file"); throw new RuntimeException(e); diff --git a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java index c91c1e6..875c80c 100644 --- a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java +++ b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java @@ -28,6 +28,8 @@ public class BaseConfiguration { public static String filename = "config.json"; public static String environmentVarPrefix = "IRMA_CONF_"; public static String confDirEnvironmentVarName = "IRMA_CONF"; + public static String emailTemplateDirVarName = "EMAIL_TEMPLATE_DIR"; + public static String emailTemplateDir; public static String confDirName; public static boolean printOnLoad = false; public static boolean testing = false; @@ -68,6 +70,17 @@ public static byte[] getResource(String filename) throws IOException { return convertStreamToByteArray(getResourceStream(filename), 2048); } + public static byte[] getEmailTemplate(String filename) throws IOException { + try { + return convertStreamToByteArray(new FileInputStream(new File(getEnvironmentVariableTemplateDir().resolve(filename))), 2048); + } catch (URISyntaxException e) { + logger.error("Invalid URI for email template (" + filename + "): " + e.getMessage()); + logger.error("Terminating now"); + System.exit(-1); + } + return new byte[]{}; + } + public static byte[] convertStreamToByteArray(InputStream stream, int size) throws IOException { byte[] buffer = new byte[size]; ByteArrayOutputStream os = new ByteArrayOutputStream(); @@ -211,6 +224,13 @@ public static URI getEnvironmentVariableConfDir() throws URISyntaxException { return pathToURI(envDir, true); } + public static URI getEnvironmentVariableTemplateDir() throws URISyntaxException { + String envDir = System.getenv(emailTemplateDirVarName); + if (envDir == null || envDir.length() == 0) + return null; + return pathToURI(envDir, true); + } + /** * Returns true if the specified path is a valid configuration directory. A directory * is considered a valid configuration directory if it contains a file called $filename. From 3b2f2b4bfda202af5cdd7ef651738bc4856c41f8 Mon Sep 17 00:00:00 2001 From: Wouter Ensink <46427708+w-ensink@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:11:08 +0100 Subject: [PATCH 02/10] verify user provided path --- .../email/common/BaseConfiguration.java | 67 ++++++++++++++++--- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java index 875c80c..1fa3090 100644 --- a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java +++ b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java @@ -71,14 +71,7 @@ public static byte[] getResource(String filename) throws IOException { } public static byte[] getEmailTemplate(String filename) throws IOException { - try { - return convertStreamToByteArray(new FileInputStream(new File(getEnvironmentVariableTemplateDir().resolve(filename))), 2048); - } catch (URISyntaxException e) { - logger.error("Invalid URI for email template (" + filename + "): " + e.getMessage()); - logger.error("Terminating now"); - System.exit(-1); - } - return new byte[]{}; + return convertStreamToByteArray(new FileInputStream(new File(getTemplateDirectory().resolve(filename))), 2048); } public static byte[] convertStreamToByteArray(InputStream stream, int size) throws IOException { @@ -231,6 +224,64 @@ public static URI getEnvironmentVariableTemplateDir() throws URISyntaxException return pathToURI(envDir, true); } + + public static URI getTemplateDirectory() throws IllegalStateException, IllegalArgumentException { + if (confPath != null) + return confPath; + + try { + // If we're running unit tests, only accept src/test/resources + URI resourcesCandidate = GetJavaResourcesDirectory(); + if (BaseConfiguration.testing) { + if (resourcesCandidate != null) { + logger.info("Running tests: taking src/test/resources as configuration directory"); + confPath = resourcesCandidate; + return confPath; + } + else { + throw new IllegalStateException("No configuration found in in src/test/resources. " + + "(Have you run `git submodule init && git submodule update`?)"); + } + } + + // If a path was given in the $confDirEnvironmentVarName environment variable, prefer it + URI envCandidate = getEnvironmentVariableTemplateDir(); + if (envCandidate != null) { + if (isConfDirectory(envCandidate)) { + logger.info("Taking template directory specified by environment variable " + emailTemplateDirVarName); + confPath = envCandidate; + return confPath; + } else { + // If the user specified an incorrect path (s)he will want to know, so bail out here + throw new IllegalArgumentException("Specified path in " + emailTemplateDirVarName + + " is not a valid configuration directory"); + } + } + + // See if a number of other fixed candidates are suitable + ArrayList candidates = new ArrayList<>(4); + candidates.add(resourcesCandidate); + if (confDirName != null) { + candidates.add(pathToURI("/etc/" + confDirName, true)); + candidates.add(pathToURI("C:/" + confDirName, true)); + candidates.add(pathToURI(System.getProperty("user.home")+"/"+confDirName, true)); + } + + for (URI candidate : candidates) { + if (isConfDirectory(candidate)) { + confPath = candidate; + return confPath; + } + } + + throw new IllegalStateException("No valid template directory found"); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } + } + + + /** * Returns true if the specified path is a valid configuration directory. A directory * is considered a valid configuration directory if it contains a file called $filename. From 857026e82a1b87160359e21445f6291c5282ff81 Mon Sep 17 00:00:00 2001 From: Wouter Ensink <46427708+w-ensink@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:29:28 +0100 Subject: [PATCH 03/10] change some variables --- .../email/common/BaseConfiguration.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java index 1fa3090..2f7580a 100644 --- a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java +++ b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java @@ -31,12 +31,14 @@ public class BaseConfiguration { public static String emailTemplateDirVarName = "EMAIL_TEMPLATE_DIR"; public static String emailTemplateDir; public static String confDirName; + public static String templatefDirName; public static boolean printOnLoad = false; public static boolean testing = false; // Return this from a static getInstance() public static BaseConfiguration instance; private static URI confPath; + private static URI templatePath; public static void load() { @@ -235,8 +237,8 @@ public static URI getTemplateDirectory() throws IllegalStateException, IllegalAr if (BaseConfiguration.testing) { if (resourcesCandidate != null) { logger.info("Running tests: taking src/test/resources as configuration directory"); - confPath = resourcesCandidate; - return confPath; + templatePath = resourcesCandidate; + return templatePath; } else { throw new IllegalStateException("No configuration found in in src/test/resources. " + @@ -249,8 +251,8 @@ public static URI getTemplateDirectory() throws IllegalStateException, IllegalAr if (envCandidate != null) { if (isConfDirectory(envCandidate)) { logger.info("Taking template directory specified by environment variable " + emailTemplateDirVarName); - confPath = envCandidate; - return confPath; + templatePath = envCandidate; + return templatePath; } else { // If the user specified an incorrect path (s)he will want to know, so bail out here throw new IllegalArgumentException("Specified path in " + emailTemplateDirVarName @@ -261,16 +263,16 @@ public static URI getTemplateDirectory() throws IllegalStateException, IllegalAr // See if a number of other fixed candidates are suitable ArrayList candidates = new ArrayList<>(4); candidates.add(resourcesCandidate); - if (confDirName != null) { - candidates.add(pathToURI("/etc/" + confDirName, true)); - candidates.add(pathToURI("C:/" + confDirName, true)); - candidates.add(pathToURI(System.getProperty("user.home")+"/"+confDirName, true)); + if (templatefDirName != null) { + candidates.add(pathToURI("/etc/" + templatefDirName, true)); + candidates.add(pathToURI("C:/" + templatefDirName, true)); + candidates.add(pathToURI(System.getProperty("user.home")+"/"+templatefDirName, true)); } for (URI candidate : candidates) { if (isConfDirectory(candidate)) { - confPath = candidate; - return confPath; + templatePath = candidate; + return templatePath; } } From 780894bc508f59d0130eeeb01ee4a52eef4963cb Mon Sep 17 00:00:00 2001 From: Wouter Ensink <46427708+w-ensink@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:36:19 +0100 Subject: [PATCH 04/10] made template code more like config code --- .../privacybydesign/email/common/BaseConfiguration.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java index 2f7580a..988bf23 100644 --- a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java +++ b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java @@ -72,8 +72,12 @@ public static byte[] getResource(String filename) throws IOException { return convertStreamToByteArray(getResourceStream(filename), 2048); } + public static FileInputStream getEmailTemplateStream(String filename) throws IOException { + return new FileInputStream(new File(getTemplateDirectory().resolve(filename))); + } + public static byte[] getEmailTemplate(String filename) throws IOException { - return convertStreamToByteArray(new FileInputStream(new File(getTemplateDirectory().resolve(filename))), 2048); + return convertStreamToByteArray(getEmailTemplateStream(filename), 2048); } public static byte[] convertStreamToByteArray(InputStream stream, int size) throws IOException { From b04f117228aaa6dccdbd3ae44eae3362df67ed0e Mon Sep 17 00:00:00 2001 From: Wouter Ensink <46427708+w-ensink@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:43:19 +0100 Subject: [PATCH 05/10] fix variable name --- .../privacybydesign/email/common/BaseConfiguration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java index 988bf23..56e7995 100644 --- a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java +++ b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java @@ -232,8 +232,8 @@ public static URI getEnvironmentVariableTemplateDir() throws URISyntaxException public static URI getTemplateDirectory() throws IllegalStateException, IllegalArgumentException { - if (confPath != null) - return confPath; + if (templatePath != null) + return templatePath; try { // If we're running unit tests, only accept src/test/resources From a92024e17788b138092f69629205fc3bfd7b9fdf Mon Sep 17 00:00:00 2001 From: Wouter Ensink <46427708+w-ensink@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:57:59 +0100 Subject: [PATCH 06/10] add more file validation --- .../email/common/BaseConfiguration.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java index 56e7995..6d3dc1f 100644 --- a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java +++ b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java @@ -20,6 +20,8 @@ import java.security.spec.X509EncodedKeySpec; import java.util.ArrayList; import java.util.HashMap; +import java.nio.file.Path; +import java.nio.file.Paths; public class BaseConfiguration { // Override these in a static {} block @@ -73,7 +75,24 @@ public static byte[] getResource(String filename) throws IOException { } public static FileInputStream getEmailTemplateStream(String filename) throws IOException { - return new FileInputStream(new File(getTemplateDirectory().resolve(filename))); + validateFilename(filename); + Path resolvedPath = resolvePath(getTemplateDirectory(), filename); + return new FileInputStream(resolvedPath.toFile()); + } + + private static void validateFilename(String filename) { + if (filename == null || filename.isEmpty() || filename.contains("..")) { + throw new IllegalArgumentException("Invalid filename: " + filename); + } + // Optional: Add further filename validation, such as allowed extensions + } + + private static Path resolvePath(URI baseDirectory, String filename) { + Path resolvedPath = new File(baseDirectory).toPath().resolve(filename).normalize(); + if (!resolvedPath.startsWith(new File(baseDirectory).toPath())) { + throw new SecurityException("Path traversal attempt detected for file: " + filename); + } + return resolvedPath; } public static byte[] getEmailTemplate(String filename) throws IOException { From 66604f73633e8afb2219d45ba70f40f24fd571f3 Mon Sep 17 00:00:00 2001 From: Wouter Ensink <46427708+w-ensink@users.noreply.github.com> Date: Wed, 4 Dec 2024 14:15:02 +0100 Subject: [PATCH 07/10] add workflow dispatch --- .github/workflows/delivery.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/delivery.yml b/.github/workflows/delivery.yml index e3db0ed..2b0d8b0 100644 --- a/.github/workflows/delivery.yml +++ b/.github/workflows/delivery.yml @@ -6,6 +6,8 @@ on: release: # Note: a current limitation is that when a release is edited after publication, then the Docker tags are not automatically updated. types: [ published ] + # Make it possible to trigger the checks manually. + workflow_dispatch: permissions: contents: write From a1026b0602933542096aaf990e5511ef8ae0be73 Mon Sep 17 00:00:00 2001 From: Wouter Ensink <46427708+w-ensink@users.noreply.github.com> Date: Wed, 4 Dec 2024 14:44:08 +0100 Subject: [PATCH 08/10] add some logging --- .../privacybydesign/email/common/BaseConfiguration.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java index 6d3dc1f..10290ef 100644 --- a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java +++ b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java @@ -77,6 +77,7 @@ public static byte[] getResource(String filename) throws IOException { public static FileInputStream getEmailTemplateStream(String filename) throws IOException { validateFilename(filename); Path resolvedPath = resolvePath(getTemplateDirectory(), filename); + logger.info("trying to load: " + resolvedPath.toString()); return new FileInputStream(resolvedPath.toFile()); } From 67c23cf6bd47438b564bd131eb0862847d7346da Mon Sep 17 00:00:00 2001 From: Wouter Ensink <46427708+w-ensink@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:03:18 +0100 Subject: [PATCH 09/10] fix looking for the wrong file --- .../email/common/BaseConfiguration.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java index 10290ef..2be87c7 100644 --- a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java +++ b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java @@ -273,7 +273,7 @@ public static URI getTemplateDirectory() throws IllegalStateException, IllegalAr // If a path was given in the $confDirEnvironmentVarName environment variable, prefer it URI envCandidate = getEnvironmentVariableTemplateDir(); if (envCandidate != null) { - if (isConfDirectory(envCandidate)) { + if (isConfDirectory(envCandidate, "email-en.html")) { logger.info("Taking template directory specified by environment variable " + emailTemplateDirVarName); templatePath = envCandidate; return templatePath; @@ -294,7 +294,7 @@ public static URI getTemplateDirectory() throws IllegalStateException, IllegalAr } for (URI candidate : candidates) { - if (isConfDirectory(candidate)) { + if (isConfDirectory(candidate, "email-en.txt")) { templatePath = candidate; return templatePath; } @@ -312,7 +312,7 @@ public static URI getTemplateDirectory() throws IllegalStateException, IllegalAr * Returns true if the specified path is a valid configuration directory. A directory * is considered a valid configuration directory if it contains a file called $filename. */ - public static boolean isConfDirectory(URI candidate) { + public static boolean isConfDirectory(URI candidate, String filename) { return candidate != null && new File(candidate.resolve(filename)).isFile(); } @@ -374,7 +374,7 @@ public static URI getConfigurationDirectory() throws IllegalStateException, Ille // If a path was given in the $confDirEnvironmentVarName environment variable, prefer it URI envCandidate = getEnvironmentVariableConfDir(); if (envCandidate != null) { - if (isConfDirectory(envCandidate)) { + if (isConfDirectory(envCandidate, filename)) { logger.info("Taking configuration directory specified by environment variable " + confDirEnvironmentVarName); confPath = envCandidate; return confPath; @@ -395,7 +395,7 @@ public static URI getConfigurationDirectory() throws IllegalStateException, Ille } for (URI candidate : candidates) { - if (isConfDirectory(candidate)) { + if (isConfDirectory(candidate, filename)) { confPath = candidate; return confPath; } From 62c0625dae0490e707e612c40581ae13af5cca14 Mon Sep 17 00:00:00 2001 From: Wouter Ensink <46427708+w-ensink@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:13:34 +0100 Subject: [PATCH 10/10] cleaned code up a bit --- .../email/common/BaseConfiguration.java | 57 ++++--------------- 1 file changed, 12 insertions(+), 45 deletions(-) diff --git a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java index 2be87c7..fa38fb2 100644 --- a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java +++ b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java @@ -21,13 +21,12 @@ import java.util.ArrayList; import java.util.HashMap; import java.nio.file.Path; -import java.nio.file.Paths; public class BaseConfiguration { // Override these in a static {} block public static Class> clazz; public static Logger logger = LoggerFactory.getLogger(BaseConfiguration.class); - public static String filename = "config.json"; + public static String configFileName = "config.json"; public static String environmentVarPrefix = "IRMA_CONF_"; public static String confDirEnvironmentVarName = "IRMA_CONF"; public static String emailTemplateDirVarName = "EMAIL_TEMPLATE_DIR"; @@ -45,7 +44,7 @@ public class BaseConfiguration { public static void load() { try { - String json = new String(getResource(filename)); + String json = new String(getResource(configFileName)); instance = GsonUtil.getGson().fromJson(json, clazz); logger.info("Using configuration directory: " + BaseConfiguration.getConfigurationDirectory().toString()); } catch (IOException|JsonSyntaxException e) { @@ -250,30 +249,13 @@ public static URI getEnvironmentVariableTemplateDir() throws URISyntaxException return pathToURI(envDir, true); } - public static URI getTemplateDirectory() throws IllegalStateException, IllegalArgumentException { if (templatePath != null) return templatePath; - try { - // If we're running unit tests, only accept src/test/resources - URI resourcesCandidate = GetJavaResourcesDirectory(); - if (BaseConfiguration.testing) { - if (resourcesCandidate != null) { - logger.info("Running tests: taking src/test/resources as configuration directory"); - templatePath = resourcesCandidate; - return templatePath; - } - else { - throw new IllegalStateException("No configuration found in in src/test/resources. " + - "(Have you run `git submodule init && git submodule update`?)"); - } - } - - // If a path was given in the $confDirEnvironmentVarName environment variable, prefer it URI envCandidate = getEnvironmentVariableTemplateDir(); if (envCandidate != null) { - if (isConfDirectory(envCandidate, "email-en.html")) { + if (isEmailTemplateDirectory(envCandidate)) { logger.info("Taking template directory specified by environment variable " + emailTemplateDirVarName); templatePath = envCandidate; return templatePath; @@ -283,37 +265,22 @@ public static URI getTemplateDirectory() throws IllegalStateException, IllegalAr + " is not a valid configuration directory"); } } - - // See if a number of other fixed candidates are suitable - ArrayList candidates = new ArrayList<>(4); - candidates.add(resourcesCandidate); - if (templatefDirName != null) { - candidates.add(pathToURI("/etc/" + templatefDirName, true)); - candidates.add(pathToURI("C:/" + templatefDirName, true)); - candidates.add(pathToURI(System.getProperty("user.home")+"/"+templatefDirName, true)); - } - - for (URI candidate : candidates) { - if (isConfDirectory(candidate, "email-en.txt")) { - templatePath = candidate; - return templatePath; - } - } - throw new IllegalStateException("No valid template directory found"); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } } - - /** * Returns true if the specified path is a valid configuration directory. A directory * is considered a valid configuration directory if it contains a file called $filename. */ - public static boolean isConfDirectory(URI candidate, String filename) { - return candidate != null && new File(candidate.resolve(filename)).isFile(); + public static boolean isConfDirectory(URI candidate) { + return candidate != null && new File(candidate.resolve(configFileName)).isFile(); + } + + public static boolean isEmailTemplateDirectory(URI candidate) { + return candidate != null && new File(candidate.resolve("email-en.html")).isFile(); } /** @@ -325,7 +292,7 @@ public static URI GetJavaResourcesDirectory() throws URISyntaxException { // seems to be to ask for an existing file or directory within the resources. That is, // BaseConfiguration.class.getClassLoader().getResource("/") or variants thereof // give an incorrect path. - String testfile = BaseConfiguration.testing ? "config.test.json" : filename; + String testfile = BaseConfiguration.testing ? "config.test.json" : configFileName; URL url = BaseConfiguration.class.getClassLoader().getResource(testfile); if (url != null) // Construct an URI of the parent path return pathToURI(new File(url.getPath()).getParent(), true); @@ -374,7 +341,7 @@ public static URI getConfigurationDirectory() throws IllegalStateException, Ille // If a path was given in the $confDirEnvironmentVarName environment variable, prefer it URI envCandidate = getEnvironmentVariableConfDir(); if (envCandidate != null) { - if (isConfDirectory(envCandidate, filename)) { + if (isConfDirectory(envCandidate)) { logger.info("Taking configuration directory specified by environment variable " + confDirEnvironmentVarName); confPath = envCandidate; return confPath; @@ -395,7 +362,7 @@ public static URI getConfigurationDirectory() throws IllegalStateException, Ille } for (URI candidate : candidates) { - if (isConfDirectory(candidate, filename)) { + if (isConfDirectory(candidate)) { confPath = candidate; return confPath; }