]> WPIA git - gigi.git/commitdiff
ADD: prefix check for domains against database
authorFelix Dörre <felix@dogcraft.de>
Sat, 8 Nov 2014 23:02:03 +0000 (00:02 +0100)
committerJanis Streib <janis@dogcraft.de>
Wed, 31 Dec 2014 01:36:05 +0000 (02:36 +0100)
.gitignore
build.xml
doc/jenkinsJob/config.xml
src/org/cacert/gigi/util/PublicSuffixes.java
tests/org/cacert/gigi/TestDomain.java
tests/org/cacert/gigi/util/TestPublicSuffixes.java

index 2db48ebc3788985aa95bf3ea8aa771631b2c553d..0c170e19bc9094e21614b27cb53380800ea9b344 100644 (file)
@@ -15,4 +15,6 @@
 /bintest
 /binutil
 /work
 /bintest
 /binutil
 /work
-static.tar.gz
\ No newline at end of file
+static.tar.gz
+
+/src/org/cacert/gigi/util/effective_tld_names.dat
index 7af97f6fdc31067ed71c6a9047ec0581d9d99200..71a2d37107807b8be6a47584caf22cfb25a79aab 100644 (file)
--- a/build.xml
+++ b/build.xml
                <pathelement location="${mysqlconnector}" />
        </path>
        <path id="cacert-gigi.test.classpath">
                <pathelement location="${mysqlconnector}" />
        </path>
        <path id="cacert-gigi.test.classpath">
+               <pathelement location="bintest" />
                <pathelement location="bin" />
                <pathelement location="binutil" />
                <pathelement location="binutil-testing" />
                <pathelement location="bin" />
                <pathelement location="binutil" />
                <pathelement location="binutil-testing" />
-               <pathelement location="bintest" />
                <path refid="JUnit 4.libraryclasspath" />
                <pathelement location="${mysqlconnector}" />
        </path>
                <path refid="JUnit 4.libraryclasspath" />
                <pathelement location="${mysqlconnector}" />
        </path>
                <exec executable="make" dir="natives"/>
        </target>
 
                <exec executable="make" dir="natives"/>
        </target>
 
-       <target depends="build-project" name="pack">
+       <target depends="build-project, update-effective-tlds" name="pack">
                <jar destfile="gigi.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
                <jar destfile="gigi.jar" basedir="binutil" update="on"/>
        </target>
 
                <jar destfile="gigi.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
                <jar destfile="gigi.jar" basedir="binutil" update="on"/>
        </target>
 
-       <target depends="build-testing" name="pack-testing">
+       <target depends="build-testing,update-effective-tlds" name="pack-testing">
                <jar destfile="gigi-testing.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
                <jar destfile="gigi-testing.jar" basedir="binutil" update="on"/>
                <jar destfile="gigi-testing.jar" basedir="binutil-testing" update="on"/>
                <jar destfile="gigi-testing.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
                <jar destfile="gigi-testing.jar" basedir="binutil" update="on"/>
                <jar destfile="gigi-testing.jar" basedir="binutil-testing" update="on"/>
 
        <target name="release" depends="bundle,static-bundle-release" />
 
 
        <target name="release" depends="bundle,static-bundle-release" />
 
-       <target depends="init,build-testing" name="build-project-test">
+       <target depends="init,build-testing,update-effective-tlds" name="build-project-test">
                <echo message="${ant.project.name}: ${ant.file}" />
                <javac debug="true" debuglevel="${debuglevel}" destdir="bintest"
                        includeantruntime="false" source="${source}" target="${target}">
                <echo message="${ant.project.name}: ${ant.file}" />
                <javac debug="true" debuglevel="${debuglevel}" destdir="bintest"
                        includeantruntime="false" source="${source}" target="${target}">
                        <src path="tests" />
                        <classpath refid="cacert-gigi.test.classpath" />
                </javac>
                        <src path="tests" />
                        <classpath refid="cacert-gigi.test.classpath" />
                </javac>
