From 2c2c0e437b2ca1124825d01ccf69b07ef84e1b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20D=C3=A9nari=C3=A9?= Date: Wed, 22 May 2024 13:33:38 +0200 Subject: [PATCH] fix: Update to JDK21 - EXO-71474 - Meeds-io/MIPs#91 (#1999) Remove usage of SecurityManager as it is deprecated for removal in jdk21 Remove also usage of classes - SecurityHelper - PrivilegedSystemHelper - PrivilegedFileHelper - SecureList - SecureSet - SecureCollections These classes are here only to use securityManager, and as it is removed, it is no more necessary Resolves meeds-io/MIPs#91 --- .../src/main/resources/bin/setenv.bat | 15 +++++++++++++++ .../src/main/resources/bin/setenv.sh | 14 ++++++++++++++ .../server/tomcat/PortalContainersCreator.java | 17 ++--------------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/packaging/plf-tomcat-resources/src/main/resources/bin/setenv.bat b/packaging/plf-tomcat-resources/src/main/resources/bin/setenv.bat index f737503ae..bf5d0bdd2 100755 --- a/packaging/plf-tomcat-resources/src/main/resources/bin/setenv.bat +++ b/packaging/plf-tomcat-resources/src/main/resources/bin/setenv.bat @@ -215,6 +215,21 @@ SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens java.xml/com.sun.org.apache. SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens java.xml/com.sun.org.apache.xerces.internal.parsers=ALL-UNNAMED SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.lang.module=ALL-UNNAMED SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/jdk.internal.module=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.time=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/sun.security.util=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/sun.net.www.protocol.http=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/sun.net.www.protocol.https=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/javax.net.ssl=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.util.zip=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.util.jar=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.util.regex=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.security=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.nio.channels=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.nio.channels.spi=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/jdk.internal.reflect=ALL-UNNAMED +SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + SET JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% -noverify REM # Set the window name diff --git a/packaging/plf-tomcat-resources/src/main/resources/bin/setenv.sh b/packaging/plf-tomcat-resources/src/main/resources/bin/setenv.sh index f039770a4..b1f094dc6 100755 --- a/packaging/plf-tomcat-resources/src/main/resources/bin/setenv.sh +++ b/packaging/plf-tomcat-resources/src/main/resources/bin/setenv.sh @@ -309,6 +309,20 @@ JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens java.desktop/java.awt.font=ALL-U JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens java.rmi/sun.rmi.transport=ALL-UNNAMED" JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED" JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens java.xml/com.sun.org.apache.xerces.internal.parsers=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.time=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/sun.security.util=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/sun.net.www.protocol.http=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/sun.net.www.protocol.https=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/javax.net.ssl=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.util.zip=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.util.jar=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.util.regex=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.security=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.nio.channels=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.nio.channels.spi=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/jdk.internal.reflect=ALL-UNNAMED" +JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED" JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS -noverify" export JDK_JAVA_OPTIONS diff --git a/services/plf-tomcat-pc-creator-listener/src/main/java/org/exoplatform/platform/server/tomcat/PortalContainersCreator.java b/services/plf-tomcat-pc-creator-listener/src/main/java/org/exoplatform/platform/server/tomcat/PortalContainersCreator.java index 7d72fe5aa..31d787f4d 100644 --- a/services/plf-tomcat-pc-creator-listener/src/main/java/org/exoplatform/platform/server/tomcat/PortalContainersCreator.java +++ b/services/plf-tomcat-pc-creator-listener/src/main/java/org/exoplatform/platform/server/tomcat/PortalContainersCreator.java @@ -19,11 +19,8 @@ import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleEvent; import org.apache.catalina.LifecycleListener; -import org.exoplatform.commons.utils.SecurityHelper; import org.exoplatform.container.RootContainer; -import java.security.PrivilegedAction; - /** * */ @@ -45,12 +42,7 @@ public void lifecycleEvent(LifecycleEvent event) { */ public void createPortalContainers() { final RootContainer rootContainer = RootContainer.getInstance(); - SecurityHelper.doPrivilegedAction(new PrivilegedAction() { - public Void run() { - rootContainer.createPortalContainers(); - return null; - } - }); + rootContainer.createPortalContainers(); } /** @@ -58,12 +50,7 @@ public Void run() { * doesn't work in some cases for example with tomcat when we call the stop command */ public void releasePortalContainers() { - SecurityHelper.doPrivilegedAction(new PrivilegedAction() { - public Void run() { - RootContainer.getInstance().stop(); - return null; - } - }); + RootContainer.getInstance().stop(); } }