Adding stub for gigi-api (api.gigi.org)
authorFelix Dörre <felix@dogcraft.de>
Thu, 3 Jul 2014 19:53:37 +0000 (21:53 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 3 Jul 2014 19:53:37 +0000 (21:53 +0200)
config/gigi.properties.template
config/test.properties.template
src/org/cacert/gigi/Launcher.java
src/org/cacert/gigi/api/GigiAPI.java [new file with mode: 0644]
src/org/cacert/gigi/util/ServerConstants.java

index b37825f3e27f820dd6f25efa07d42f8a5ab6919b..b091faf76a27ed1d15ea6a75b90174c071953a54 100644 (file)
@@ -2,6 +2,8 @@ host=127.0.0.1
 name.static=static.cacert.local
 name.secure=secure.cacert.local
 name.www=www.cacert.local
+name.api=api.cacert.local
+
 port=443
 #emailProvider=org.cacert.gigi.email.Sendmail
 emailProvider=org.cacert.gigi.email.CommandlineEmailProvider
index 01a83dfc51ecedf96dbe1aae89a1cbbd3d565608..703bda1066c2305435905a751a3619fb21904bb0 100644 (file)
@@ -15,6 +15,7 @@ mailPort=8473
 name.static=static.cacert.local
 name.secure=secure.cacert.local
 name.www=www.cacert.local
+name.api=api.cacert.local
 sql.driver=com.mysql.jdbc.Driver
 sql.url=jdbc:mysql://localhost:3306/cacert
 sql.user=cacert
index 41b09ffb6a4a04736bf6316fe4ad1c89dd6ba666..87c215cc3b87d0b31084e1f51f9c051c5aa21040 100644 (file)
@@ -12,6 +12,7 @@ import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLParameters;
 import javax.net.ssl.SSLSession;
 
+import org.cacert.gigi.api.GigiAPI;
 import org.cacert.gigi.natives.SetUID;
 import org.cacert.gigi.util.CipherInfo;
 import org.cacert.gigi.util.ServerConstants;
@@ -58,7 +59,7 @@ public class Launcher {
 
                HandlerList hl = new HandlerList();
                hl.setHandlers(new Handler[]{generateStaticContext(),
-                               generateGigiContext(conf.getMainProps())});
+                               generateGigiContext(conf.getMainProps()), generateAPIContext()});
                s.setHandler(hl);
                s.start();
                if (connector.getPort() <= 1024
@@ -79,9 +80,12 @@ public class Launcher {
                secureContextFactory.setNeedClientAuth(true);
                final SslContextFactory staticContextFactory = generateSSLContextFactory(
                                conf, "static");
+               final SslContextFactory apiContextFactory = generateSSLContextFactory(
+                               conf, "api");
                try {
                        secureContextFactory.start();
                        staticContextFactory.start();
+                       apiContextFactory.start();
                } catch (Exception e) {
                        e.printStackTrace();
                }
@@ -107,6 +111,8 @@ public class Launcher {
                                                                e2 = staticContextFactory.newSSLEngine();
                                                        } else if (hostname.equals("secure.cacert.local")) {
                                                                e2 = secureContextFactory.newSSLEngine();
+                                                       } else if (hostname.equals("api.cacert.local")) {
+                                                               e2 = apiContextFactory.newSSLEngine();
                                                        }
                                                        break;
                                                }
@@ -157,6 +163,14 @@ public class Launcher {
                return ch;
        }
 
+       private static Handler generateAPIContext() {
+               ServletContextHandler sch = new ServletContextHandler();
+
+               sch.addVirtualHosts(new String[]{ServerConstants.getApiHostName()});
+               sch.addServlet(new ServletHolder(new GigiAPI()), "/*");
+               return sch;
+       }
+
        private static SslContextFactory generateSSLContextFactory(GigiConfig conf,
                        String alias) throws GeneralSecurityException, IOException {
                SslContextFactory scf = new SslContextFactory() {
diff --git a/src/org/cacert/gigi/api/GigiAPI.java b/src/org/cacert/gigi/api/GigiAPI.java
new file mode 100644 (file)
index 0000000..74cff96
--- /dev/null
@@ -0,0 +1,19 @@
+package org.cacert.gigi.api;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class GigiAPI extends HttpServlet {
+       @Override
+       protected void service(HttpServletRequest req, HttpServletResponse resp)
+                       throws ServletException, IOException {
+               String pi = req.getPathInfo();
+               if (pi == null) {
+                       return;
+               }
+       }
+}
index 28a52eb4e924332fc9726ed35473209fac42ac31..2f22d4396b4a38abfe26ed99149a4b1849ae8317 100644 (file)
@@ -6,6 +6,7 @@ public class ServerConstants {
        private static String wwwHostName = "www.cacert.local";
        private static String secureHostName = "secure.cacert.local";
        private static String staticHostName = "static.cacert.local";
+       private static String apiHostName = "api.cacert.local";
        private static String port;
        public static void init(Properties conf) {
                port = "";
@@ -15,6 +16,7 @@ public class ServerConstants {
                wwwHostName = conf.getProperty("name.www");
                secureHostName = conf.getProperty("name.secure");
                staticHostName = conf.getProperty("name.static");
+               apiHostName = conf.getProperty("name.api");
        }
        public static String getSecureHostName() {
                return secureHostName;
@@ -25,6 +27,9 @@ public class ServerConstants {
        public static String getWwwHostName() {
                return wwwHostName;
        }
+       public static String getApiHostName() {
+               return apiHostName;
+       }
        public static String getSecureHostNamePort() {
                return secureHostName + port;
        }
@@ -34,5 +39,8 @@ public class ServerConstants {
        public static String getWwwHostNamePort() {
                return wwwHostName + port;
        }
+       public static String getApiHostNamePort() {
+               return apiHostName + port;
+       }
 
 }