weblib/remlib: white/black lists: allow sources with /
authorNiki Roo <niki@nikiroo.be>
Thu, 14 May 2020 08:13:25 +0000 (10:13 +0200)
committerNiki Roo <niki@nikiroo.be>
Thu, 14 May 2020 08:13:25 +0000 (10:13 +0200)
src/be/nikiroo/fanfix/library/RemoteLibraryServer.java
src/be/nikiroo/fanfix/library/WebLibraryServer.java

index e54f105d6bf9233c4f1c4383c948630b57b79555..59819bb948903a1893b9e9d2751f43ca8d3a66a5 100644 (file)
@@ -3,6 +3,7 @@ package be.nikiroo.fanfix.library;
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -578,12 +579,16 @@ public class RemoteLibraryServer extends ServerObject {
 
        private boolean isAllowed(MetaData meta, List<String> whitelist,
                        List<String> blacklist) {
-               if (!whitelist.isEmpty() && !whitelist.contains(meta.getSource())) {
-                       return false;
+               MetaResultList one = new MetaResultList(Arrays.asList(meta));
+               if (!whitelist.isEmpty()) {
+                       if (one.filter(whitelist, null, null).isEmpty()) {
+                               return false;
+                       }
                }
-
-               if (blacklist.contains(meta.getSource())) {
-                       return false;
+               if (!blacklist.isEmpty()) {
+                       if (!one.filter(blacklist, null, null).isEmpty()) {
+                               return false;
+                       }
                }
 
                return true;
index 97f2f0e8f69c6c07e217e1022ee4aa0fa96eaa4d..3ccdc3d00ec9a4f6e0feeda95682b18363a55c11 100644 (file)
@@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -359,12 +360,16 @@ public class WebLibraryServer extends WebLibraryServerHtml {
        }
 
        private boolean isAllowed(MetaData meta, WLoginResult login) {
-               if (login.isWl() && !whitelist.isEmpty()
-                               && !whitelist.contains(meta.getSource())) {
-                       return false;
+               MetaResultList one = new MetaResultList(Arrays.asList(meta));
+               if (login.isWl() && !whitelist.isEmpty()) {
+                       if (one.filter(whitelist, null, null).isEmpty()) {
+                               return false;
+                       }
                }
-               if (login.isBl() && blacklist.contains(meta.getSource())) {
-                       return false;
+               if (login.isBl() && !blacklist.isEmpty()) {
+                       if (!one.filter(blacklist, null, null).isEmpty()) {
+                               return false;
+                       }
                }
 
                return true;