Skip to content

Commit

Permalink
Split pki-tomcat.jar
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
edewata committed Jul 5, 2023
1 parent 02b6fde commit b304cb1
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 39 deletions.
9 changes: 5 additions & 4 deletions base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions base/acme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions base/ca/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions base/est/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
4 changes: 2 additions & 2 deletions base/kra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions base/ocsp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions base/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion base/server/python/pki/server/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions base/tks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
27 changes: 13 additions & 14 deletions base/tomcat-9.0/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -16,37 +14,38 @@ 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(
${CMAKE_CURRENT_SOURCE_DIR}/src/main/resources/META-INF/MANIFEST.MF
${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
)
Expand Down
2 changes: 1 addition & 1 deletion base/tomcat-9.0/src/main/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Name: pki-tomcat
Name: pki-tomcat-9.0
Specification-Version: ${APPLICATION_VERSION}
Implementation-Version: ${IMPL_VERSION}
50 changes: 50 additions & 0 deletions base/tomcat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
3 changes: 3 additions & 0 deletions base/tomcat/src/main/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Name: pki-tomcat
Specification-Version: ${APPLICATION_VERSION}
Implementation-Version: ${IMPL_VERSION}
4 changes: 2 additions & 2 deletions base/tps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions pki.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b304cb1

Please sign in to comment.