/hg/icedtea-web: Fix PR1040, PR1041, PR1042: Allows signed jars ...
smohammad at icedtea.classpath.org
smohammad at icedtea.classpath.org
Tue Jul 3 14:02:04 PDT 2012
changeset f7191afb7ab9 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=f7191afb7ab9
author: Saad Mohammad <smohammad at redhat.com>
date: Tue Jul 03 17:00:49 2012 -0400
Fix PR1040, PR1041, PR1042: Allows signed jars to function correctly using extensions
diffstat:
ChangeLog | 44 +++
netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java | 121 ++++++++-
tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJar.jnlp | 63 +++++
tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJarExtension.jnlp | 62 +++++
tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJnlp.jnlp | 62 +++++
tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJnlpExtension.jnlp | 62 +++++
tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJnlpJarAndSignedJarExtension.jnlp | 63 +++++
tests/reproducers/signed/ExtensionJnlp/testcases/ExtensionJnlpTest.java | 86 +++++++
tests/reproducers/signed/SignedJarResource/resources/SignedJarExtension.jnlp | 62 +++++
tests/reproducers/signed/SignedJarResource/srcs/SignedJarResource.java | 43 +++
tests/reproducers/signed/SignedJnlpResource/resources/MatchingSignedJnlpExtension.jnlp | 62 +++++
tests/reproducers/signed/SignedJnlpResource/resources/UnmatchingSignedJnlpExtension.jnlp | 62 +++++
tests/reproducers/signed/SignedJnlpResource/srcs/JNLP-INF/APPLICATION_TEMPLATE.jnlp | 58 ++++
tests/reproducers/signed/SignedJnlpResource/srcs/SignedJnlpResource.java | 43 +++
14 files changed, 875 insertions(+), 18 deletions(-)
diffs (truncated from 1047 to 500 lines):
diff -r cbb73b27594b -r f7191afb7ab9 ChangeLog
--- a/ChangeLog Tue Jul 03 16:42:52 2012 +0200
+++ b/ChangeLog Tue Jul 03 17:00:49 2012 -0400
@@ -1,3 +1,47 @@
+2012-07-03 Saad Mohammad <smohammad at redhat.com>
+
+ * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java:
+ (JNLPClassLoader): New constructor that accepts an additional parameter
+ containing the main class name.
+ (getInstance): Accepts mainName as parameter to override application's
+ main class name
+ (initializeExtensions): Passes in the name of the application's main class
+ when creating a new JNLPClassLoader instance.
+ (initializeResources): If the loader owns no jars, it will consider
+ itself as signed if all of the extension loaders are signed. Also, if the
+ extension jars have the main class, it will set foundMainJar to true.
+ (initializeResources): If the main class was not found, check if it was
+ found within the extension jars.
+ (checkForMain): Uses the overwritten main class name (if set) when
+ searching for the main within the jars.
+ (hasMainJar): Returns true if this loader holds the main jar.
+ (hasMainInExtensions): Returns true if extension loaders have the main jar
+ * tests/jnlp_tests/signed/ExtensionJnlp/resources/UsesSignedJarExtension.jnlp:
+ * tests/jnlp_tests/signed/ExtensionJnlp/resources/UsesSignedJnlpExtension.jnlp:
+ * tests/jnlp_tests/signed/ExtensionJnlp/resources/UsesSignedJnlpJarAndSignedJarExtension.jnlp:
+ Launching jnlps that use extension jnlp as its resource.
+ * tests/jnlp_tests/signed/ExtensionJnlp/resources/UsesSignedJar.jnlp:
+ Launching jnlp that directly launches SignedJarResource class.
+ * tests/jnlp_tests/signed/ExtensionJnlp/resources/UsesSignedJnlp.jnlp:
+ Launching jnlp that directly launches SignedJnlpResource class.
+ * tests/jnlp_tests/signed/ExtensionJnlp/testcases/ExtensionJnlpTest.java:
+ Testcase that tests the launching of jnlp files containing extension jnlps
+ as resource.
+ * tests/jnlp_tests/signed/SignedJarResource/resources/SignedJarExtension.jnlp:
+ Component jnlp file that is used as an extension resource.
+ * tests/jnlp_tests/signed/SignedJarResource/srcs/SignedJarResource.java:
+ A simple java class that outputs a string.
+ * tests/jnlp_tests/signed/SignedJnlpResource/resources/UnmatchingSignedJnlpExtension.jnlp:
+ Component jnlp file that is used as an extension resource and does not
+ match the signed jnlp file.
+ * tests/jnlp_tests/signed/SignedJnlpResource/resources/MatchingSignedJnlpExtension.jnlp:
+ Component jnlp file that is used as an extension resource and matches the
+ signed jnlp file.
+ * tests/jnlp_tests/signed/SignedJnlpResource/srcs/JNLP-INF/APPLICATION_TEMPLATE.jnlp:
+ Signed jnlp file.
+ * tests/jnlp_tests/signed/SignedJnlpResource/srcs/SignedJnlpResource.java:
+ A simple java class that outputs a string.
+
2012-07-02 Jiri Vanek <jvanek at redhat.com>
Added missing headers
diff -r cbb73b27594b -r f7191afb7ab9 netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Tue Jul 03 16:42:52 2012 +0200
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Tue Jul 03 17:00:49 2012 -0400
@@ -183,6 +183,9 @@
* */
private boolean foundMainJar= false;
+ /** Name of the application's main class */
+ private String mainClass = null;
+
/**
* Variable to track how many times this loader is in use
*/
@@ -194,6 +197,16 @@
* @param file the JNLP file
*/
protected JNLPClassLoader(JNLPFile file, UpdatePolicy policy) throws LaunchException {
+ this(file,policy,null);
+ }
+
+ /**
+ * Create a new JNLPClassLoader from the specified file.
+ *
+ * @param file the JNLP file
+ * @param name of the application's main class
+ */
+ protected JNLPClassLoader(JNLPFile file, UpdatePolicy policy, String mainName) throws LaunchException {
super(new URL[0], JNLPClassLoader.class.getClassLoader());
if (JNLPRuntime.isDebug())
@@ -203,6 +216,8 @@
this.updatePolicy = policy;
this.resources = file.getResources();
+ this.mainClass = mainName;
+
// initialize extensions
initializeExtensions();
@@ -309,6 +324,17 @@
* @param policy the update policy to use when downloading resources
*/
public static JNLPClassLoader getInstance(JNLPFile file, UpdatePolicy policy) throws LaunchException {
+ return getInstance(file, policy, null);
+ }
+
+ /**
+ * Returns a JNLP classloader for the specified JNLP file.
+ *
+ * @param file the file to load classes for
+ * @param policy the update policy to use when downloading resources
+ * @param mainName Overrides the main class name of the application
+ */
+ public static JNLPClassLoader getInstance(JNLPFile file, UpdatePolicy policy, String mainName) throws LaunchException {
JNLPClassLoader baseLoader = null;
JNLPClassLoader loader = null;
String uniqueKey = file.getUniqueKey();
@@ -325,7 +351,7 @@
(file.isApplication() &&
!baseLoader.getJNLPFile().getFileLocation().equals(file.getFileLocation()))) {
- loader = new JNLPClassLoader(file, policy);
+ loader = new JNLPClassLoader(file, policy, mainName);
// New loader init may have caused extentions to create a
// loader for this unique key. Check.
@@ -343,14 +369,14 @@
// loader is now current + ext. But we also need to think of
// the baseLoader
if (baseLoader != null && baseLoader != loader) {
- loader.merge(baseLoader);
+ loader.merge(baseLoader);
}
} else {
// if key is same and locations match, this is the loader we want
if (!file.isApplication()) {
// If this is an applet, we do need to consider its loader
- loader = new JNLPClassLoader(file, policy);
+ loader = new JNLPClassLoader(file, policy, mainName);
if (baseLoader != null)
baseLoader.merge(loader);
@@ -380,13 +406,17 @@
* @param location the file's location
* @param version the file's version
* @param policy the update policy to use when downloading resources
+ * @param mainName Overrides the main class name of the application
*/
- public static JNLPClassLoader getInstance(URL location, String uniqueKey, Version version, UpdatePolicy policy)
+ public static JNLPClassLoader getInstance(URL location, String uniqueKey, Version version, UpdatePolicy policy, String mainName)
throws IOException, ParseException, LaunchException {
JNLPClassLoader loader = urlToLoader.get(uniqueKey);
- if (loader == null || !location.equals(loader.getJNLPFile().getFileLocation()))
- loader = getInstance(new JNLPFile(location, uniqueKey, version, false, policy), policy);
+ if (loader == null || !location.equals(loader.getJNLPFile().getFileLocation())) {
+ JNLPFile jnlpFile = new JNLPFile(location, uniqueKey, version, false, policy);
+
+ loader = getInstance(jnlpFile, policy, mainName);
+ }
return loader;
}
@@ -405,7 +435,20 @@
for (int i = 0; i < ext.length; i++) {
try {
String uniqueKey = this.getJNLPFile().getUniqueKey();
- JNLPClassLoader loader = getInstance(ext[i].getLocation(), uniqueKey, ext[i].getVersion(), updatePolicy);
+
+ if (mainClass == null) {
+ Object obj = file.getLaunchInfo();
+
+ if (obj instanceof ApplicationDesc) {
+ ApplicationDesc ad = (ApplicationDesc) file.getLaunchInfo();
+ mainClass = ad.getMainClass();
+ } else if (obj instanceof AppletDesc) {
+ AppletDesc ad = (AppletDesc) file.getLaunchInfo();
+ mainClass = ad.getMainClass();
+ }
+ }
+
+ JNLPClassLoader loader = getInstance(ext[i].getLocation(), uniqueKey, ext[i].getVersion(), updatePolicy, mainClass);
loaderList.add(loader);
} catch (Exception ex) {
ex.printStackTrace();
@@ -457,8 +500,25 @@
}
JARDesc jars[] = resources.getJARs();
- if (jars == null || jars.length == 0)
+
+ if (jars == null || jars.length == 0) {
+
+ boolean allSigned = true;
+ for (int i = 1; i < loaders.length; i++) {
+ if (!loaders[i].getSigning()) {
+ allSigned = false;
+ break;
+ }
+ }
+
+ if(allSigned)
+ signing = true;
+
+ //Check if main jar is found within extensions
+ foundMainJar = foundMainJar || hasMainInExtensions();
+
return;
+ }
/*
if (jars == null || jars.length == 0) {
throw new LaunchException(null, null, R("LSFatal"),
@@ -520,6 +580,10 @@
while (!foundMainJar && available != null && available.size() != 0)
addNextResource();
+ // If the jar with main class was not found, check extension
+ // jnlp's resources
+ foundMainJar = foundMainJar || hasMainInExtensions();
+
// If jar with main class was not found and there are no more
// available jars, throw a LaunchException
if (file.getLaunchInfo() instanceof AppletDesc ||
@@ -606,17 +670,18 @@
*/
private void checkForMain(List<JARDesc> jars) throws LaunchException {
- Object obj = file.getLaunchInfo();
- String mainClass;
+ if (mainClass == null) {
+ Object obj = file.getLaunchInfo();
- if (obj instanceof ApplicationDesc) {
- ApplicationDesc ad = (ApplicationDesc) file.getLaunchInfo();
- mainClass = ad.getMainClass();
- } else if (obj instanceof AppletDesc) {
- AppletDesc ad = (AppletDesc) file.getLaunchInfo();
- mainClass = ad.getMainClass();
- } else
- return;
+ if (obj instanceof ApplicationDesc) {
+ ApplicationDesc ad = (ApplicationDesc) file.getLaunchInfo();
+ mainClass = ad.getMainClass();
+ } else if (obj instanceof AppletDesc) {
+ AppletDesc ad = (AppletDesc) file.getLaunchInfo();
+ mainClass = ad.getMainClass();
+ } else
+ return;
+ }
// The main class may be specified in the manifest
@@ -711,6 +776,26 @@
}
/**
+ * Returns true if this loader has the main jar
+ */
+ public boolean hasMainJar() {
+ return this.foundMainJar;
+ }
+
+ /**
+ * Returns true if extension loaders have the main jar
+ */
+ private boolean hasMainInExtensions() {
+ boolean foundMain = false;
+
+ for (int i = 1; i < loaders.length && !foundMain; i++) {
+ foundMain = loaders[i].hasMainJar();
+ }
+
+ return foundMain;
+ }
+
+ /**
* Is called by checkForMain() to check if the jar file is signed and if it
* contains a signed JNLP file.
*
diff -r cbb73b27594b -r f7191afb7ab9 tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJar.jnlp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJar.jnlp Tue Jul 03 17:00:49 2012 -0400
@@ -0,0 +1,63 @@
+<!--
+
+This file is part of IcedTea.
+
+IcedTea 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; either version 2, or (at your option)
+any later version.
+
+IcedTea 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 IcedTea; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+
+***********************************************************************
+Uses only the main jar as its resources (SignedJarResource) ; used for testing to check if the jar
+exists with main
+***********************************************************************
+ -->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="UsesSignedJar.jnlp" codebase=".">
+ <information>
+ <title>UsesSignedJar</title>
+ <vendor>IcedTea</vendor>
+ <homepage href="http://icedtea.classpath.org/wiki/IcedTea-Web#Testing_IcedTea-Web"/>
+ <description>UsesSignedJar</description>
+ <offline/>
+ </information>
+
+ <security>
+ <all-permissions/>
+ </security>
+
+ <resources>
+ <j2se version="1.6+"/>
+ <jar href="SignedJarResource.jar" main="true"/>
+ </resources>
+
+ <application-desc main-class="SignedJarResource">
+ </application-desc>
+</jnlp>
diff -r cbb73b27594b -r f7191afb7ab9 tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJarExtension.jnlp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJarExtension.jnlp Tue Jul 03 17:00:49 2012 -0400
@@ -0,0 +1,62 @@
+<!--
+
+This file is part of IcedTea.
+
+IcedTea 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; either version 2, or (at your option)
+any later version.
+
+IcedTea 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 IcedTea; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+
+***********************************************************************
+Uses only SignedJarExtension as its resources
+***********************************************************************
+ -->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="UsesSignedJarExtension.jnlp" codebase=".">
+ <information>
+ <title>UseSignedJarExtension</title>
+ <vendor>IcedTea</vendor>
+ <homepage href="http://icedtea.classpath.org/wiki/IcedTea-Web#Testing_IcedTea-Web"/>
+ <description>UseSignedJarExtension</description>
+ <offline/>
+ </information>
+
+ <security>
+ <all-permissions/>
+ </security>
+
+ <resources>
+ <j2se version="1.6+"/>
+ <extension name="SignedJarExtension" href="./SignedJarExtension.jnlp"/>
+ </resources>
+
+ <application-desc main-class="SignedJarResource">
+ </application-desc>
+</jnlp>
diff -r cbb73b27594b -r f7191afb7ab9 tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJnlp.jnlp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJnlp.jnlp Tue Jul 03 17:00:49 2012 -0400
@@ -0,0 +1,62 @@
+<!--
+
+This file is part of IcedTea.
+
+IcedTea 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; either version 2, or (at your option)
+any later version.
+
+IcedTea 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 IcedTea; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+
+***********************************************************************
+Uses only MatchingSignedJnlpExtension as its resources
+***********************************************************************
+ -->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="UsesSignedJnlp.jnlp" codebase=".">
+ <information>
+ <title>UsesSignedJnlp</title>
+ <vendor>IcedTea</vendor>
+ <homepage href="http://icedtea.classpath.org/wiki/IcedTea-Web#Testing_IcedTea-Web"/>
+ <description>UsesSignedJnlp</description>
+ <offline/>
+ </information>
+
+ <security>
+ <all-permissions/>
+ </security>
+
+ <resources>
+ <j2se version="1.6+"/>
+ <extension name="MatchingSignedJnlpExtension" href="./MatchingSignedJnlpExtension.jnlp"/>
+ </resources>
+
+ <application-desc main-class="SignedJnlpResource">
+ </application-desc>
+</jnlp>
diff -r cbb73b27594b -r f7191afb7ab9 tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJnlpExtension.jnlp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/ExtensionJnlp/resources/UsesSignedJnlpExtension.jnlp Tue Jul 03 17:00:49 2012 -0400
@@ -0,0 +1,62 @@
+<!--
+
+This file is part of IcedTea.
+
+IcedTea 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; either version 2, or (at your option)
+any later version.
+
+IcedTea 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 IcedTea; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
More information about the distro-pkg-dev
mailing list