X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FLauncher.java;h=87c215cc3b87d0b31084e1f51f9c051c5aa21040;hp=41b09ffb6a4a04736bf6316fe4ad1c89dd6ba666;hb=fc2fcf0b35bf4cde8f4a9c7243de3306e8b4b55b;hpb=86074c17c59d504912389d7caa006e27714abdec diff --git a/src/org/cacert/gigi/Launcher.java b/src/org/cacert/gigi/Launcher.java index 41b09ffb..87c215cc 100644 --- a/src/org/cacert/gigi/Launcher.java +++ b/src/org/cacert/gigi/Launcher.java @@ -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() {