diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2015-03-26 10:04:08 +0100 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2015-03-26 10:04:08 +0100 |
commit | dfde473ef88f8be7873385b1ff3357c1f79afe73 (patch) | |
tree | 5e6873399f8519944a1a20c6ed1ba2d2795f429e /pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config | |
parent | f179c8db3574d03bb1b6b5be1bd86c9ea04073ad (diff) | |
download | pdf-as-4-dfde473ef88f8be7873385b1ff3357c1f79afe73.tar.gz pdf-as-4-dfde473ef88f8be7873385b1ff3357c1f79afe73.tar.bz2 pdf-as-4-dfde473ef88f8be7873385b1ff3357c1f79afe73.zip |
added Whitelist for external configuration overwrites
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config')
-rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java index 5860b740..ca4f2c50 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java @@ -50,6 +50,8 @@ public class WebConfiguration implements IConfigurationConstants { public static final String STATISTIC_BACKEND_LIST = "statistic.backends"; public static final String ALLOW_EXT_OVERWRITE = "allow.ext.overwrite"; + public static final String ALLOW_EXT_WHITELIST_VALUE_PRE = "ext.overwrite.wl."; + public static final String MOA_SS_ENABLED = "moa.enabled"; public static final String SOAP_SIGN_ENABLED = "soap.sign.enabled"; public static final String SOAP_VERIFY_ENABLED = "soap.verify.enabled"; @@ -94,11 +96,13 @@ public class WebConfiguration implements IConfigurationConstants { .getLogger(WebConfiguration.class); private static List<String> whiteListregEx = new ArrayList<String>(); - + private static List<String> overwritewhiteListregEx = new ArrayList<String>(); + public static void configure(String config) { properties.clear(); whiteListregEx.clear(); + overwritewhiteListregEx.clear(); try { properties.load(new FileInputStream(config)); @@ -123,6 +127,23 @@ public class WebConfiguration implements IConfigurationConstants { } } } + + if (isAllowExtOverwrite()) { + Iterator<Object> keyIt = properties.keySet().iterator(); + while (keyIt.hasNext()) { + Object keyObj = keyIt.next(); + if (keyObj != null) { + String key = keyObj.toString(); + if (key.startsWith(ALLOW_EXT_WHITELIST_VALUE_PRE)) { + String whitelist_expr = properties.getProperty(key); + if (whitelist_expr != null) { + overwritewhiteListregEx.add(whitelist_expr); + logger.debug("Overwrite Whitelist: " + whitelist_expr); + } + } + } + } + } Iterator<Object> keyIt = properties.keySet().iterator(); while (keyIt.hasNext()) { @@ -249,6 +270,26 @@ public class WebConfiguration implements IConfigurationConstants { return false; } + public static synchronized boolean isOverwriteAllowed(String key) { + if (isAllowExtOverwrite()) { + + Iterator<String> patterns = whiteListregEx.iterator(); + while (patterns.hasNext()) { + String pattern = patterns.next(); + try { + if (key.matches(pattern)) { + return true; + } + } catch (Throwable e) { + logger.warn("Error in matching regex: " + pattern, e); + } + } + + return false; + } + return false; + } + public static boolean isMoaEnabled(String keyIdentifier) { String value = properties.getProperty(MOA_LIST + "." + keyIdentifier + ".enabled"); if (value != null) { |