From bf3722d35e44eda25d92b358592cbb8a2415364d Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 5 Jul 2023 10:20:29 -0500 Subject: [PATCH] Split pki-tomcat.jar Previously CMake stored both generic Tomcat and Tomcat 9.0-specific classes into a single JAR file. To simplify the transition to Maven the CMake scripts have been updated to store those classes into separate JAR files. PKI server code has also been updated to use both JAR files. Currently PKI code has direct dependencies on Tomcat 9.0 classes. To simplify the transition to newer Tomcat versions the code needs to be refactored to use generic Tomcat classes at compile time, then use version-specific classes at runtime. This can be done separately in the future. --- base/CMakeLists.txt | 9 ++-- base/acme/CMakeLists.txt | 9 ++-- base/ca/CMakeLists.txt | 7 +-- base/est/CMakeLists.txt | 5 +- base/kra/CMakeLists.txt | 4 +- base/ocsp/CMakeLists.txt | 4 +- base/server/CMakeLists.txt | 6 ++- base/server/python/pki/server/instance.py | 3 +- base/tks/CMakeLists.txt | 4 +- base/tomcat-9.0/CMakeLists.txt | 27 +++++----- .../src/main/resources/META-INF/MANIFEST.MF | 2 +- base/tomcat/CMakeLists.txt | 50 +++++++++++++++++++ .../src/main/resources/META-INF/MANIFEST.MF | 3 ++ base/tps/CMakeLists.txt | 4 +- build.sh | 3 +- pki.spec | 1 + 16 files changed, 102 insertions(+), 39 deletions(-) create mode 100644 base/tomcat/CMakeLists.txt create mode 100644 base/tomcat/src/main/resources/META-INF/MANIFEST.MF diff --git a/base/CMakeLists.txt b/base/CMakeLists.txt index d0e2edf2e58..55d88294000 100644 --- a/base/CMakeLists.txt +++ b/base/CMakeLists.txt @@ -420,6 +420,7 @@ add_subdirectory(tools) if(WITH_SERVER OR WITH_CA OR WITH_KRA OR WITH_OCSP OR WITH_TKS OR WITH_TPS OR WITH_ACME OR WITH_EST) + add_subdirectory(tomcat) add_subdirectory(${APP_SERVER}) add_subdirectory(server) add_subdirectory(server-webapp) @@ -431,12 +432,12 @@ if(WITH_SERVER OR WITH_CA OR WITH_KRA OR WITH_OCSP OR WITH_TKS OR WITH_TPS OR WI com.netscape.cms) list(APPEND PKI_JAVADOC_CLASSPATH - ${PKI_SERVER_JAR} - ${PKI_TOMCAT_JAR}) + ${PKI_TOMCAT_JAR} + ${PKI_TOMCAT_9_0_JAR} + ${PKI_SERVER_JAR}) list(APPEND PKI_JAVADOC_DEPENDS - pki-server-jar - pki-tomcat-jar) + pki-server-jar) if(WITH_CA) add_subdirectory(ca) diff --git a/base/acme/CMakeLists.txt b/base/acme/CMakeLists.txt index 201a752e253..22325587a7a 100644 --- a/base/acme/CMakeLists.txt +++ b/base/acme/CMakeLists.txt @@ -14,11 +14,14 @@ javac(pki-acme-classes ${JACKSON2_CORE_JAR} ${JACKSON2_DATABIND_JAR} ${JSS_JAR} ${LDAPJDK_JAR} - ${PKI_COMMON_JAR} ${PKI_SERVER_JAR} ${PKI_TOMCAT_JAR} - DEPENDS - pki-common-jar pki-server-jar + ${PKI_COMMON_JAR} + ${PKI_TOMCAT_JAR} + ${PKI_TOMCAT_9_0_JAR} + ${PKI_SERVER_JAR} OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/classes + DEPENDS + pki-server-jar ) set(PKI_ACME_JAR ${CMAKE_BINARY_DIR}/dist/pki-acme.jar diff --git a/base/ca/CMakeLists.txt b/base/ca/CMakeLists.txt index d8ed52ce673..9a0998e1399 100644 --- a/base/ca/CMakeLists.txt +++ b/base/ca/CMakeLists.txt @@ -5,8 +5,6 @@ add_subdirectory(${APP_SERVER}) # build pki-ca javac(pki-ca-classes - DEPENDS - pki-common-jar pki-server-jar SOURCES src/main/java/*.java CLASSPATH @@ -27,10 +25,13 @@ javac(pki-ca-classes ${TOMCATJSS_TOMCAT_9_0_JAR} ${JAXRS_API_JAR} ${RESTEASY_JAXRS_JAR} ${PKI_COMMON_JAR} - ${PKI_SERVER_JAR} ${PKI_TOMCAT_JAR} + ${PKI_TOMCAT_9_0_JAR} + ${PKI_SERVER_JAR} OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/classes + DEPENDS + pki-server-jar ) set(PKI_CA_JAR ${CMAKE_BINARY_DIR}/dist/pki-ca.jar diff --git a/base/est/CMakeLists.txt b/base/est/CMakeLists.txt index 5e123059e20..77e338936ae 100644 --- a/base/est/CMakeLists.txt +++ b/base/est/CMakeLists.txt @@ -17,10 +17,11 @@ javac(pki-est-classes ${JSS_JAR} ${PKI_CMSUTIL_JAR} ${PKI_COMMON_JAR} - ${PKI_SERVER_JAR} ${PKI_TOMCAT_JAR} + ${PKI_TOMCAT_9_0_JAR} + ${PKI_SERVER_JAR} DEPENDS - pki-common-jar pki-server-jar + pki-server-jar OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/classes ) diff --git a/base/kra/CMakeLists.txt b/base/kra/CMakeLists.txt index 37e190f428f..480a3f98846 100644 --- a/base/kra/CMakeLists.txt +++ b/base/kra/CMakeLists.txt @@ -5,8 +5,6 @@ add_subdirectory(${APP_SERVER}) # build pki-kra javac(pki-kra-classes - DEPENDS - pki-common-jar pki-server-jar SOURCES src/main/java/*.java CLASSPATH @@ -23,6 +21,8 @@ javac(pki-kra-classes ${PKI_COMMON_JAR} ${PKI_SERVER_JAR} ${TOMCAT_CATALINA_JAR} OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/classes + DEPENDS + pki-server-jar ) set(PKI_KRA_JAR ${CMAKE_BINARY_DIR}/dist/pki-kra.jar diff --git a/base/ocsp/CMakeLists.txt b/base/ocsp/CMakeLists.txt index c4f2bbf1311..9816054f231 100644 --- a/base/ocsp/CMakeLists.txt +++ b/base/ocsp/CMakeLists.txt @@ -5,8 +5,6 @@ add_subdirectory(${APP_SERVER}) # build pki-ocsp javac(pki-ocsp-classes - DEPENDS - pki-common-jar pki-server-jar SOURCES src/main/java/*.java CLASSPATH @@ -24,6 +22,8 @@ javac(pki-ocsp-classes ${PKI_SERVER_JAR} OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/classes + DEPENDS + pki-server-jar ) set(PKI_OCSP_JAR ${CMAKE_BINARY_DIR}/dist/pki-ocsp.jar diff --git a/base/server/CMakeLists.txt b/base/server/CMakeLists.txt index f7292ac5174..fb359438cb6 100644 --- a/base/server/CMakeLists.txt +++ b/base/server/CMakeLists.txt @@ -4,8 +4,6 @@ add_subdirectory(healthcheck) # build server classes javac(pki-server-classes - DEPENDS - pki-common-jar pki-tools-jar pki-tomcat-jar SOURCES src/main/java/*.java CLASSPATH @@ -24,8 +22,11 @@ javac(pki-server-classes ${JAXRS_API_JAR} ${RESTEASY_JAXRS_JAR} ${PKI_COMMON_JAR} ${PKI_TOMCAT_JAR} + ${PKI_TOMCAT_9_0_JAR} OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/classes + DEPENDS + pki-common-jar pki-tools-jar pki-tomcat-jar pki-tomcat-9.0-jar ) set(PKI_SERVER_JAR ${CMAKE_BINARY_DIR}/dist/pki-server.jar @@ -140,6 +141,7 @@ add_custom_command( COMMAND ln -sf ../../../../../..${LDAPJDK_JAR} common/lib/ldapjdk.jar COMMAND ln -sf ../../../../../..${JAVA_JAR_INSTALL_DIR}/pki/pki-common.jar common/lib/pki-common.jar COMMAND ln -sf ../../../../../..${JAVA_JAR_INSTALL_DIR}/pki/pki-tomcat.jar common/lib/pki-tomcat.jar + COMMAND ln -sf ../../../../../..${JAVA_JAR_INSTALL_DIR}/pki/pki-tomcat-9.0.jar common/lib/pki-tomcat-9.0.jar COMMAND ln -sf ../../../../../..${RESTEASY_CLIENT_JAR} common/lib/resteasy-client.jar COMMAND ln -sf ../../../../../..${RESTEASY_JACKSON2_PROVIDER_JAR} common/lib/resteasy-jackson2-provider.jar COMMAND ln -sf ../../../../../..${RESTEASY_JAXRS_JAR} common/lib/resteasy-jaxrs.jar diff --git a/base/server/python/pki/server/instance.py b/base/server/python/pki/server/instance.py index 4446d7d51cb..df986790f25 100644 --- a/base/server/python/pki/server/instance.py +++ b/base/server/python/pki/server/instance.py @@ -346,7 +346,8 @@ def create_libs(self, force=False): 'tomcatjss-core.jar', 'tomcatjss-tomcat-9.0.jar', 'pki-common.jar', - 'pki-tomcat.jar']: + 'pki-tomcat.jar', + 'pki-tomcat-9.0.jar']: source = os.path.join(common_lib_dir, filename) dest = os.path.join(self.common_lib_dir, filename) diff --git a/base/tks/CMakeLists.txt b/base/tks/CMakeLists.txt index b35176f5160..a1be005f966 100644 --- a/base/tks/CMakeLists.txt +++ b/base/tks/CMakeLists.txt @@ -5,8 +5,6 @@ add_subdirectory(${APP_SERVER}) # build pki-tks javac(pki-tks-classes - DEPENDS - pki-common-jar pki-server-jar SOURCES src/main/java/*.java CLASSPATH @@ -25,6 +23,8 @@ javac(pki-tks-classes ${PKI_COMMON_JAR} ${PKI_SERVER_JAR} OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/classes + DEPENDS + pki-server-jar ) set(PKI_TKS_JAR ${CMAKE_BINARY_DIR}/dist/pki-tks.jar CACHE INTERNAL "pki-tks.jar") diff --git a/base/tomcat-9.0/CMakeLists.txt b/base/tomcat-9.0/CMakeLists.txt index 2facd8a1759..9b589d39b4b 100644 --- a/base/tomcat-9.0/CMakeLists.txt +++ b/base/tomcat-9.0/CMakeLists.txt @@ -1,9 +1,7 @@ project(pki-tomcat-9.0) -# build pki-tomcat -javac(pki-tomcat-classes +javac(pki-tomcat-9.0-classes SOURCES - ../tomcat/src/main/java/*.java src/main/java/*.java CLASSPATH ${SERVLET_JAR} @@ -16,10 +14,15 @@ javac(pki-tomcat-classes ${TOMCATJSS_CORE_JAR} ${TOMCATJSS_TOMCAT_9_0_JAR} ${PKI_COMMON_JAR} + ${PKI_TOMCAT_JAR} OUTPUT_DIR - ${CMAKE_BINARY_DIR}/../tomcat + ${CMAKE_BINARY_DIR}/classes DEPENDS - pki-common-jar + pki-tomcat-jar +) + +set(PKI_TOMCAT_9_0_JAR ${CMAKE_BINARY_DIR}/dist/pki-tomcat-9.0.jar + CACHE INTERNAL "pki-tomcat-9.0.jar" ) configure_file( @@ -27,26 +30,22 @@ configure_file( ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST.MF ) -set(PKI_TOMCAT_JAR ${CMAKE_BINARY_DIR}/dist/pki-tomcat.jar - CACHE INTERNAL "pki-tomcat.jar" -) - -jar(pki-tomcat-jar +jar(pki-tomcat-9.0-jar CREATE - ${PKI_TOMCAT_JAR} + ${PKI_TOMCAT_9_0_JAR} OPTIONS m PARAMS ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST.MF INPUT_DIR - ${CMAKE_BINARY_DIR}/../tomcat + ${CMAKE_BINARY_DIR}/classes DEPENDS - pki-tomcat-classes + pki-tomcat-9.0-classes ) install( FILES - ${PKI_TOMCAT_JAR} + ${PKI_TOMCAT_9_0_JAR} DESTINATION ${JAVA_JAR_INSTALL_DIR}/pki ) diff --git a/base/tomcat-9.0/src/main/resources/META-INF/MANIFEST.MF b/base/tomcat-9.0/src/main/resources/META-INF/MANIFEST.MF index 021eb0d857b..98ac14f2518 100644 --- a/base/tomcat-9.0/src/main/resources/META-INF/MANIFEST.MF +++ b/base/tomcat-9.0/src/main/resources/META-INF/MANIFEST.MF @@ -1,3 +1,3 @@ -Name: pki-tomcat +Name: pki-tomcat-9.0 Specification-Version: ${APPLICATION_VERSION} Implementation-Version: ${IMPL_VERSION} diff --git a/base/tomcat/CMakeLists.txt b/base/tomcat/CMakeLists.txt new file mode 100644 index 00000000000..23f0d74bd51 --- /dev/null +++ b/base/tomcat/CMakeLists.txt @@ -0,0 +1,50 @@ +project(pki-tomcat) + +javac(pki-tomcat-classes + SOURCES + src/main/java/*.java + CLASSPATH + ${SERVLET_JAR} + ${JAXRS_API_JAR} + ${JASPIC_API_JAR} + ${COMMONS_LANG3_JAR} + ${TOMCAT_API_JAR} ${TOMCAT_CATALINA_JAR} ${TOMCAT_COYOTE_JAR} ${TOMCAT_UTIL_SCAN_JAR} + ${SLF4J_API_JAR} + ${JSS_JAR} + ${TOMCATJSS_CORE_JAR} + ${TOMCATJSS_TOMCAT_9_0_JAR} + ${PKI_COMMON_JAR} + OUTPUT_DIR + ${CMAKE_BINARY_DIR}/classes + DEPENDS + pki-common-jar +) + +set(PKI_TOMCAT_JAR ${CMAKE_BINARY_DIR}/dist/pki-tomcat.jar + CACHE INTERNAL "pki-tomcat.jar" +) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/src/main/resources/META-INF/MANIFEST.MF + ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST.MF +) + +jar(pki-tomcat-jar + CREATE + ${PKI_TOMCAT_JAR} + OPTIONS + m + PARAMS + ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST.MF + INPUT_DIR + ${CMAKE_BINARY_DIR}/classes + DEPENDS + pki-tomcat-classes +) + +install( + FILES + ${PKI_TOMCAT_JAR} + DESTINATION + ${JAVA_JAR_INSTALL_DIR}/pki +) diff --git a/base/tomcat/src/main/resources/META-INF/MANIFEST.MF b/base/tomcat/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..021eb0d857b --- /dev/null +++ b/base/tomcat/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Name: pki-tomcat +Specification-Version: ${APPLICATION_VERSION} +Implementation-Version: ${IMPL_VERSION} diff --git a/base/tps/CMakeLists.txt b/base/tps/CMakeLists.txt index 60535c4da00..b15e916d8e8 100644 --- a/base/tps/CMakeLists.txt +++ b/base/tps/CMakeLists.txt @@ -5,8 +5,6 @@ add_subdirectory(${APP_SERVER}) # build pki-tps javac(pki-tps-classes - DEPENDS - pki-common-jar pki-server-jar SOURCES src/main/java/*.java CLASSPATH @@ -23,6 +21,8 @@ javac(pki-tps-classes ${PKI_COMMON_JAR} ${PKI_SERVER_JAR} OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/classes + DEPENDS + pki-server-jar ) set(PKI_TPS_JAR ${CMAKE_BINARY_DIR}/dist/pki-tps.jar diff --git a/build.sh b/build.sh index 482363762d6..84938e4e3c4 100755 --- a/build.sh +++ b/build.sh @@ -711,9 +711,10 @@ if [ "$BUILD_TARGET" = "dist" ] ; then echo " $WORK_DIR/dist/pki-tools.jar" fi if [[ " ${PKGS_TO_BUILD[*]} " =~ " server " ]]; then + echo " $WORK_DIR/dist/pki-tomcat.jar" + echo " $WORK_DIR/dist/pki-tomcat-9.0.jar" echo " $WORK_DIR/dist/pki-server.jar" echo " $WORK_DIR/dist/pki-server-webapp.jar" - echo " $WORK_DIR/dist/pki-tomcat.jar" fi if [[ " ${PKGS_TO_BUILD[*]} " =~ " ca " ]]; then echo " $WORK_DIR/dist/pki-ca.jar" diff --git a/pki.spec b/pki.spec index da847bb275d..21f5811bc01 100644 --- a/pki.spec +++ b/pki.spec @@ -1111,6 +1111,7 @@ fi %{_javadir}/pki/pki-server.jar %{_javadir}/pki/pki-server-webapp.jar %{_javadir}/pki/pki-tomcat.jar +%{_javadir}/pki/pki-tomcat-9.0.jar %dir %{_sharedstatedir}/pki %{_mandir}/man1/pkidaemon.1.gz %{_mandir}/man5/pki_default.cfg.5.gz