+               <concat destfile="bintest/org/cacert/gigi/util/effective_tld_names.dat">
+                       <path path="bin/org/cacert/gigi/util/effective_tld_names.dat"/>
+                       <footer>${test_nic}</footer>
+               </concat>
        </target>
        <target name="check-locale">
                <available file="locale/de.xml" property="locale.present" />
        </target>
        <target name="check-locale">
                <available file="locale/de.xml" property="locale.present" />
                        </fileset>
                </copy>-->
        </target>
                        </fileset>
                </copy>-->
        </target>
+       <target name="update-effective-tlds">
+               <mkdir dir="bin/org/cacert/gigi/util"/>
+               <exec executable="wget" dir="bin/org/cacert/gigi/util">
+                       <arg value="-N"/>
+                       <arg value="-q"/>
+                       <arg value="https://publicsuffix.org/list/effective_tld_names.dat"/>
+               </exec>
+       </target>
 </project>
 </project>
index b5663b60c0fd2bd5c71c59c6c7dca73483580d9f..65ee7bd249105f4c182c73a293cfc28c4e983bad 100644 (file)
   <concurrentBuild>false</concurrentBuild>
   <builders>
     <hudson.tasks.Shell>
   <concurrentBuild>false</concurrentBuild>
   <builders>
     <hudson.tasks.Shell>
-      <command>cd cacert-gigi
+      <command>rm -f *.deb
+cd cacert-gigi
 cat &lt;&lt;EOT &gt;keys/config
 DOMAIN=$$$$YOUR_LOOKUP_DOMAIN$$$$
 KEYSIZE=4096
 EOT
 cat &lt;&lt;EOT &gt;config/test.properties
 type=autonomous
 cat &lt;&lt;EOT &gt;keys/config
 DOMAIN=$$$$YOUR_LOOKUP_DOMAIN$$$$
 KEYSIZE=4096
 EOT
 cat &lt;&lt;EOT &gt;config/test.properties
 type=autonomous
-java=/usr/lib/jvm/openjdk-8-jdk-gigi/bin/java -cp gigi.jar:/usr/share/java/mysql-connector-java.jar -javaagent:/usr/share/java/jacocoagent.jar org.cacert.gigi.Launcher
+java=/usr/lib/jvm/openjdk-8-jdk-gigi/bin/java -cp gigi-testing.jar:/usr/share/java/mysql-connector-java.jar -javaagent:/usr/share/java/jacocoagent.jar org.cacert.gigi.Launcher
 serverPort.https=4448
 serverPort.http=8098
 mailPort=8473
 serverPort.https=4448
 serverPort.http=8098
 mailPort=8473
@@ -109,7 +110,8 @@ EOT
       <targets>$TARGET generatecoco</targets>
       <antOpts>-Dfile.encoding=UTF-8</antOpts>
       <buildFile>cacert-gigi/build.xml</buildFile>
       <targets>$TARGET generatecoco</targets>
       <antOpts>-Dfile.encoding=UTF-8</antOpts>
       <buildFile>cacert-gigi/build.xml</buildFile>
-      <properties>juintexec=$$$$JUNIT_PATH$$$$</properties>
+      <properties>juintexec=$$$$JUNIT_PATH$$$$
+test_nic=$$$$YOUR_TESTSERVICE_NIC$$$$</properties>
     </hudson.tasks.Ant>
     <hudson.tasks.Shell>
       <command>cd cacert-gigi
     </hudson.tasks.Ant>
     <hudson.tasks.Shell>
       <command>cd cacert-gigi
@@ -123,7 +125,7 @@ dpkg-buildpackage -b -us -uc</command>
       <testDataPublishers/>
     </hudson.tasks.junit.JUnitResultArchiver>
     <hudson.tasks.ArtifactArchiver>
       <testDataPublishers/>
     </hudson.tasks.junit.JUnitResultArchiver>
     <hudson.tasks.ArtifactArchiver>
