From: Niki Roo Date: Thu, 14 May 2020 08:13:25 +0000 (+0200) Subject: weblib/remlib: white/black lists: allow sources with / X-Git-Url: http://git.nikiroo.be/?a=commitdiff_plain;h=5c4ce687a0510cef279bcba66be79b0e053396b9;p=fanfix-swing.git weblib/remlib: white/black lists: allow sources with / --- diff --git a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java index e54f105d..59819bb9 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java @@ -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 whitelist, List 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; diff --git a/src/be/nikiroo/fanfix/library/WebLibraryServer.java b/src/be/nikiroo/fanfix/library/WebLibraryServer.java index 97f2f0e8..3ccdc3d0 100644 --- a/src/be/nikiroo/fanfix/library/WebLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/WebLibraryServer.java @@ -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;