diff options
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/JNLPFile.java | 24 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/Parser.java | 25 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/PluginBridge.java | 11 |
5 files changed, 67 insertions, 8 deletions
@@ -1,5 +1,19 @@ 2011-07-08 Andrew Su <[email protected]> + * NEWS: Updated. + * netx/net/sourceforge/jnlp/JNLPFile.java: + (JNLPFile): Calls new constructor. + (JNLPFile): New constructor to take an option for forcing a codebase. + (JNLPFile): Call parse with extra parameter. + (parse): Use the given codebase passed in if we did not find one. + * netx/net/sourceforge/jnlp/Parser.java: + (Parser): Calls new constructor. + (Parser): New constructor which takes in a codebase as a last option. + * netx/net/sourceforge/jnlp/PluginBridge.java: + (PluginBridge): Calls new JNLPFile's constructor with current codebase + +2011-07-08 Andrew Su <[email protected]> + * netx/net/sourceforge/jnlp/PluginBridge.java: (jars): Changed to use HashSet instead of String[]. (PluginBridge): Updated to work with HashSet instead of String[] @@ -26,6 +26,7 @@ New in release 1.1 (2011-XX-XX): - Use Firefox's proxy settings if possible - The user's default browser (determined from xdg-open or $BROWSER) is used - RH669942: javaws fails to download version/packed files (missing support for jnlp.packEnabled and jnlp.versionEnabled) + - PR464: plugin can now load parameters from jnlp files. - PR658: now jnlp.packEnabled works with applets. - PR726: closing javaws -about no longer throws exceptions. - PR727: cache now properly removes files. diff --git a/netx/net/sourceforge/jnlp/JNLPFile.java b/netx/net/sourceforge/jnlp/JNLPFile.java index 9add91b..183f6b1 100644 --- a/netx/net/sourceforge/jnlp/JNLPFile.java +++ b/netx/net/sourceforge/jnlp/JNLPFile.java @@ -174,8 +174,24 @@ public class JNLPFile { * @throws ParseException if the JNLP file was invalid */ public JNLPFile(URL location, Version version, boolean strict, UpdatePolicy policy) throws IOException, ParseException { + this(location, version, strict, policy, null); + } + + /** + * Create a JNLPFile from a URL and a version, checking for updates + * using the specified policy. + * + * @param location the location of the JNLP file + * @param version the version of the JNLP file + * @param strict whether to enforce the spec when + * @param policy the update policy + * @param forceCodebase codebase to use if not specified in JNLP file. + * @throws IOException if an IO exception occurred + * @throws ParseException if the JNLP file was invalid + */ + protected JNLPFile(URL location, Version version, boolean strict, UpdatePolicy policy, URL forceCodebase) throws IOException, ParseException { Node root = Parser.getRootNode(openURL(location, version, policy)); - parse(root, strict, location); + parse(root, strict, location, forceCodebase); //Downloads the original jnlp file into the cache if possible //(i.e. If the jnlp file being launched exist locally, but it @@ -222,7 +238,7 @@ public class JNLPFile { * @throws ParseException if the JNLP file was invalid */ public JNLPFile(InputStream input, boolean strict) throws ParseException { - parse(Parser.getRootNode(input), strict, null); + parse(Parser.getRootNode(input), strict, null, null); } /** @@ -574,12 +590,12 @@ public class JNLPFile { * @param strict whether to enforce the spec when * @param location the file location or null */ - private void parse(Node root, boolean strict, URL location) throws ParseException { + private void parse(Node root, boolean strict, URL location, URL forceCodebase) throws ParseException { try { //if (location != null) // location = new URL(location, "."); // remove filename - Parser parser = new Parser(this, location, root, strict, true); // true == allow extensions + Parser parser = new Parser(this, location, root, strict, true, forceCodebase); // true == allow extensions // JNLP tag information specVersion = parser.getSpecVersion(); diff --git a/netx/net/sourceforge/jnlp/Parser.java b/netx/net/sourceforge/jnlp/Parser.java index aeb03b9..917cad2 100644 --- a/netx/net/sourceforge/jnlp/Parser.java +++ b/netx/net/sourceforge/jnlp/Parser.java @@ -110,6 +110,27 @@ class Parser { * @throws ParseException if the JNLP file is invalid */ public Parser(JNLPFile file, URL base, Node root, boolean strict, boolean allowExtensions) throws ParseException { + this(file, base, root, strict, allowExtensions, null); + } + + /** + * Create a parser for the JNLP file. If the location + * parameters is not null it is used as the default codebase + * (does not override value of jnlp element's href + * attribute).<p> + * + * The root node may be normalized as a side effect of this + * constructor. + * + * @param file the (uninitialized) file reference + * @param base if codebase is not specified, a default base for relative URLs + * @param root the root node + * @param strict whether to enforce strict compliance with the JNLP spec + * @param allowExtensions whether to allow extensions to the JNLP spec + * @param codebase codebase to use if we did not parse one from JNLP file. + * @throws ParseException if the JNLP file is invalid + */ + public Parser(JNLPFile file, URL base, Node root, boolean strict, boolean allowExtensions, URL codebase) throws ParseException { this.file = file; this.root = root; this.strict = strict; @@ -122,7 +143,9 @@ class Parser { // JNLP tag information this.spec = getVersion(root, "spec", "1.0+"); this.codebase = addSlash(getURL(root, "codebase", base)); - this.base = (codebase != null) ? codebase : base; // if codebase not specified use default codebase + if (this.codebase == null) // We only override it if it is not specified. + this.codebase = codebase; + this.base = (this.codebase != null) ? this.codebase : base; // if codebase not specified use default codebase fileLocation = getURL(root, "href", this.base); // normalize the text nodes diff --git a/netx/net/sourceforge/jnlp/PluginBridge.java b/netx/net/sourceforge/jnlp/PluginBridge.java index 3423318..a54858a 100644 --- a/netx/net/sourceforge/jnlp/PluginBridge.java +++ b/netx/net/sourceforge/jnlp/PluginBridge.java @@ -53,17 +53,23 @@ public class PluginBridge extends JNLPFile { fileVersion = new Version("1.1"); this.codeBase = codebase; this.sourceLocation = documentBase; + this.atts = atts; if (atts.containsKey("jnlp_href")) { try { URL jnlp = new URL(codeBase.toExternalForm() + atts.get("jnlp_href")); - JNLPFile jnlpFile = new JNLPFile(jnlp); + JNLPFile jnlpFile = new JNLPFile(jnlp, null, false, JNLPRuntime.getDefaultUpdatePolicy(), this.codeBase); Map<String, String> jnlpParams = jnlpFile.getApplet().getParameters(); // Change the parameter name to lowercase to follow conventions. for (Map.Entry<String, String> entry : jnlpParams.entrySet()) { - atts.put(entry.getKey().toLowerCase(), entry.getValue()); + this.atts.put(entry.getKey().toLowerCase(), entry.getValue()); } + JARDesc[] jarDescs = jnlpFile.getResources().getJARs(); + for (JARDesc jarDesc : jarDescs) { + String fileName = jarDesc.getLocation().toExternalForm(); + this.jars.add(fileName); + } } 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. @@ -117,7 +123,6 @@ public class PluginBridge extends JNLPFile { System.err.println("jars length: " + jars.length); } } - this.atts = atts; name = atts.get("name"); if (name == null) |