On 2/22/2017 1:57 PM, Endi Sukma Dewata wrote:
A new PKIApplication class has been added into /pki web application
to define common PKI REST services such as access banner.

https://fedorahosted.org/pki/ticket/2582

Pushed an updated patch to master under trivial rule.

--
Endi S. Dewata
>From a59af865110f04e09121c1743f02b7be628703e4 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edew...@redhat.com>
Date: Wed, 15 Feb 2017 17:50:26 +0100
Subject: [PATCH] Added PKIApplication.

A new PKIApplication class has been added into /pki web application
to define common PKI REST services such as access banner.

https://fedorahosted.org/pki/ticket/2582
---
 base/server/CMakeLists.txt                         | 22 ++++++++++
 .../org/dogtagpki/server/rest/PKIApplication.java  | 50 ++++++++++++++++++++++
 base/server/share/webapps/pki/WEB-INF/web.xml      | 30 +++++++++++++
 3 files changed, 102 insertions(+)
 create mode 100644 base/server/cms/src/org/dogtagpki/server/rest/PKIApplication.java

diff --git a/base/server/CMakeLists.txt b/base/server/CMakeLists.txt
index e0669ca5c0f7d990b8ab8a10f9babf96cf36e4a3..d4aa94a9bea993b8a79628280dee4b73717c7378 100644
--- a/base/server/CMakeLists.txt
+++ b/base/server/CMakeLists.txt
@@ -63,6 +63,21 @@ add_custom_command(
     COMMAND ${CMAKE_COMMAND} -E create_symlink /usr/share/java/xml-commons-resolver.jar common/lib/xml-commons-resolver.jar
 )
 
+# Create /usr/share/pki/server/webapps/pki/WEB-INF/lib. This can be customized for different platforms in RPM spec.
+
+add_custom_target(pki-server-webapp-lib ALL)
+
+add_custom_command(
+    TARGET pki-server-webapp-lib
+    COMMAND ${CMAKE_COMMAND} -E make_directory webapp/lib
+    COMMAND /usr/bin/ln -sf /usr/share/java/pki/pki-nsutil.jar ${CMAKE_CURRENT_BINARY_DIR}/webapp/lib/pki-nsutil.jar
+    COMMAND /usr/bin/ln -sf /usr/share/java/pki/pki-cmsutil.jar ${CMAKE_CURRENT_BINARY_DIR}/webapp/lib/pki-cmsutil.jar
+    COMMAND /usr/bin/ln -sf /usr/share/java/pki/pki-certsrv.jar ${CMAKE_CURRENT_BINARY_DIR}/webapp/lib/pki-certsrv.jar
+    COMMAND /usr/bin/ln -sf /usr/share/java/pki/pki-cms.jar ${CMAKE_CURRENT_BINARY_DIR}/webapp/lib/pki-cms.jar
+    COMMAND /usr/bin/ln -sf /usr/share/java/pki/pki-cmscore.jar ${CMAKE_CURRENT_BINARY_DIR}/webapp/lib/pki-cmscore.jar
+    COMMAND /usr/bin/ln -sf /usr/share/java/pki/pki-cmsbundle.jar ${CMAKE_CURRENT_BINARY_DIR}/webapp/lib/pki-cmsbundle.jar
+)
+
 install(
     DIRECTORY
         ${CMAKE_CURRENT_BINARY_DIR}/common/lib/
@@ -72,6 +87,13 @@ install(
 
 install(
     DIRECTORY
+        ${CMAKE_CURRENT_BINARY_DIR}/webapp/lib/
+    DESTINATION
+        ${DATA_INSTALL_DIR}/server/webapps/pki/WEB-INF/lib
+)
+
+install(
+    DIRECTORY
         man/
     DESTINATION
         ${MAN_INSTALL_DIR}
diff --git a/base/server/cms/src/org/dogtagpki/server/rest/PKIApplication.java b/base/server/cms/src/org/dogtagpki/server/rest/PKIApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..d6ac7939c979d6d491f35094b689746558af1363
--- /dev/null
+++ b/base/server/cms/src/org/dogtagpki/server/rest/PKIApplication.java
@@ -0,0 +1,50 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2017 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package org.dogtagpki.server.rest;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class PKIApplication extends Application {
+
+    private Set<Object> singletons = new LinkedHashSet<Object>();
+    private Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
+
+    public PKIApplication() {
+
+        // services
+
+        // exception mappers
+        classes.add(PKIExceptionMapper.class);
+
+        // interceptors
+        singletons.add(new MessageFormatInterceptor());
+    }
+
+    public Set<Class<?>> getClasses() {
+        return classes;
+    }
+
+    public Set<Object> getSingletons() {
+        return singletons;
+    }
+
+}
diff --git a/base/server/share/webapps/pki/WEB-INF/web.xml b/base/server/share/webapps/pki/WEB-INF/web.xml
index 9afb41825ed80bbd7c59acc8bdbdfe3edeb16f12..aacdffaee4348a36ee155e3d1b2ee989a9d6d1cf 100644
--- a/base/server/share/webapps/pki/WEB-INF/web.xml
+++ b/base/server/share/webapps/pki/WEB-INF/web.xml
@@ -5,6 +5,36 @@
 
     <display-name>PKI</display-name>
 
+    <listener>
+        <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
+    </listener>
+
+    <context-param>
+        <param-name>resteasy.servlet.mapping.prefix</param-name>
+        <param-value>/rest</param-value>
+    </context-param>
+
+    <context-param>
+        <param-name>resteasy.resource.method-interceptors</param-name>
+        <param-value>
+            org.jboss.resteasy.core.ResourceMethodSecurityInterceptor
+        </param-value>
+    </context-param>
+
+    <servlet>
+        <servlet-name>Resteasy</servlet-name>
+        <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.dogtagpki.server.rest.PKIApplication</param-value>
+         </init-param>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>Resteasy</servlet-name>
+        <url-pattern>/rest/*</url-pattern>
+    </servlet-mapping>
+
     <security-constraint>
         <web-resource-collection>
             <web-resource-name>PKI UI</web-resource-name>
-- 
2.9.3

_______________________________________________
Pki-devel mailing list
Pki-devel@redhat.com
https://www.redhat.com/mailman/listinfo/pki-devel

Reply via email to