Mercurial > hg > icedtea11
changeset 1680:1be2224bd96c
* Apply patch from Xerxes R?nby to prevent initialization timeout on slower
systems.
* Fix for 294 [handle null jar specification in archive tags + handle empty
jars]. The JavaFX page still does not load, but the error appears to in
server-side code now, caused due to an old version of applet-loader.
* Supply cookie info when requesting jars (rhbz #480487).
* Fix bug that was causing exceptions to be thrown during shutdown.
author | Deepak Bhole <dbhole@redhat.com> |
---|---|
date | Mon, 23 Feb 2009 17:14:33 -0500 |
parents | 0848286d8e5c |
children | 1847391cef9c |
files | ChangeLog IcedTeaPlugin.cc plugin/icedtea/sun/applet/PluginAppletViewer.java plugin/icedtea/sun/applet/PluginStreamHandler.java rt/net/sourceforge/jnlp/ExtensionDesc.java rt/net/sourceforge/jnlp/JNLPFile.java rt/net/sourceforge/jnlp/Launcher.java rt/net/sourceforge/jnlp/NetxPanel.java rt/net/sourceforge/jnlp/Parser.java rt/net/sourceforge/jnlp/PluginBridge.java rt/net/sourceforge/jnlp/cache/CacheUtil.java rt/net/sourceforge/jnlp/cache/Resource.java rt/net/sourceforge/jnlp/cache/ResourceTracker.java rt/net/sourceforge/jnlp/runtime/Boot.java rt/net/sourceforge/jnlp/runtime/JNLPClassLoader.java rt/net/sourceforge/jnlp/tools/JarSigner.java |
diffstat | 16 files changed, 231 insertions(+), 89 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Feb 23 15:42:22 2009 -0500 +++ b/ChangeLog Mon Feb 23 17:14:33 2009 -0500 @@ -1,3 +1,31 @@ +2009-02-23 Deepak Bhole <dbhole@redhat.com> + + * IcedTeaPlugin.cc: Supply cookie info to Java side. + * plugin/icedtea/sun/applet/PluginAppletViewer.java: Apply patch from + Xerxes RĂ„nby to prevent initialization timeout on slower systems. Also, + use cookie info when equests for jar are made. + * plugin/icedtea/sun/applet/PluginStreamHandler.java: Fix bug that was + causing unnecessary exception prints on exit. + * rt/net/sourceforge/jnlp/ExtensionDesc.java: Store/supply cookie info as + needed. + * rt/net/sourceforge/jnlp/JNLPFile.java: Same. + * rt/net/sourceforge/jnlp/Launcher.java: Same. + * rt/net/sourceforge/jnlp/NetxPanel.java: Same. + * rt/net/sourceforge/jnlp/Parser.java: Same. + * rt/net/sourceforge/jnlp/PluginBridge.java: Same. Also, handle empty jar + specification (Bug: 294) in archive tags. + * rt/net/sourceforge/jnlp/cache/CacheUtil.java: Store/supply cookie info + as needed. + * rt/net/sourceforge/jnlp/cache/Resource.java: Same. + * rt/net/sourceforge/jnlp/cache/ResourceTracker.java: Supply cookie string + to server when requesting jars, if there is one set. + * rt/net/sourceforge/jnlp/runtime/Boot.java: Initialize JNLPFile with null + cookie string. + * rt/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: Store/supply + cookie info as needed. + * rt/net/sourceforge/jnlp/tools/JarSigner.java: Use JarInputStream instead + of Jar to handle empty jars, and update signature checking accordingly. + 2009-02-23 Lillian Angel <langel@redhat.com> * AUTHORS: Added Mark Reinhold.
--- a/IcedTeaPlugin.cc Mon Feb 23 15:42:22 2009 -0500 +++ b/IcedTeaPlugin.cc Mon Feb 23 17:14:33 2009 -0500 @@ -1063,6 +1063,7 @@ IcedTeaPluginFactory* factory; PRUint32 instance_identifier; nsCString instanceIdentifierPrefix; + nsresult GetCookie(const char* siteAddr, char** cookieString); }; @@ -2281,6 +2282,12 @@ } +#include <nsICookieService.h> +#include <nsIIOService.h> +#include <nsIScriptSecurityManager.h> +#include <nsIURI.h> +#include <nsServiceManagerUtils.h> + NS_IMPL_ISUPPORTS2 (IcedTeaPluginInstance, nsIPluginInstance, nsIJVMPluginInstance) @@ -2337,25 +2344,35 @@ PLUGIN_DEBUG_1ARG("TAG FROM BROWSER = %s\n", tagMessage.get()); // encode newline characters in the message - nsCString toSend(""); + nsCString encodedAppletTag(""); for (int i=0; i < tagMessage.Length(); i++) { if (tagMessage.get()[i] == '\r') { - toSend += " "; + encodedAppletTag += " "; continue; } if (tagMessage.get()[i] == '\n') { - toSend += " "; + encodedAppletTag += " "; continue; } - toSend += tagMessage.get()[i]; + encodedAppletTag += tagMessage.get()[i]; } - factory->SendMessageToAppletViewer (toSend); + nsCString cookieInfo(instanceIdentifierPrefix); + cookieInfo += "cookie "; + + char* cookieString; + if (GetCookie(documentbase, &cookieString) == NS_OK) + { + cookieInfo += cookieString; + } + + factory->SendMessageToAppletViewer (cookieInfo); + factory->SendMessageToAppletViewer (encodedAppletTag); // Set back-pointer to peer instance. PLUGIN_DEBUG_1ARG ("SETTING PEER!!!: %p\n", aPeer); @@ -2631,6 +2648,42 @@ NS_IMETHODIMP +IcedTeaPluginInstance::GetCookie(const char* siteAddr, char** cookieString) +{ + + nsresult rv; + nsCOMPtr<nsIScriptSecurityManager> sec_man = + do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); + + if (!sec_man) { + return NS_ERROR_FAILURE; + } + + nsCOMPtr<nsIIOService> io_svc = do_GetService(NS_IOSERVICE_CONTRACTID, &rv); + + if (NS_FAILED(rv) || !io_svc) { + return NS_ERROR_FAILURE; + } + + nsIURI *uri; + io_svc->NewURI(nsCString(siteAddr), NULL, NULL, &uri); + + nsCOMPtr<nsICookieService> cookie_svc = do_GetService(NS_COOKIESERVICE_CONTRACTID, &rv); + + if (NS_FAILED(rv) || !cookie_svc) { + return NS_ERROR_FAILURE; + } + + rv = cookie_svc->GetCookieString(uri, NULL, cookieString); + + if (NS_FAILED(rv) || !*cookieString) { + return NS_ERROR_FAILURE; + } + + return NS_OK; +} + +NS_IMETHODIMP IcedTeaPluginFactory::GetJavaObject (PRUint32 instance_identifier, jobject* object) { @@ -4438,10 +4491,7 @@ #include <nsISocketTransport.h> #include <nsITransport.h> #include <nsNetCID.h> -#include <nsServiceManagerUtils.h> #include <nsIPrincipal.h> -#include <nsIScriptSecurityManager.h> -#include <nsIURI.h> #include <xpcjsid.h> IcedTeaJNIEnv::IcedTeaJNIEnv (IcedTeaPluginFactory* factory) @@ -4486,16 +4536,6 @@ nsresult IcedTeaJNIEnv::GetEnabledPrivileges(nsCString *privileges, nsISecurityContext *ctx) { - nsresult rv; - nsCOMPtr<nsIScriptSecurityManager> sec_man = - do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); - - if (NS_FAILED(rv) || !sec_man) { - return NS_ERROR_FAILURE; - } - - PRBool isEnabled = PR_FALSE; - // check privileges one by one privileges->Truncate();
--- a/plugin/icedtea/sun/applet/PluginAppletViewer.java Mon Feb 23 15:42:22 2009 -0500 +++ b/plugin/icedtea/sun/applet/PluginAppletViewer.java Mon Feb 23 17:14:33 2009 -0500 @@ -174,6 +174,8 @@ private static PluginCallRequestFactory requestFactory; + private static HashMap<Integer, String> siteCookies = new HashMap<Integer,String>(); + private double proposedHeightFactor; private double proposedWidthFactor; @@ -186,7 +188,7 @@ /** * Create the applet viewer */ - public PluginAppletViewer(int identifier, long handle, int x, int y, final URL doc, + public PluginAppletViewer(final int identifier, long handle, int x, int y, final URL doc, final Hashtable atts, PrintStream statusMsgStream, PluginAppletViewerFactory factory) { super(handle, true); @@ -213,7 +215,7 @@ AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { - panel = new NetxPanel(doc, atts, false); + panel = new NetxPanel(doc, siteCookies.get(identifier), atts, false); AppletViewerPanel.debug("Using NetX panel"); PluginDebug.debug(atts.toString()); } catch (Exception ex) { @@ -302,15 +304,12 @@ showStatus(amh.getMessage("status.start")); initEventQueue(); - // Wait for a maximum of 10 seconds for the panel to initialize + // Wait for the panel to initialize // (happens in a separate thread) Applet a; - int maxSleepTime = 10000; - int sleepTime = 0; - while ((a = panel.getApplet()) == null && sleepTime < maxSleepTime) { + while ((a = panel.getApplet()) == null && panel.getAppletHandlerThread().isAlive()) { try { Thread.sleep(100); - sleepTime += 100; PluginDebug.debug("Waiting for applet to initialize... "); } catch (InterruptedException ie) { ie.printStackTrace(); @@ -344,7 +343,7 @@ } catch (IOException ioe) { ioe.printStackTrace(); } - + } public static void setStreamhandler(PluginStreamHandler sh) { @@ -420,6 +419,16 @@ PluginDebug.debug ("REQUEST TAG NOT SET: " + request.tag + ". BYPASSING"); } } + } else if (message.startsWith("cookie")) { + + int cookieStrIndex = message.indexOf(" "); + String cookieStr = null; + + if (cookieStrIndex > 0) + cookieStr = message.substring(cookieStrIndex); + + // Always set the cookie -- even if it is null + siteCookies.put(identifier, cookieStr); } else { PluginDebug.debug ("HANDLING MESSAGE " + message + " instance " + identifier + " " + Thread.currentThread()); applets.get(identifier).handleMessage(reference, message); @@ -480,20 +489,23 @@ // object should belong to? Object o; - // Wait for a maximum of 10 seconds for the panel to initialize + // Wait for the panel to initialize // (happens in a separate thread) - int maxSleepTime = 10000; - int sleepTime = 0; - while ((o = panel.getApplet()) == null && sleepTime < maxSleepTime) { + while ((o = panel.getApplet()) == null && panel.getAppletHandlerThread().isAlive()) { try { Thread.sleep(100); - sleepTime += 100; PluginDebug.debug("Waiting for applet to initialize..."); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // Still null? + if (panel.getApplet() == null) { + this.streamhandler.write("instance " + identifier + " reference " + -1 + " fatalError " + "Initialization failed"); + return; + } + PluginDebug.debug ("Looking for object " + o + " panel is " + panel); AppletSecurityContextManager.getSecurityContext(0).store(o); PluginDebug.debug ("WRITING 1: " + "context 0 reference " + reference + " GetJavaObject " @@ -1455,6 +1467,11 @@ public static void parse(int identifier, long handle, Reader in, URL url) throws IOException { + + // wait until cookie is set (even if cookie is null, it needs to be + // "set" to that first + while (!siteCookies.containsKey(identifier)); + final int fIdentifier = identifier; final long fHandle = handle; final Reader fIn = in;
--- a/plugin/icedtea/sun/applet/PluginStreamHandler.java Mon Feb 23 15:42:22 2009 -0500 +++ b/plugin/icedtea/sun/applet/PluginStreamHandler.java Mon Feb 23 17:14:33 2009 -0500 @@ -362,24 +362,26 @@ try { message = pluginInputReader.readLine(); PluginDebug.debug(" PIPE: appletviewer read: " + message); - } catch (IOException e) { - if (message == null || message.equals("shutdown")) { - synchronized(shuttingDown) { - shuttingDown = true; - } - try { - // Close input/output channels to plugin. - pluginInputReader.close(); - pluginOutputWriter.close(); - } catch (IOException exception) { - // Deliberately ignore IOException caused by broken - // pipe since plugin may have already detached. - } - AppletSecurityContextManager.dumpStore(0); - PluginDebug.debug("APPLETVIEWER: exiting appletviewer"); - System.exit(0); - } + if (message == null || message.equals("shutdown")) { + synchronized(shuttingDown) { + shuttingDown = true; + } + try { + // Close input/output channels to plugin. + pluginInputReader.close(); + pluginOutputWriter.close(); + } catch (IOException exception) { + // Deliberately ignore IOException caused by broken + // pipe since plugin may have already detached. + } + AppletSecurityContextManager.dumpStore(0); + PluginDebug.debug("APPLETVIEWER: exiting appletviewer"); + System.exit(0); + } + + } catch (IOException e) { + e.printStackTrace(); } return message;
--- a/rt/net/sourceforge/jnlp/ExtensionDesc.java Mon Feb 23 15:42:22 2009 -0500 +++ b/rt/net/sourceforge/jnlp/ExtensionDesc.java Mon Feb 23 17:14:33 2009 -0500 @@ -40,6 +40,9 @@ /** the location of the extension JNLP file */ private URL location; + + /** the cookie string sent with resource requests */ + private String cookieStr; /** the JNLPFile the extension refers to */ private JNLPFile file; @@ -58,10 +61,11 @@ * @param version the required version of the extention JNLPFile * @param location the location of the extention JNLP file */ - public ExtensionDesc(String name, Version version, URL location) { + public ExtensionDesc(String name, Version version, URL location, String cookieStr) { this.name = name; this.version = version; this.location = location; + this.cookieStr = cookieStr; } /** @@ -121,7 +125,7 @@ */ public void resolve() throws ParseException, IOException { if (file == null) { - file = new JNLPFile(location); + file = new JNLPFile(location, cookieStr); if (JNLPRuntime.isDebug()) System.out.println("Resolve: "+file.getInformation().getTitle()); @@ -140,6 +144,13 @@ public JNLPFile getJNLPFile() { return file; } + + /** + * Returns the cookie associated with this instance + */ + public String getCookieStr() { + return cookieStr; + } }
--- a/rt/net/sourceforge/jnlp/JNLPFile.java Mon Feb 23 15:42:22 2009 -0500 +++ b/rt/net/sourceforge/jnlp/JNLPFile.java Mon Feb 23 17:14:33 2009 -0500 @@ -62,6 +62,9 @@ /** the URL used to resolve relative URLs in the file */ protected URL codeBase; + + /** cookie string to send alongwith resource requests */ + protected String cookieStr; /** file version */ protected Version fileVersion; @@ -117,8 +120,8 @@ * @throws IOException if an IO exception occurred * @throws ParseException if the JNLP file was invalid */ - public JNLPFile(URL location) throws IOException, ParseException { - this(location, false); // not strict + public JNLPFile(URL location, String cookieStr) throws IOException, ParseException { + this(location, cookieStr, false); // not strict } /** @@ -130,8 +133,8 @@ * @throws IOException if an IO exception occurred * @throws ParseException if the JNLP file was invalid */ - public JNLPFile(URL location, boolean strict) throws IOException, ParseException { - this(location, strict, JNLPRuntime.getDefaultUpdatePolicy()); + public JNLPFile(URL location, String cookieStr, boolean strict) throws IOException, ParseException { + this(location, cookieStr, strict, JNLPRuntime.getDefaultUpdatePolicy()); } /** @@ -144,11 +147,12 @@ * @throws IOException if an IO exception occurred * @throws ParseException if the JNLP file was invalid */ - public JNLPFile(URL location, boolean strict, UpdatePolicy policy) throws IOException, ParseException { - Node root = Parser.getRootNode(openURL(location, policy)); + public JNLPFile(URL location, String cookieStr, boolean strict, UpdatePolicy policy) throws IOException, ParseException { + Node root = Parser.getRootNode(openURL(location, cookieStr, policy)); parse(root, strict, location); this.fileLocation = location; + this.cookieStr = cookieStr; } /** @@ -179,13 +183,13 @@ * Open the jnlp file URL from the cache if there, otherwise * download to the cache. Called from constructor. */ - private static InputStream openURL(URL location, UpdatePolicy policy) throws IOException { + private static InputStream openURL(URL location, String cookieStr, UpdatePolicy policy) throws IOException { if (location == null || policy == null) throw new IllegalArgumentException(R("NullParameter")); try { ResourceTracker tracker = new ResourceTracker(false); // no prefetch - tracker.addResource(location, null/*version*/, policy); + tracker.addResource(location, cookieStr, null/*version*/, policy); return tracker.getInputStream(location); } @@ -247,6 +251,13 @@ } /** + * Returns the cookie string that will be send when resources for this file are requested + */ + public String getCookieStr() { + return cookieStr; + } + + /** * Returns the information section of the JNLP file as viewed * through the default locale. */
--- a/rt/net/sourceforge/jnlp/Launcher.java Mon Feb 23 15:42:22 2009 -0500 +++ b/rt/net/sourceforge/jnlp/Launcher.java Mon Feb 23 17:14:33 2009 -0500 @@ -299,10 +299,10 @@ JNLPFile file = null; try { - file = new JNLPFile(location, true, updatePolicy); // strict + file = new JNLPFile(location, null, true, updatePolicy); // strict } catch (ParseException ex) { - file = new JNLPFile(location, false, updatePolicy); + file = new JNLPFile(location, null, false, updatePolicy); // only here if strict failed but lax did not fail LaunchException lex =
--- a/rt/net/sourceforge/jnlp/NetxPanel.java Mon Feb 23 15:42:22 2009 -0500 +++ b/rt/net/sourceforge/jnlp/NetxPanel.java Mon Feb 23 17:14:33 2009 -0500 @@ -41,6 +41,7 @@ private PluginBridge bridge = null; private boolean exitOnFailure = true; private AppletInstance appInst = null; + private String cookieStr; public NetxPanel(URL documentURL, Hashtable atts) { @@ -48,10 +49,11 @@ } // overloaded constructor, called when initialized via plugin - public NetxPanel(URL documentURL, Hashtable atts, boolean exitOnFailure) + public NetxPanel(URL documentURL, String cookieStr, Hashtable atts, boolean exitOnFailure) { this(documentURL, atts); this.exitOnFailure = exitOnFailure; + this.cookieStr = cookieStr; } //Overriding to use Netx classloader. You might need to relax visibility @@ -59,7 +61,8 @@ protected void runLoader() { try { - bridge = new PluginBridge(baseURL, + bridge = new PluginBridge(baseURL, + cookieStr, getDocumentBase(), getJarFiles(), getCode(),
--- a/rt/net/sourceforge/jnlp/Parser.java Mon Feb 23 15:42:22 2009 -0500 +++ b/rt/net/sourceforge/jnlp/Parser.java Mon Feb 23 17:14:33 2009 -0500 @@ -323,7 +323,7 @@ Version version = getVersion(node, "version", null); URL location = getRequiredURL(node, "href", base); - ExtensionDesc ext = new ExtensionDesc(name, version, location); + ExtensionDesc ext = new ExtensionDesc(name, version, location, null); Node dload[] = getChildNodes(node, "ext-download"); for (int i=0; i < dload.length; i++) {
--- a/rt/net/sourceforge/jnlp/PluginBridge.java Mon Feb 23 15:42:22 2009 -0500 +++ b/rt/net/sourceforge/jnlp/PluginBridge.java Mon Feb 23 17:14:33 2009 -0500 @@ -43,7 +43,7 @@ String[] cache_ex_jars = new String[0]; Hashtable atts; - public PluginBridge(URL codebase, URL documentBase, String jar, String main, + public PluginBridge(URL codebase, String cookieStr, URL documentBase, String jar, String main, int width, int height, Hashtable atts) throws Exception { @@ -103,6 +103,8 @@ codebase.getHost()); else security = null; + + this.cookieStr = cookieStr; } public String getTitle() @@ -139,8 +141,9 @@ if (launchType.equals(JARDesc.class)) { for (int i = 0; i < jars.length; i++) - result.add(new JARDesc(new URL(codeBase, jars[i]), - null, null, false, true, false, true)); + if (jars[i].length() > 0) + result.add(new JARDesc(new URL(codeBase, jars[i]), + null, null, false, true, false, true)); boolean cacheable = true; @@ -155,6 +158,9 @@ String jar = jar_and_ver[0]; Version version = null; + if (jar.length() == 0) + continue; + if (jar_and_ver.length > 1) { version = new Version(jar_and_ver[1]); } @@ -164,6 +170,10 @@ } for (int i = 0; i < cache_ex_jars.length; i++) { + + if (cache_ex_jars[i].length() == 0) + continue; + String[] jar_info = cache_ex_jars[i].split(";"); String jar = jar_info[0].trim();
--- a/rt/net/sourceforge/jnlp/cache/CacheUtil.java Mon Feb 23 15:42:22 2009 -0500 +++ b/rt/net/sourceforge/jnlp/cache/CacheUtil.java Mon Feb 23 17:14:33 2009 -0500 @@ -75,9 +75,9 @@ * @param version the version, or null * @return either the location in the cache or the original location */ - public static URL getCachedResource(URL location, Version version, UpdatePolicy policy) { + public static URL getCachedResource(URL location, String cookieStr, Version version, UpdatePolicy policy) { ResourceTracker rt = new ResourceTracker(); - rt.addResource(location, version, policy); + rt.addResource(location, cookieStr, version, policy); try { File f = rt.getCacheFile(location); return f.toURL(); @@ -139,6 +139,7 @@ * @throws IllegalArgumentException if the source is not cacheable */ public static boolean isCurrent(URL source, Version version, URLConnection connection) { + if (!isCacheable(source, version)) throw new IllegalArgumentException(R("CNotCacheable", source));
--- a/rt/net/sourceforge/jnlp/cache/Resource.java Mon Feb 23 15:42:22 2009 -0500 +++ b/rt/net/sourceforge/jnlp/cache/Resource.java Mon Feb 23 17:14:33 2009 -0500 @@ -67,6 +67,9 @@ /** the remote location of the resource */ URL location; + + /** cookie string to send with the resource request */ + String cookieStr; /** the local file downloaded to */ File localFile; @@ -95,19 +98,20 @@ /** * Create a resource. */ - private Resource(URL location, UpdatePolicy updatePolicy, Version requestVersion) { + private Resource(URL location, String cookieStr, UpdatePolicy updatePolicy, Version requestVersion) { this.location = location; this.requestVersion = requestVersion; this.updatePolicy = updatePolicy; + this.cookieStr = cookieStr; } /** * Return a shared Resource object representing the given * location and version. */ - public static Resource getResource(URL location, UpdatePolicy updatePolicy, Version requestVersion) { + public static Resource getResource(URL location, String cookieStr, UpdatePolicy updatePolicy, Version requestVersion) { synchronized (resources) { - Resource resource = new Resource(location, updatePolicy, requestVersion); + Resource resource = new Resource(location, cookieStr, updatePolicy, requestVersion); int index = resources.indexOf(resource); if (index >= 0) { // return existing object @@ -129,6 +133,13 @@ public URL getLocation() { return location; } + + /** + * Returns the cookie string associated with this resource + */ + public String getCookieStr() { + return cookieStr; + } /** * Returns the tracker that first created or monitored the
--- a/rt/net/sourceforge/jnlp/cache/ResourceTracker.java Mon Feb 23 15:42:22 2009 -0500 +++ b/rt/net/sourceforge/jnlp/cache/ResourceTracker.java Mon Feb 23 17:14:33 2009 -0500 @@ -148,11 +148,11 @@ * @param version the resource version * @param updatePolicy whether to check for updates if already in cache */ - public void addResource(URL location, Version version, UpdatePolicy updatePolicy) { + public void addResource(URL location, String cookieStr, Version version, UpdatePolicy updatePolicy) { if (location == null) throw new IllegalArgumentException("location==null"); - Resource resource = Resource.getResource(location, updatePolicy, version); + Resource resource = Resource.getResource(location, cookieStr, updatePolicy, version); boolean downloaded = false; synchronized (resources) { @@ -606,6 +606,10 @@ try { // create out second in case in does not exist URLConnection con = getVersionedResourceURL(resource).openConnection(); + + if (resource.getCookieStr() != null && resource.getCookieStr().length() > 0) + con.setRequestProperty("Cookie", resource.getCookieStr()); + InputStream in = new BufferedInputStream(con.getInputStream()); OutputStream out = CacheUtil.getOutputStream(resource.location, resource.downloadVersion); byte buf[] = new byte[1024]; @@ -653,6 +657,10 @@ // connect URLConnection connection = getVersionedResourceURL(resource).openConnection(); // this won't change so should be okay unsynchronized + + if (resource.getCookieStr() != null && resource.getCookieStr().length() > 0) + connection.setRequestProperty("Cookie", resource.getCookieStr()); + int size = connection.getContentLength(); boolean current = CacheUtil.isCurrent(resource.location, resource.requestVersion, connection) && resource.getUpdatePolicy() != UpdatePolicy.FORCE;
--- a/rt/net/sourceforge/jnlp/runtime/Boot.java Mon Feb 23 15:42:22 2009 -0500 +++ b/rt/net/sourceforge/jnlp/runtime/Boot.java Mon Feb 23 17:14:33 2009 -0500 @@ -243,7 +243,7 @@ boolean strict = (null != getOption("-strict")); - JNLPFile file = new JNLPFile(url, strict); + JNLPFile file = new JNLPFile(url, null, strict); // add in extra params from command line addProperties(file);
--- a/rt/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Mon Feb 23 15:42:22 2009 -0500 +++ b/rt/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Mon Feb 23 17:14:33 2009 -0500 @@ -233,11 +233,11 @@ * @param location the file's location * @param policy the update policy to use when downloading resources */ - public static JNLPClassLoader getInstance(URL location, UpdatePolicy policy) throws IOException, ParseException, LaunchException { + public static JNLPClassLoader getInstance(URL location, String cookieStr, UpdatePolicy policy) throws IOException, ParseException, LaunchException { JNLPClassLoader loader = (JNLPClassLoader) urlToLoader.get(location); if (loader == null) - loader = getInstance(new JNLPFile(location, false, policy), policy); + loader = getInstance(new JNLPFile(location, cookieStr, false, policy), policy); return loader; } @@ -255,7 +255,7 @@ //if (ext != null) { for (int i=0; i < ext.length; i++) { try { - JNLPClassLoader loader = getInstance(ext[i].getLocation(), updatePolicy); + JNLPClassLoader loader = getInstance(ext[i].getLocation(), ext[i].getCookieStr(), updatePolicy); loaderList.add(loader); } catch (Exception ex) { @@ -312,7 +312,8 @@ if (jars[i].isEager()) initialJars.add(jars[i]); // regardless of part - tracker.addResource(jars[i].getLocation(), + tracker.addResource(jars[i].getLocation(), + file.getCookieStr(), jars[i].getVersion(), jars[i].isCacheable() ? JNLPRuntime.getDefaultUpdatePolicy() : UpdatePolicy.FORCE ); @@ -730,6 +731,7 @@ available.add(desc); tracker.addResource(desc.getLocation(), + file.getCookieStr(), desc.getVersion(), JNLPRuntime.getDefaultUpdatePolicy() );
--- a/rt/net/sourceforge/jnlp/tools/JarSigner.java Mon Feb 23 15:42:22 2009 -0500 +++ b/rt/net/sourceforge/jnlp/tools/JarSigner.java Mon Feb 23 17:14:33 2009 -0500 @@ -239,22 +239,20 @@ public boolean verifyJar(String jarName) throws Exception { boolean anySigned = false; boolean hasUnsignedEntry = false; - JarFile jf = null; + JarInputStream jis = null; try { - jf = new JarFile(jarName, true); + jis = new JarInputStream(new FileInputStream(jarName), true); Vector<JarEntry> entriesVec = new Vector<JarEntry>(); byte[] buffer = new byte[8192]; - Enumeration<JarEntry> entries = jf.entries(); - while (entries.hasMoreElements()) { - JarEntry je = entries.nextElement(); + JarEntry je; + while ((je = jis.getNextJarEntry()) != null) { entriesVec.addElement(je); InputStream is = null; try { - is = jf.getInputStream(je); int n; - while ((n = is.read(buffer, 0, buffer.length)) != -1) { + while ((n = jis.read(buffer, 0, buffer.length)) != -1) { // we just read. this will throw a SecurityException // if a signature/digest check fails. } @@ -265,7 +263,7 @@ } } - Manifest man = jf.getManifest(); + Manifest man = jis.getManifest(); if (man != null) { if (verbose) System.out.println(); @@ -274,7 +272,7 @@ long now = System.currentTimeMillis(); while (e.hasMoreElements()) { - JarEntry je = e.nextElement(); + je = e.nextElement(); String name = je.getName(); CodeSigner[] signers = je.getCodeSigners(); boolean isSigned = (signers != null); @@ -349,8 +347,8 @@ e.printStackTrace(); throw e; } finally { // close the resource - if (jf != null) { - jf.close(); + if (jis != null) { + jis.close(); } }