diff --git a/source/de/anomic/soap/services/BlacklistService.java b/source/de/anomic/soap/services/BlacklistService.java index e4b2bc04c..d3efd875d 100644 --- a/source/de/anomic/soap/services/BlacklistService.java +++ b/source/de/anomic/soap/services/BlacklistService.java @@ -52,6 +52,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; +import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -67,7 +68,10 @@ import org.apache.axis.attachments.Attachments; import org.w3c.dom.Document; import de.anomic.data.listManager; +import de.anomic.http.httpd; +import de.anomic.net.URL; import de.anomic.plasma.plasmaSwitchboard; +import de.anomic.plasma.urlPattern.plasmaURLPattern; import de.anomic.server.serverObjects; import de.anomic.soap.AbstractService; @@ -85,8 +89,25 @@ public class BlacklistService extends AbstractService { private static final String TEMPLATE_BLACKLIST_XML = "xml/blacklists_p.xml"; - - + public boolean urlIsBlacklisted(String blacklistType, String urlString) throws AxisFault, MalformedURLException { + if (blacklistType == null || blacklistType.length() == 0) throw new IllegalArgumentException("The blacklist type must not be null or empty."); + if (urlString == null || urlString.length() == 0) throw new IllegalArgumentException("The url must not be null or empty."); + + // extracting the message context + extractMessageContext(AUTHENTICATION_NEEDED); + + // check if we know all type passed to this function + checkForKnownBlacklistTypes(new String[]{blacklistType}); + + // check for url validity + URL url = new URL(urlString); + String hostlow = url.getHost().toLowerCase(); + String file = url.getFile(); + + // check if the specified url is listed + return (plasmaSwitchboard.urlBlacklist.isListed(plasmaURLPattern.BLACKLIST_PROXY, hostlow, file)); + } + public Document getBlacklistList() throws Exception { try { // extracting the message context diff --git a/source/de/anomic/soap/services/blacklist.wsdl b/source/de/anomic/soap/services/blacklist.wsdl index cf8557af4..2a1e21722 100644 --- a/source/de/anomic/soap/services/blacklist.wsdl +++ b/source/de/anomic/soap/services/blacklist.wsdl @@ -1,85 +1,97 @@ - + - - - + - + + + - - - + + + - - + + - - + + + - - - + + + - + + - + + + + + - - + - + + + + + + - + - - + - - + + + - + - - - + - - - + + + + + - + - + + - - + - - - - + - - + + + + + + + + - @@ -87,9 +99,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -97,9 +109,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -107,9 +119,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -117,9 +129,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -127,19 +139,29 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - + + + + + + + + + + + - @@ -147,9 +169,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -157,9 +179,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -167,9 +189,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -177,9 +199,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -187,9 +209,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -197,9 +219,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -207,9 +229,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -217,9 +239,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -227,9 +249,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -237,9 +259,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -247,9 +269,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -257,7 +279,7 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - \ No newline at end of file diff --git a/test/de/anomic/soap/services/BlacklistServiceTest.java b/test/de/anomic/soap/services/BlacklistServiceTest.java index a22431b60..29e4063c2 100644 --- a/test/de/anomic/soap/services/BlacklistServiceTest.java +++ b/test/de/anomic/soap/services/BlacklistServiceTest.java @@ -8,9 +8,7 @@ import javax.activation.DataSource; import javax.xml.rpc.ServiceException; import org.apache.axis.attachments.AttachmentPart; -import org.apache.axis.attachments.Attachments; import org.apache.axis.attachments.PlainTextDataSource; -import org.apache.axis.client.Call; import org.apache.axis.client.Stub; import org.apache.axis.utils.XMLUtils; import org.w3c.dom.Document; @@ -32,7 +30,7 @@ public class BlacklistServiceTest extends AbstractServiceTest { Document xml = ((BlacklistService)service).getBlacklistList(); System.out.println(XMLUtils.DocumentToString(xml)); } - + public void testBlacklist() throws RemoteException { BlacklistService bl = ((BlacklistService)service); @@ -54,9 +52,13 @@ public class BlacklistServiceTest extends AbstractServiceTest { bl.addBlacklistItem(blacklistName,item); // getting the blacklist list - Document xml = ((BlacklistService)service).getBlacklistList(); + Document xml = bl.getBlacklistList(); System.out.println(XMLUtils.DocumentToString(xml)); + // test is listed + boolean isListed = bl.urlIsBlacklisted("proxy","http://www.yacy.net/blacklisttest"); + assertEquals(true,isListed); + // remove blacklist item bl.removeBlacklistItem(blacklistName,item);