directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zheng, Kai" <kai.zh...@intel.com>
Subject RE: [1/2] directory-kerby git commit: Embed Jetty in Kerby KDC - initially work.
Date Wed, 09 Dec 2015 05:05:13 GMT
Hi Lin,

Thanks a lot for initiating the work. The initial code looks pretty good. Hope your school
days are happy!

Regards,
Kai

-----Original Message-----
From: hazel@apache.org [mailto:hazel@apache.org] 
Sent: Sunday, December 06, 2015 10:55 PM
To: commits@directory.apache.org
Subject: [1/2] directory-kerby git commit: Embed Jetty in Kerby KDC - initially work.

Repository: directory-kerby
Updated Branches:
  refs/heads/jetty-embedded [created] 6b72f249f


Embed Jetty in Kerby KDC - initially work.


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/65049ae3
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/65049ae3
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/65049ae3

Branch: refs/heads/jetty-embedded
Commit: 65049ae3c96ae01d772e6667ad8ca040c41b29f3
Parents: 1d93856
Author: Lin <linchen7@foxmail.com>
Authored: Sun Dec 6 22:53:07 2015 +0800
Committer: Lin <linchen7@foxmail.com>
Committed: Sun Dec 6 22:53:07 2015 +0800

----------------------------------------------------------------------
 kerby-kdc/pom.xml                               | 42 ++++++++++++++++++++
 .../kerby/kerberos/kdc/KerbyKdcServer.java      | 29 ++++++++++++++
 .../kerberos/kdc/jetty/services/HelloJetty.java | 36 +++++++++++++++++
 3 files changed, 107 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/65049ae3/kerby-kdc/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-kdc/pom.xml b/kerby-kdc/pom.xml index ed222ec..97d50ab6 100644
--- a/kerby-kdc/pom.xml
+++ b/kerby-kdc/pom.xml
@@ -26,6 +26,11 @@
   <description>Kerby KDC Server</description>
   <packaging>jar</packaging>
 
+  <properties>
+    <jetty.version>9.3.6.v20151106</jetty.version>
+    <jersey.version>2.22.1</jersey.version>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>org.apache.kerby</groupId>
@@ -62,5 +67,42 @@
       <artifactId>slf4j-api</artifactId>
       <version>${slf4j.version}</version>
     </dependency>
+
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-server</artifactId>
+      <version>${jetty.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlet</artifactId>
+      <version>${jetty.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-util</artifactId>
+      <version>${jetty.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.glassfish.jersey.core</groupId>
+      <artifactId>jersey-server</artifactId>
+      <version>${jersey.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.glassfish.jersey.containers</groupId>
+      <artifactId>jersey-container-servlet-core</artifactId>
+      <version>${jersey.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.glassfish.jersey.containers</groupId>
+      <artifactId>jersey-container-jetty-http</artifactId>
+      <version>${jersey.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.glassfish.jersey.media</groupId>
+      <artifactId>jersey-media-moxy</artifactId>
+      <version>${jersey.version}</version>
+    </dependency>
   </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/65049ae3/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/KerbyKdcServer.java
----------------------------------------------------------------------
diff --git a/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/KerbyKdcServer.java b/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/KerbyKdcServer.java
index ac789b5..bbc6951 100644
--- a/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/KerbyKdcServer.java
+++ b/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/KerbyKdcServ
+++ er.java
@@ -20,11 +20,17 @@
 package org.apache.kerby.kerberos.kdc;
 
 import org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl;
+import org.apache.kerby.kerberos.kdc.jetty.services.HelloJetty;
 import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.kerberos.kerb.admin.Kadmin;
 import org.apache.kerby.kerberos.kerb.server.KdcServer;
 import org.apache.kerby.util.OSUtil;
 
+import org.eclipse.jetty.server.Server; import 
+org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.glassfish.jersey.servlet.ServletContainer;
+
 import java.io.File;
 
 /**
@@ -89,5 +95,28 @@ public class KerbyKdcServer extends KdcServer {
 
         server.start();
         System.out.println("KDC started.");
+
+        initJettyServer();
+    }
+
+    private static void initJettyServer() {
+        ServletHolder servletHolder = new ServletHolder(ServletContainer.class);
+        servletHolder.setInitParameter("jersey.config.server.provider.classnames",
+                HelloJetty.class.getCanonicalName());
+
+        Server jettyServer = new Server(8080);
+        ServletContextHandler context = new ServletContextHandler(jettyServer, "/", ServletContextHandler.SESSIONS);
+        context.addServlet(servletHolder, "/*");
+
+        try {
+            jettyServer.start();
+            jettyServer.join();
+            System.out.println("Jetty server started.");
+        } catch (Exception e) {
+            System.out.println("Errors occurred when start jetty server:  " + e.getMessage());
+            System.exit(5);
+        } finally {
+            jettyServer.destroy();
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/65049ae3/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/jetty/services/HelloJetty.java
----------------------------------------------------------------------
diff --git a/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/jetty/services/HelloJetty.java
b/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/jetty/services/HelloJetty.java
new file mode 100644
index 0000000..f70f18e
--- /dev/null
+++ b/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/jetty/servic
+++ es/HelloJetty.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kerby.kerberos.kdc.jetty.services;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("/hello")
+public class HelloJetty {
+
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String getHello() {
+        return "Hello Kerby KDC!";
+    }
+
+
+}


Mime
View raw message