From 4db4f1e1b0425b06d5b0c3f285b43b1cb11c0353 Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Mon, 14 Feb 2022 13:48:51 +0300 Subject: [PATCH 1/7] backport classloader patch from #783 --- netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java index 7ed0c4db6..da23fb5c4 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java @@ -1559,6 +1559,12 @@ protected Class findLoadedClassAll(String name) { */ @Override public Class loadClass(String name) throws ClassNotFoundException { + synchronized (getClassLoadingLock(name)) { + return loadClassImpl(name); + } + } + + private Class loadClassImpl(String name) throws ClassNotFoundException { Class result = findLoadedClassAll(name); // try parent classloader From 3c25773f7d516f4babaf5e2ab302160914cbb58b Mon Sep 17 00:00:00 2001 From: lherschi Date: Tue, 8 Nov 2022 23:25:29 +0100 Subject: [PATCH 2/7] fix "Unexpected End of ZLIB Input Stream" Task #826 - IcedTeaWeb + Tomcat Cause "Unexpected End of ZLIB Input Stream" While Caching --- netx/net/sourceforge/jnlp/cache/ResourceDownloader.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netx/net/sourceforge/jnlp/cache/ResourceDownloader.java b/netx/net/sourceforge/jnlp/cache/ResourceDownloader.java index e0a123bbd..50d4e12a1 100644 --- a/netx/net/sourceforge/jnlp/cache/ResourceDownloader.java +++ b/netx/net/sourceforge/jnlp/cache/ResourceDownloader.java @@ -396,6 +396,8 @@ private URLConnection getDownloadConnection(URL location) throws IOException { } private void downloadPackGzFile(URLConnection connection, URL downloadFrom, URL downloadTo) throws IOException { + if (downloadFrom.equals(downloadTo)) + downloadFrom = new URL(downloadFrom + ".pack.gz"); downloadFile(connection, downloadFrom); uncompressPackGz(downloadFrom, downloadTo, resource.getDownloadVersion()); @@ -405,6 +407,8 @@ private void downloadPackGzFile(URLConnection connection, URL downloadFrom, URL } private void downloadGZipFile(URLConnection connection, URL downloadFrom, URL downloadTo) throws IOException { + if (downloadFrom.equals(downloadTo)) + downloadFrom = new URL(downloadFrom + ".gz"); downloadFile(connection, downloadFrom); uncompressGzip(downloadFrom, downloadTo, resource.getDownloadVersion()); From 1f246bdcd3a7cf4db12b65a838cdcc228e8aec24 Mon Sep 17 00:00:00 2001 From: lhersch Date: Wed, 9 Nov 2022 13:38:11 +0100 Subject: [PATCH 3/7] change to new rhino download url --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f016d3a4..4df43d068 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,7 +49,7 @@ jobs: gmp-devel java-1.8.0-openjdk-devel libcurl-devel make mpfr-devel perl unzip which zip curl -o tagsoup.jar "https://repo1.maven.org/maven2/org/ccil/cowan/tagsoup/tagsoup/1.2.1/tagsoup-1.2.1.jar" sha256sum tagsoup.jar | awk '$1!="ac97f7b4b1d8e9337edfa0e34044f8d0efe7223f6ad8f3a85d54cc1018ea2e04"{exit 1}' - curl -o rhino.zip "https://ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R7.zip" + curl -o rhino.zip "https://mediacdn.prod.productdelivery.prod.webservices.mozgcp.net/pub/js/rhino1_6R7.zip" sha256sum rhino.zip | awk '$1!="c94c6de3a29b3acbc4eee732e688f75a5d94bd02c9878be4ceb4d3cd220f3866"{exit 1}' unzip -j rhino.zip "*/js.jar" @@ -161,7 +161,7 @@ jobs: sha256sum tagsoup.jar | awk '$1!="ac97f7b4b1d8e9337edfa0e34044f8d0efe7223f6ad8f3a85d54cc1018ea2e04"{exit 1}' curl -o mslinks.jar "https://repo1.maven.org/maven2/com/github/vatbub/mslinks/1.0.5/mslinks-1.0.5.jar" sha256sum mslinks.jar | awk '$1!="e14d756f81b310b75baeb5baf219d25592b6a8635eb215c4059f17493b0cea5c"{exit 1}' - curl -o rhino.zip "https://ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R7.zip" + curl -o rhino.zip "https://mediacdn.prod.productdelivery.prod.webservices.mozgcp.net/pub/js/rhino1_6R7.zip" sha256sum rhino.zip | awk '$1!="c94c6de3a29b3acbc4eee732e688f75a5d94bd02c9878be4ceb4d3cd220f3866"{exit 1}' unzip -j rhino.zip "*/js.jar" From d3c6a540a1e2405d19d1c743ac853c3520655c4d Mon Sep 17 00:00:00 2001 From: lhersch Date: Wed, 9 Nov 2022 14:24:55 +0100 Subject: [PATCH 4/7] change to new rhino download url --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4df43d068..00abe0f89 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -259,7 +259,7 @@ jobs: brew install autoconf automake coreutils freetype gnu-sed rust curl -o tagsoup.jar "https://repo1.maven.org/maven2/org/ccil/cowan/tagsoup/tagsoup/1.2.1/tagsoup-1.2.1.jar" sha256sum tagsoup.jar | awk '$1!="ac97f7b4b1d8e9337edfa0e34044f8d0efe7223f6ad8f3a85d54cc1018ea2e04"{exit 1}' - curl -o rhino.zip "https://ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R7.zip" + curl -o rhino.zip "https://mediacdn.prod.productdelivery.prod.webservices.mozgcp.net/pub/js/rhino1_6R7.zip" sha256sum rhino.zip | awk '$1!="c94c6de3a29b3acbc4eee732e688f75a5d94bd02c9878be4ceb4d3cd220f3866"{exit 1}' unzip -j rhino.zip "*/js.jar" From 8970fed7c8b4ba25adec786104f4d348947c84fe Mon Sep 17 00:00:00 2001 From: Lars Herschke Date: Thu, 10 Nov 2022 10:37:45 +0100 Subject: [PATCH 5/7] fix checkout when using Cygwin Git --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00abe0f89..8bfc780f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -359,9 +359,11 @@ jobs: - name: Cygwin git configuration shell: bash - run: mkdir $HOME && git config --system core.autocrlf false + run: mkdir $HOME && git config --system core.autocrlf false && git config --system --add safe.directory '*' - uses: actions/checkout@v2 + with: + set-safe-directory: false - name: Install Dependencies run: | From be989488bb60c23b8ea2b5e95282d661d25a4077 Mon Sep 17 00:00:00 2001 From: lherschi Date: Sat, 26 Nov 2022 00:17:10 +0100 Subject: [PATCH 6/7] backport of #868 --- Makefile.am | 10 +++++++--- configure.ac | 9 ++++----- .../jnlp/runtime/JNLPSecurityManager.java | 12 ++++++++---- netx/net/sourceforge/jnlp/security/package-info.java | 2 +- .../sourceforge/jnlp/tools/CodeSignerCreator.java | 3 ++- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Makefile.am b/Makefile.am index e44070c17..d762c002b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -195,6 +195,9 @@ else NETX_EXCLUDE_SRCS=net.sourceforge.jnlp.MalformedXMLParser.java net.sourceforge.jnlp.util.WindowsDesktopEntry.java endif endif +if !ENABLE_PLUGINJAR + NETX_EXCLUDE_SRCS+= net.sourceforge.jnlp.NetxPanel sun.applet.AppletViewerPanelAccess.java +endif # Flags # macOS requires this flag, see https://youtrack.jetbrains.com/issue/IDEA-72010 @@ -246,6 +249,7 @@ export ICEDTEAPLUGIN_TARGET = stamps/liveconnect-dist.stamp export PLUGIN_DIR=$(TOP_BUILD_DIR)/plugin/icedteanp export PLUGIN_SRCDIR=$(TOP_SRC_DIR)/plugin/icedteanp export JSOBJECT_DIRS = netscape +export SUN_DIR = sun export SUN_APPLET_DIRS = sun/applet export PLUGIN_PKGS = sun.applet netscape.security netscape.javascript export LIVECONNECT_SRCS = $(PLUGIN_SRCDIR)/java @@ -283,7 +287,7 @@ if ENABLE_DOCS JAVADOC_OPTS=-use -keywords -encoding UTF-8 -splitIndex \ -bottom ' Submit a bug or feature' if HAVE_JAVA9 -JAVADOC_OPTS+=-source $(IT_LANGUAGE_SOURCE_VERSION) +JAVADOC_OPTS+=-source $(IT_LANGUAGE_SOURCE_VERSION) --ignore-source-errors endif if JAVADOC_SUPPORTS_J_OPTIONS JAVADOC_MEM_OPTS=-J-Xmx1024m -J-Xms128m @@ -956,11 +960,11 @@ stamps/netx-dist.stamp: stamps/netx.stamp $(TOP_BUILD_DIR)/netx.manifest stamps/ (cd $(NETX_DIR) ; \ mkdir -p lib ; \ $(SYSTEM_JDK_DIR)/bin/jar cfm lib/classes.jar \ - $(TOP_BUILD_DIR)/netx.manifest javax/jnlp net sun; \ + $(TOP_BUILD_DIR)/netx.manifest javax/jnlp net $(SUN_DIR); \ cp -pPR $(SRC_DIR_LINK) $(NETX_SRCDIR) src; \ find src -type f -exec chmod 640 '{}' ';' -o -type d -exec chmod 750 '{}' ';'; \ cd src ; \ - $(ZIP) -qr $(NETX_DIR)/lib/src.zip javax net sun) + $(ZIP) -qr $(NETX_DIR)/lib/src.zip javax net $(SUN_DIR)) mkdir -p stamps touch $@ diff --git a/configure.ac b/configure.ac index b6710ed93..3b5b95ade 100644 --- a/configure.ac +++ b/configure.ac @@ -143,7 +143,6 @@ dnl PR46074 (gcc) - Missing java.net cookie code required by IcedTea plugin dnl IT563 - NetX uses sun.security code dnl IT605 - NetX depends on sun.misc HexDumpEncoder or sun.security.util.HexDumpEncoder dnl IT570 - NetX depends on sun.applet.AppletViewPanel -dnl IT571 - NetX depends on com.sun.net.ssl.internal.ssl.X509ExtendedTrustManager.java dnl IT573 - Plugin depends on sun.awt,X11.XEmbeddedFrame.java dnl IT575 - Plugin depends on com.sun/jndi.toolkit.url.UrlUtil dnl IT576 - Plugin depends on sun.applet.AppletImageRef @@ -172,7 +171,6 @@ else IT_CHECK_FOR_CLASS(SUN_MISC_LAUNCHER, [sun.misc.Launcher], [some.pkg], [$JAVA_BASE]) fi IT_CHECK_FOR_CLASS(SUN_SECURITY_VALIDATOR_VALIDATOREXCEPTION, [sun.security.validator.ValidatorException], [some.pkg], [$JAVA_BASE]) -IT_CHECK_FOR_CLASS(COM_SUN_NET_SSL_INTERNAL_SSL_X509EXTENDEDTRUSTMANAGER, [com.sun.net.ssl.internal.ssl.X509ExtendedTrustManager], [some.pkg], [$JAVA_BASE]) IT_CHECK_FOR_CLASS(SUN_NET_WWW_PROTOCOL_JAR_URLJARFILE, [sun.net.www.protocol.jar.URLJarFile], [some.pkg], [$JAVA_BASE]) IT_CHECK_FOR_CLASS(SUN_NET_WWW_PROTOCOL_JAR_URLJARFILECALLBACK, [sun.net.www.protocol.jar.URLJarFileCallBack], [some.pkg], [$JAVA_BASE]) if test "x$build_linux" = xyes ; then @@ -186,9 +184,10 @@ if test "x$build_windows" = xyes ; then fi IT_CHECK_FOR_CLASS(COM_SUN_JNDI_TOOLKIT_URL_URLUTIL, [com.sun.jndi.toolkit.url.UrlUtil], [some.pkg], [$JAVA_NAMING]) IT_CHECK_FOR_CLASS(SUN_NET_WWW_PROTOCOL_HTTP_HANDLER, [sun.net.www.protocol.http.Handler], [some.pkg], [$JAVA_BASE]) -IT_CHECK_FOR_CLASS(SUN_APPLET_APPLETIMAGEREF, [sun.applet.AppletImageRef], [sun.applet], [$JAVA_DESKTOP]) - -IT_CHECK_FOR_SUN_APPLET_ACCESSIBILITY +if test "$enable_pluginjar" = yes ; then + IT_CHECK_FOR_CLASS(SUN_APPLET_APPLETIMAGEREF, [sun.applet.AppletImageRef], [sun.applet], [$JAVA_DESKTOP]) + IT_CHECK_FOR_SUN_APPLET_ACCESSIBILITY +fi IT_CHECK_GLIB_VERSION IT_CHECK_XULRUNNER_MIMEDESCRIPTION_CONSTCHAR IT_CHECK_XULRUNNER_REQUIRES_C11 diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java index 6196a9ea7..fab17a80f 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java @@ -18,6 +18,7 @@ import static net.sourceforge.jnlp.runtime.Translator.R; +import java.awt.AWTPermission; import java.awt.Window; import java.net.SocketPermission; import java.security.AccessControlException; @@ -343,7 +344,6 @@ private void addPermission(Permission perm) { * warning banner, and adds the window to the list of windows to * be disposed when the calling application exits. */ - @Override public boolean checkTopLevelWindow(Object window) { ApplicationInstance app = getApplication(); @@ -362,7 +362,12 @@ public boolean checkTopLevelWindow(Object window) { // todo: set awt.appletWarning to custom message // todo: logo on with glass pane on JFrame/JWindow? - return super.checkTopLevelWindow(window); + try { + checkPermission(new AWTPermission("showWindowWithoutWarningBanner")); + return true; + } catch (Exception se) { + return false; + } } /** @@ -432,7 +437,6 @@ protected void disableExit() { * @exception SecurityException if the caller does not have * permission to accesss the AWT event queue. */ - @Override public void checkAwtEventQueueAccess() { /* * this is the templace of the code that should allow applets access to @@ -446,7 +450,7 @@ public void checkAwtEventQueueAccess() { // If we're about to allow access to the main EventQueue, // and anything untrusted is on the class context stack, // disallow access. - super.checkAwtEventQueueAccess(); + checkPermission(new AWTPermission("accessEventQueue")); // } } diff --git a/netx/net/sourceforge/jnlp/security/package-info.java b/netx/net/sourceforge/jnlp/security/package-info.java index a894f15c8..bac704a49 100644 --- a/netx/net/sourceforge/jnlp/security/package-info.java +++ b/netx/net/sourceforge/jnlp/security/package-info.java @@ -32,7 +32,7 @@ statement from your version.*/ /** *package generally about showing various security prompts - *

