aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/data/UserWhitelistStore.java40
1 files changed, 37 insertions, 3 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/data/UserWhitelistStore.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/data/UserWhitelistStore.java
index 38bcfa2af..a90d71a18 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/data/UserWhitelistStore.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/data/UserWhitelistStore.java
@@ -43,8 +43,24 @@ public class UserWhitelistStore {
try {
InputStream is = new FileInputStream(new File(new URL(absWhiteListUrl).toURI()));
String whiteListString = IOUtils.toString(new InputStreamReader(is));
- whitelist = KeyValueUtils.getListOfCSVValues(KeyValueUtils.normalizeCSVValueString(whiteListString));
+ List<String> preWhitelist = KeyValueUtils.getListOfCSVValues(KeyValueUtils.normalizeCSVValueString(whiteListString));
+
+ //remove prefix if required
+ for (String bPK : preWhitelist) {
+ String[] bPKSplit = bPK.split(":");
+ if (bPKSplit.length == 1)
+ whitelist.add(bPK);
+
+ else if (bPKSplit.length ==2 )
+ whitelist.add(bPKSplit[1]);
+
+ else
+ Logger.info("Whitelist entry: " + bPK + " has an unsupported format. Entry will be removed ...");
+
+ }
+
Logger.info("User whitelist is initialized with " + whitelist.size() + " entries.");
+
} catch (FileNotFoundException e) {
Logger.warn("Do not initialize user whitelist. Reason: CSV file with bPKs NOT found", e);
@@ -62,6 +78,15 @@ public class UserWhitelistStore {
}
/**
+ * Get the number of entries of the static whitelist
+ *
+ * @return
+ */
+ public int getNumberOfEntries() {
+ return whitelist.size();
+ }
+
+ /**
* Check if bPK is in whitelist
*
* @param bPK
@@ -76,6 +101,11 @@ public class UserWhitelistStore {
}
public boolean isUserbPKInWhitelistDynamic(String bPK) {
+ return isUserbPKInWhitelistDynamic(bPK, false);
+
+ }
+
+ public boolean isUserbPKInWhitelistDynamic(String bPK, boolean onlyDynamic) {
try {
if (absWhiteListUrl != null) {
InputStream is = new FileInputStream(new File(new URL(absWhiteListUrl).toURI()));
@@ -86,7 +116,8 @@ public class UserWhitelistStore {
} else {
Logger.debug("Can NOT find user in dynamic loaded user whitelist. Switch to static version ... ");
- return isUserbPKInWhitelist(bPK);
+ if (!onlyDynamic)
+ return isUserbPKInWhitelist(bPK);
}
}
@@ -94,8 +125,11 @@ public class UserWhitelistStore {
Logger.warn("Dynamic user whitelist check FAILED. Switch to static version ... ", e);
}
+ if (!onlyDynamic)
+ return isUserbPKInWhitelist(bPK);
- return isUserbPKInWhitelist(bPK);
+
+ return false;
}
}