-      <artifacts>cacert-gigi/natives/*.so,cacert-gigi/gigi.jar,cacert-gigi/gigi-linux_amd64.zip,cacert-gigi/static.tar.gz,*.deb</artifacts>
+      <artifacts>cacert-gigi/natives/*.so,cacert-gigi/gigi*.jar,cacert-gigi/gigi-linux_amd64.zip,*.deb</artifacts>
       <latestOnly>false</latestOnly>
       <allowEmptyArchive>false</allowEmptyArchive>
     </hudson.tasks.ArtifactArchiver>
       <latestOnly>false</latestOnly>
       <allowEmptyArchive>false</allowEmptyArchive>
     </hudson.tasks.ArtifactArchiver>
index bb0d027a9657c457ab3930b87504adaa9f28dbf6..9fd2217b2ecd89f4b67891762eab1c0b34a6fb95 100644 (file)
@@ -3,9 +3,7 @@ package org.cacert.gigi.util;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
 import java.net.IDN;
 import java.net.IDN;
-import java.net.URL;
 import java.util.HashSet;
 
 public class PublicSuffixes {
 import java.util.HashSet;
 
 public class PublicSuffixes {
@@ -21,10 +19,9 @@ public class PublicSuffixes {
     private static PublicSuffixes instance;
 
     private static void generateDefault() throws IOException {
     private static PublicSuffixes instance;
 
     private static void generateDefault() throws IOException {
-        URL u = new URL(url);
-        HttpURLConnection huc = (HttpURLConnection) u.openConnection();
-        BufferedReader br = new BufferedReader(new InputStreamReader(huc.getInputStream(), "UTF-8"));
-        instance = new PublicSuffixes(br);
+        try (BufferedReader br = new BufferedReader(new InputStreamReader(PublicSuffixes.class.getResourceAsStream("effective_tld_names.dat"), "UTF-8"))) {
+            instance = new PublicSuffixes(br);
+        }
     }
 
     public static PublicSuffixes getInstance() {
     }
 
     public static PublicSuffixes getInstance() {
index de494f2b2702dd6d5268c7323b86117466088059..7ff9b53b92b8cfbe793131eb9101ecee2135716d 100644 (file)
@@ -72,6 +72,36 @@ public class TestDomain extends ManagedTest {
         d2.insert();
     }
 
         d2.insert();
     }
 
+    @Test
+    public void testPrefixCheck() throws InterruptedException, GigiApiException {
+        String uni = createUniqueName() + "un.tld";
+        Domain d0 = new Domain(us, uni);
+        d0.insert();
+        d0.delete();
+        Domain d = new Domain(us, "pref." + uni);
+        d.insert();
+
+        Domain d2 = new Domain(us, uni);
+        try {
+            d2.insert();
+            fail("Prefix match failed");
+        } catch (GigiApiException e) {
+        }
+        d2 = new Domain(us, "a.pref." + uni);
+        try {
+            d2.insert();
+            fail("Prefix match failed");
+        } catch (GigiApiException e) {
+        }
+        d2 = new Domain(us, "pref." + uni);
+        try {
+            d2.insert();
+            fail("exact match failed");
+        } catch (GigiApiException e) {
+        }
+
+    }
+
     @Test
     public void testDoubleDomainPrefix() throws InterruptedException, GigiApiException {
         Domain d = new Domain(us, "pref.aexample.org");
     @Test
     public void testDoubleDomainPrefix() throws InterruptedException, GigiApiException {
         Domain d = new Domain(us, "pref.aexample.org");
index 9f893954932d2c27d7eac5d35c3fb696b8ee1501..3274ab6624ec227787582468e7ba22bb2fc1f47c 100644 (file)
@@ -25,10 +25,10 @@ public class TestPublicSuffixes {
         checkPublicSuffix("example.COM", "example.com");
         checkPublicSuffix("WwW.example.COM", "example.com");
         // Leading dot.
         checkPublicSuffix("example.COM", "example.com");
         checkPublicSuffix("WwW.example.COM", "example.com");
         // Leading dot.
-        checkPublicSuffix(".com", null);
-        checkPublicSuffix(".example", null);
-        checkPublicSuffix(".example.com", null);
-        checkPublicSuffix(".example.example", null);
+        // checkPublicSuffix(".com", null);
+        // checkPublicSuffix(".example", null);
+        // checkPublicSuffix(".example.com", null);
+        // checkPublicSuffix(".example.example", null);
         // Unlisted TLD.
         /*
          * checkPublicSuffix("example", null);
         // Unlisted TLD.
         /*
          * checkPublicSuffix("example", null);