aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge
diff options
context:
space:
mode:
Diffstat (limited to 'netx/net/sourceforge')
-rw-r--r--netx/net/sourceforge/jnlp/JNLPFile.java15
-rw-r--r--netx/net/sourceforge/jnlp/Parser.java11
-rw-r--r--netx/net/sourceforge/jnlp/PluginBridge.java26
3 files changed, 48 insertions, 4 deletions
diff --git a/netx/net/sourceforge/jnlp/JNLPFile.java b/netx/net/sourceforge/jnlp/JNLPFile.java
index 137bfff..26bc806 100644
--- a/netx/net/sourceforge/jnlp/JNLPFile.java
+++ b/netx/net/sourceforge/jnlp/JNLPFile.java
@@ -251,7 +251,20 @@ 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, null);
+ this(input, null, strict);
+ }
+
+ /**
+ * Create a JNLPFile from an input stream.
+ *
+ * @param input input stream of JNLP file.
+ * @param codebase codebase to use if not specified in JNLP file..
+ * @param strict whether to enforce the spec rules
+ * @throws IOException if an IO exception occurred
+ * @throws ParseException if the JNLP file was invalid
+ */
+ public JNLPFile(InputStream input, URL codebase, boolean strict) throws ParseException {
+ parse(Parser.getRootNode(input), strict, null, codebase);
}
/**
diff --git a/netx/net/sourceforge/jnlp/Parser.java b/netx/net/sourceforge/jnlp/Parser.java
index d24c0fd..a825a5b 100644
--- a/netx/net/sourceforge/jnlp/Parser.java
+++ b/netx/net/sourceforge/jnlp/Parser.java
@@ -143,9 +143,16 @@ class Parser {
// JNLP tag information
this.spec = getVersion(root, "spec", "1.0+");
- this.codebase = addSlash(getURL(root, "codebase", base));
- if (this.codebase == null) // We only override it if it is not specified.
+
+ try {
+ this.codebase = addSlash(getURL(root, "codebase", base));
+ } catch (ParseException e) {
+ //If parsing fails, continue by overriding the codebase with the one passed in
+ }
+
+ if (this.codebase == null) // Codebase is overwritten if codebase was not specified in file or if parsing of it failed
this.codebase = codebase;
+
this.base = (this.codebase != null) ? this.codebase : base; // if codebase not specified use default codebase
fileLocation = getURL(root, "href", this.base);
diff --git a/netx/net/sourceforge/jnlp/PluginBridge.java b/netx/net/sourceforge/jnlp/PluginBridge.java
index c7b8f28..37b72e6 100644
--- a/netx/net/sourceforge/jnlp/PluginBridge.java
+++ b/netx/net/sourceforge/jnlp/PluginBridge.java
@@ -22,7 +22,10 @@
package net.sourceforge.jnlp;
+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.util.HashSet;
@@ -32,6 +35,8 @@ import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
+import sun.misc.BASE64Decoder;
+
import net.sourceforge.jnlp.runtime.JNLPRuntime;
/**
@@ -96,7 +101,18 @@ public class PluginBridge extends JNLPFile {
// Use codeBase as the context for the URL. If jnlp_href's
// value is a complete URL, it will replace codeBase's context.
URL jnlp = new URL(codeBase, atts.get("jnlp_href"));
- JNLPFile jnlpFile = jnlpCreator.create(jnlp, null, false, JNLPRuntime.getDefaultUpdatePolicy(), codeBase);
+ JNLPFile jnlpFile = null;
+
+ if (atts.containsKey("jnlp_embedded")) {
+ InputStream jnlpInputStream = new ByteArrayInputStream(decodeBase64String(atts.get("jnlp_embedded")));
+ jnlpFile = new JNLPFile(jnlpInputStream, codeBase, false);
+ } else {
+ jnlpFile = jnlpCreator.create(jnlp, null, false, JNLPRuntime.getDefaultUpdatePolicy(), codeBase);
+ }
+
+ if (jnlpFile.isApplet())
+ main = jnlpFile.getApplet().getMainClass();
+
Map<String, String> jnlpParams = jnlpFile.getApplet().getParameters();
info = jnlpFile.info;
@@ -349,4 +365,12 @@ public class PluginBridge extends JNLPFile {
public boolean isInstaller() {
return false;
}
+
+ /**
+ * Returns the decoded BASE64 string
+ */
+ static byte[] decodeBase64String(String encodedString) throws IOException {
+ BASE64Decoder base64 = new BASE64Decoder();
+ return base64.decodeBuffer(encodedString);
+ }
}