aboutsummaryrefslogtreecommitdiffstats
path: root/netx
diff options
context:
space:
mode:
authorAndrew Azores <[email protected]>2013-08-15 14:57:08 -0400
committerAndrew Azores <[email protected]>2013-08-15 14:57:08 -0400
commit40dbe8d01d9e6a9d2f99c772a0f5968102309808 (patch)
tree557a5298326c7985bda3479c31fd26e9a09fa62a /netx
parent3f6158009745f971e7554750f96e1fdf07893720 (diff)
Fix and tests for PR974, extension JNLPs unavailable when embedded in HTML applet tags
Diffstat (limited to 'netx')
-rw-r--r--netx/net/sourceforge/jnlp/ParserSettings.java35
-rw-r--r--netx/net/sourceforge/jnlp/PluginBridge.java17
-rw-r--r--netx/net/sourceforge/jnlp/runtime/Boot.java12
3 files changed, 47 insertions, 17 deletions
diff --git a/netx/net/sourceforge/jnlp/ParserSettings.java b/netx/net/sourceforge/jnlp/ParserSettings.java
index de781d9..b698bd4 100644
--- a/netx/net/sourceforge/jnlp/ParserSettings.java
+++ b/netx/net/sourceforge/jnlp/ParserSettings.java
@@ -37,6 +37,9 @@ exception statement from your version.
package net.sourceforge.jnlp;
+import java.util.Arrays;
+import java.util.List;
+
/**
* Contains settings to be used by the Parser while parsing JNLP files.
*
@@ -44,6 +47,8 @@ package net.sourceforge.jnlp;
*/
public class ParserSettings {
+ private static ParserSettings globalParserSettings = new ParserSettings();
+
private final boolean isStrict;
private final boolean extensionAllowed;
private final boolean malformedXmlAllowed;
@@ -75,4 +80,32 @@ public class ParserSettings {
return isStrict;
}
-} \ No newline at end of file
+ /**
+ * Return the global parser settings in use.
+ */
+ public static ParserSettings getGlobalParserSettings() {
+ return globalParserSettings;
+ }
+
+ /**
+ * Set the global ParserSettings to match the given settings.
+ */
+ public static void setGlobalParserSettings(ParserSettings parserSettings) {
+ globalParserSettings = parserSettings;
+ }
+
+ /**
+ * Return the ParserSettings to be used according to arguments specified
+ * at boot on the command line. These settings are also stored so they
+ * can be retrieved at a later time.
+ */
+ public static ParserSettings setGlobalParserSettingsFromArgs(String[] cmdArgs) {
+ List<String> argList = Arrays.asList(cmdArgs);
+ boolean strict = argList.contains("-strict");
+ boolean malformedXmlAllowed = !argList.contains("-xml");
+
+ globalParserSettings = new ParserSettings(strict, true, malformedXmlAllowed);
+ return globalParserSettings;
+ }
+
+}
diff --git a/netx/net/sourceforge/jnlp/PluginBridge.java b/netx/net/sourceforge/jnlp/PluginBridge.java
index 9163404..4f4c8f1 100644
--- a/netx/net/sourceforge/jnlp/PluginBridge.java
+++ b/netx/net/sourceforge/jnlp/PluginBridge.java
@@ -26,18 +26,18 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
-import java.util.Locale;
import java.util.List;
-import java.util.ArrayList;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
-import sun.misc.BASE64Decoder;
-
import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import sun.misc.BASE64Decoder;
/**
* Allows reuse of code that expects a JNLPFile object,
@@ -47,6 +47,7 @@ public class PluginBridge extends JNLPFile {
private PluginParameters params;
private Set<String> jars = new HashSet<String>();
+ private List<ExtensionDesc> extensionJars = new ArrayList<ExtensionDesc>();
//Folders can be added to the code-base through the archive tag
private List<String> codeBaseFolders = new ArrayList<String>();
private String[] cacheJars = new String[0];
@@ -90,6 +91,7 @@ public class PluginBridge extends JNLPFile {
this.codeBase = codebase;
this.sourceLocation = documentBase;
this.params = params;
+ this.parserSettings = ParserSettings.getGlobalParserSettings();
if (params.getJNLPHref() != null) {
useJNLPHref = true;
@@ -122,6 +124,9 @@ public class PluginBridge extends JNLPFile {
String fileName = jarDesc.getLocation().toExternalForm();
this.jars.add(fileName);
}
+
+ // Store any extensions listed in the JNLP file to be returned later on, namely in getResources()
+ extensionJars = Arrays.asList(jnlpFile.getResources().getExtensions());
} catch (MalformedURLException e) {
// Don't fail because we cannot get the jnlp file. Parameters are optional not required.
// it is the site developer who should ensure that file exist.
@@ -308,6 +313,8 @@ public class PluginBridge extends JNLPFile {
return result;
} catch (MalformedURLException ex) { /* Ignored */
}
+ } else if (launchType.equals(ExtensionDesc.class)) {
+ return (List<T>) extensionJars; // this list is populated when the PluginBridge is first constructed
}
return sharedResources.getResources(launchType);
}
diff --git a/netx/net/sourceforge/jnlp/runtime/Boot.java b/netx/net/sourceforge/jnlp/runtime/Boot.java
index fcd87b8..81d19c1 100644
--- a/netx/net/sourceforge/jnlp/runtime/Boot.java
+++ b/netx/net/sourceforge/jnlp/runtime/Boot.java
@@ -214,18 +214,8 @@ public final class Boot implements PrivilegedAction<Void> {
extra.put("arguments", getOptions("-arg"));
extra.put("parameters", getOptions("-param"));
extra.put("properties", getOptions("-property"));
- boolean strict = false;
- boolean malformedXmlAllowed = true;
- if (null != getOption("-strict")) {
- strict = true;
- }
-
- if (null != getOption("-xml")) {
- malformedXmlAllowed = false;
- }
-
- ParserSettings settings = new ParserSettings(strict, true, malformedXmlAllowed);
+ ParserSettings settings = ParserSettings.setGlobalParserSettingsFromArgs(args);
try {
Launcher launcher = new Launcher(false);