Following diagram shows how dialog is handled when some application/appelt needs to show it

+ *

Following diagram shows how dialog is handled when some application/appelt needs to show it

* *
 {@code
diff --git a/tests/test-extensions/net/sourceforge/jnlp/tools/CodeSignerCreator.java b/tests/test-extensions/net/sourceforge/jnlp/tools/CodeSignerCreator.java
index 8d372c022..0eceef613 100644
--- a/tests/test-extensions/net/sourceforge/jnlp/tools/CodeSignerCreator.java
+++ b/tests/test-extensions/net/sourceforge/jnlp/tools/CodeSignerCreator.java
@@ -204,7 +204,8 @@ private String getCertAndKeyGenClass() {
             String className = null;
             if (javaVersion.startsWith("1.7")) {
                 className = "sun.security.x509.CertAndKeyGen";
-            } else if (javaVersion.startsWith("1.8") || javaVersion.startsWith("1.9")) {
+            } else if (javaVersion.startsWith("1.8") ||
+                       javaVersion.matches("^(9|1[0-3])\\..*")) {
                 className = "sun.security.tools.keytool.CertAndKeyGen";
             } else {
                 throw new AssertionError("Unrecognized Java Version");

From 261ce91cfd6e09887c42ce0b4a4114fb7f511e3d Mon Sep 17 00:00:00 2001
From: Frederic Thevenet 
Date: Tue, 28 Feb 2023 19:53:29 +0100
Subject: [PATCH 7/7]  Fixed issue #691: properties from extension jnlp are not
 set.

---
 .../jnlp/runtime/ApplicationInstance.java     | 35 ++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
index 6acc5dd38..170e5032a 100644
--- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
+++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
@@ -27,10 +27,15 @@
 import java.security.CodeSource;
 import java.security.PrivilegedAction;
 import java.security.ProtectionDomain;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 import javax.swing.event.EventListenerList;
 
 import sun.awt.AppContext;
+import net.sourceforge.jnlp.ExtensionDesc;
+import net.sourceforge.jnlp.ParseException;
 import net.sourceforge.jnlp.JNLPFile;
 import net.sourceforge.jnlp.PropertyDesc;
 import net.sourceforge.jnlp.SecurityDesc;
@@ -314,7 +319,7 @@ public void finalize() {
      * Install the environment variables.
      */
     void installEnvironment() {
-        final PropertyDesc props[] = file.getResources().getProperties();
+        final List props = collectPropertiesFromJnlpHierarchy(new ArrayList<>(), file);
 
         CodeSource cs = new CodeSource((URL) null, (java.security.cert.Certificate[]) null);
 
@@ -331,6 +336,8 @@ void installEnvironment() {
             public Object run() {
                 for (PropertyDesc propDesc : props) {
                     System.setProperty(propDesc.getKey(), propDesc.getValue());
+                    OutputController.getLogger().log(OutputController.Level.MESSAGE_DEBUG,
+                            "Setting property: " + propDesc.getKey() + " = " + propDesc.getValue());
                 }
 
                 return null;
@@ -339,6 +346,32 @@ public Object run() {
         AccessController.doPrivileged(installProps, acc);
     }
 
+    /**
+     * Collects properties from the full hierarchy of JNLP files
+     *
+     * @param props a list of all properties collected so far
+     * @param jnlpFile the current tip of the jnlp hierarchy
+     * @return a list of properties collected from the full hierarchy of JNLP files
+     */
+    private List collectPropertiesFromJnlpHierarchy(List props, JNLPFile jnlpFile) {
+        // Collect properties from the current jnlp file
+        props.addAll(Arrays.asList(jnlpFile.getResources().getProperties()));
+        for (ExtensionDesc ext : jnlpFile.getResources().getExtensions()) {
+            // Recursively look for extension jnlp files to collect their properties
+            try {
+                ext.resolve();
+                JNLPFile extFile = ext.getJNLPFile();
+                if (extFile != null) {
+                    collectPropertiesFromJnlpHierarchy(props, extFile);
+                }
+            } catch (ParseException | IOException e) {
+                OutputController.getLogger().log(OutputController.Level.WARNING_ALL,
+                        "Could not resolve JNLP file " + ext.getName() + " (declared properties won't be set): " + e.getMessage());
+            }
+        }
+        return props;
+    }
+
     /**
      * Returns the jnlpfile on which is this application based
      * @return JNLP file for this task.