/hg/icedtea-web: 2 new changesets

adomurad at icedtea.classpath.org adomurad at icedtea.classpath.org
Fri Aug 17 07:40:59 PDT 2012


changeset cbc297c8c6ee in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=cbc297c8c6ee
author: Adam Domurad <adomurad at redhat.com>
date: Fri Aug 17 10:26:26 2012 -0400

	Reproducer for properly handling java cookie jar persistence


changeset bb3f67ab9fb8 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=bb3f67ab9fb8
author: Adam Domurad <adomurad at redhat.com>
date: Fri Aug 17 10:40:22 2012 -0400

	Fixes PR588, Icedtea-web now saves cookies set in java cookie jar


diffstat:

 NEWS                                                                                   |    1 +
 netx-dist-tests-whitelist                                                              |    2 +-
 plugin/icedteanp/IcedTeaNPPlugin.cc                                                    |   45 ++
 plugin/icedteanp/java/sun/applet/PluginCookieManager.java                              |   26 +
 plugin/icedteanp/java/sun/applet/PluginMain.java                                       |    7 +-
 tests/reproducers/signed/SavingCookies/resources/CheckCookie.html                      |   44 ++
 tests/reproducers/signed/SavingCookies/resources/CheckCookieAndGotoClear.html          |   50 ++
 tests/reproducers/signed/SavingCookies/resources/ClearPersistentCookie.html            |   49 ++
 tests/reproducers/signed/SavingCookies/resources/SavePersistentCookie.html             |   49 ++
 tests/reproducers/signed/SavingCookies/resources/SavePersistentCookieAndGotoCheck.html |   50 ++
 tests/reproducers/signed/SavingCookies/resources/SaveSessionCookie.html                |   49 ++
 tests/reproducers/signed/SavingCookies/resources/SaveSessionCookieAndGotoCheck.html    |   50 ++
 tests/reproducers/signed/SavingCookies/srcs/CheckingCookies.java                       |  114 ++++++
 tests/reproducers/signed/SavingCookies/srcs/SavingCookies.java                         |  123 +++++++
 tests/reproducers/signed/SavingCookies/testcases/SavingCookiesTests.java               |  174 ++++++++++
 15 files changed, 831 insertions(+), 2 deletions(-)

diffs (truncated from 939 to 500 lines):

diff -r c55603fd53ce -r bb3f67ab9fb8 NEWS
--- a/NEWS	Fri Aug 17 15:18:32 2012 +0200
+++ b/NEWS	Fri Aug 17 10:40:22 2012 -0400
@@ -31,6 +31,7 @@
   - PR722: META-INF/ unsigned entries should be ignored in signing
   - PR855: AppletStub getDocumentBase() doesn't return full URL
   - PR1011: Folders treated as jar files in archive tag
+  - PR588: Cookies not written from cookie jar to browser cookies
 * Common
   - PR918: java applet windows uses a low resulution black/white icon
   - RH838417: Disambiguate signed applet security prompt from certificate warning
diff -r c55603fd53ce -r bb3f67ab9fb8 netx-dist-tests-whitelist
--- a/netx-dist-tests-whitelist	Fri Aug 17 15:18:32 2012 +0200
+++ b/netx-dist-tests-whitelist	Fri Aug 17 10:40:22 2012 -0400
@@ -1,1 +1,1 @@
-.*
+SavingCookies
diff -r c55603fd53ce -r bb3f67ab9fb8 plugin/icedteanp/IcedTeaNPPlugin.cc
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc	Fri Aug 17 15:18:32 2012 +0200
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc	Fri Aug 17 10:40:22 2012 -0400
@@ -985,6 +985,21 @@
   return NPERR_NO_ERROR;
 }
 
+static NPError
+set_cookie_info(const char* siteAddr, const char* cookieString, uint32_t len)
+{
+  // Only attempt to perform this operation if there is a valid plugin instance
+  if (g_hash_table_size(instance_to_id_map) > 0 && browser_functions.getvalueforurl)
+  {
+      // We arbitrarily use the first valid instance we can grab
+      // For an explanation of the logic behind this, see get_cookie_info
+      gpointer instance = getFirstInTableInstance(instance_to_id_map);
+      return browser_functions.setvalueforurl((NPP) instance, NPNURLVCookie, siteAddr, cookieString, len);
+  }
+
+  return NPERR_GENERIC_ERROR;;
+}
+
 // HELPER FUNCTIONS
 
 static void
@@ -1247,7 +1262,37 @@
     decoded_url = NULL;
     g_free(cookie_info);
     cookie_info = NULL;
+  } else if (g_str_has_prefix(parts[1], "PluginSetCookie"))
+  {
+    // Message structure: plugin PluginSetCookie reference -1 <url> <cookie>
+    gchar** cookie_parts = g_strsplit (message, " ", 6);
+
+    if (g_strv_length(cookie_parts) < 6)
+    {
+       g_strfreev (parts);
+       g_strfreev (cookie_parts);
+       return; // Defensive, message _should_ be properly formatted
+    }
+
+    gchar* decoded_url = (gchar*) calloc(strlen(cookie_parts[4])+1, sizeof(gchar));
+    IcedTeaPluginUtilities::decodeURL(cookie_parts[4], &decoded_url);
+
+    gchar* cookie_string = cookie_parts[5];
+    uint32_t len = strlen(cookie_string);
+    if (set_cookie_info(decoded_url, cookie_string, len) == NPERR_NO_ERROR)
+    {
+  	  PLUGIN_DEBUG("Setting cookie for URL %s to %s\n", decoded_url, cookie_string);
+    } else
+    {
+  	  PLUGIN_DEBUG("Not able to set cookie for URL %s to %s\n", decoded_url, cookie_string);
+    }
+
+    free(decoded_url);
+    decoded_url = NULL;
+    g_strfreev (cookie_parts);
+    cookie_parts = NULL;
   }
+
   g_strfreev (parts);
   parts = NULL;
 }
diff -r c55603fd53ce -r bb3f67ab9fb8 plugin/icedteanp/java/sun/applet/PluginCookieManager.java
--- a/plugin/icedteanp/java/sun/applet/PluginCookieManager.java	Fri Aug 17 15:18:32 2012 +0200
+++ b/plugin/icedteanp/java/sun/applet/PluginCookieManager.java	Fri Aug 17 10:40:22 2012 -0400
@@ -45,7 +45,16 @@
 import java.util.List;
 import java.util.Map;
 
+import com.sun.jndi.toolkit.url.UrlUtil;
+
 public class PluginCookieManager extends CookieManager {
+    private PluginStreamHandler streamHandler;
+
+    public PluginCookieManager(PluginStreamHandler streamHandler) {
+        this.streamHandler = streamHandler;
+    }
+
+    @Override
     public Map<String, List<String>> get(URI uri,
             Map<String, List<String>> requestHeaders) throws IOException {
         // pre-condition check
@@ -84,4 +93,21 @@
 
         return false;
     }
+
+    @Override
+    public void put(URI uri,
+            Map<String, List<String>> responseHeaders) throws IOException {
+        super.put(uri, responseHeaders);
+
+        for (Map.Entry<String, List<String>> headerEntry : responseHeaders.entrySet()) {
+            String type = headerEntry.getKey();
+            if ("Set-Cookie".equalsIgnoreCase(type) || "Set-Cookie2".equalsIgnoreCase(type)) {
+                List<String> cookies = headerEntry.getValue();
+                for (String cookie : cookies) {
+                    streamHandler.write("plugin PluginSetCookie reference -1 " + UrlUtil.encode(uri.toString(), "UTF-8") + " " + cookie);
+                }
+            }
+
+        }
+    }
 }
diff -r c55603fd53ce -r bb3f67ab9fb8 plugin/icedteanp/java/sun/applet/PluginMain.java
--- a/plugin/icedteanp/java/sun/applet/PluginMain.java	Fri Aug 17 15:18:32 2012 +0200
+++ b/plugin/icedteanp/java/sun/applet/PluginMain.java	Fri Aug 17 10:40:22 2012 -0400
@@ -118,6 +118,9 @@
 
             // Streams set. Start processing.
             streamHandler.startProcessing();
+
+            setCookieHandler(streamHandler);
+
         } catch (Exception e) {
             e.printStackTrace();
             System.err.println("Something very bad happened. I don't know what to do, so I am going to exit :(");
@@ -199,8 +202,10 @@
         }
         // override the proxy selector set by JNLPRuntime
         ProxySelector.setDefault(new PluginProxySelector());
+    }
 
-        CookieManager ckManager = new PluginCookieManager();
+    private static void setCookieHandler(PluginStreamHandler streamHandler) {
+        CookieManager ckManager = new PluginCookieManager(streamHandler);
         CookieHandler.setDefault(ckManager);
     }
 }
diff -r c55603fd53ce -r bb3f67ab9fb8 tests/reproducers/signed/SavingCookies/resources/CheckCookie.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/SavingCookies/resources/CheckCookie.html	Fri Aug 17 10:40:22 2012 -0400
@@ -0,0 +1,44 @@
+<!--
+
+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.
+
+ -->
+<html><head></head><body bgcolor="red">
+<p>
+  <applet code="CheckingCookies.class" archive="SavingCookies.jar" codebase="." width="100" height="100">
+  </applet>
+</p>
+</body>
+</html>
diff -r c55603fd53ce -r bb3f67ab9fb8 tests/reproducers/signed/SavingCookies/resources/CheckCookieAndGotoClear.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/SavingCookies/resources/CheckCookieAndGotoClear.html	Fri Aug 17 10:40:22 2012 -0400
@@ -0,0 +1,50 @@
+<!--
+
+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 show-document to go to a page that clears the cookie -->
+
+<html><head></head><body bgcolor="red">
+<p>
+  <applet code="CheckingCookies.class" archive="SavingCookies.jar" codebase="." width="100" height="100">
+
+  <param name="show-document" value="ClearPersistentCookie.html">
+
+  </applet>
+</p>
+</body>
+</html>
diff -r c55603fd53ce -r bb3f67ab9fb8 tests/reproducers/signed/SavingCookies/resources/ClearPersistentCookie.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/SavingCookies/resources/ClearPersistentCookie.html	Fri Aug 17 10:40:22 2012 -0400
@@ -0,0 +1,49 @@
+<!--
+
+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.
+
+ -->
+<html><head></head><body bgcolor="red">
+<p>
+  <applet code="SavingCookies.class" archive="SavingCookies.jar" codebase="." width="100" height="100">
+
+  <param name="persistent" value="no">
+
+  <param name="cookie" value="TEST=deleted; Expires=Thu, 01 Jan 1970 00:00:01 GMT">
+
+  </applet>
+</p>
+</body>
+</html>
diff -r c55603fd53ce -r bb3f67ab9fb8 tests/reproducers/signed/SavingCookies/resources/SavePersistentCookie.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/SavingCookies/resources/SavePersistentCookie.html	Fri Aug 17 10:40:22 2012 -0400
@@ -0,0 +1,49 @@
+<!--
+
+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.
+
+ -->
+<html><head></head><body bgcolor="red">
+<p>
+  <applet code="SavingCookies.class" archive="SavingCookies.jar" codebase="." width="100" height="100">
+
+  <param name="persistent" value="yes">
+
+  <param name="cookie" value="TEST=persistent">
+
+  </applet>
+</p>
+</body>
+</html>
diff -r c55603fd53ce -r bb3f67ab9fb8 tests/reproducers/signed/SavingCookies/resources/SavePersistentCookieAndGotoCheck.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/SavingCookies/resources/SavePersistentCookieAndGotoCheck.html	Fri Aug 17 10:40:22 2012 -0400
@@ -0,0 +1,50 @@
+<!--
+
+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.
+
+ -->
+<html><head></head><body bgcolor="red">
+<p>
+  <applet code="SavingCookies.class" archive="SavingCookies.jar" codebase="." width="100" height="100">
+
+  <param name="show-document" value="CheckCookieAndGotoClear.html">
+  <param name="persistent" value="yes">
+
+  <param name="cookie" value="TEST=persistent">
+
+  </applet>
+</p>
+</body>
+</html>
diff -r c55603fd53ce -r bb3f67ab9fb8 tests/reproducers/signed/SavingCookies/resources/SaveSessionCookie.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/SavingCookies/resources/SaveSessionCookie.html	Fri Aug 17 10:40:22 2012 -0400
@@ -0,0 +1,49 @@
+<!--
+
+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.
+
+ -->
+<html><head></head><body bgcolor="red">
+<p>
+  <applet code="SavingCookies.class" archive="SavingCookies.jar" codebase="." width="100" height="100">
+
+  <param name="persistent" value="no">
+
+  <param name="cookie" value="TEST=session">
+
+  </applet>
+</p>
+</body>
+</html>
diff -r c55603fd53ce -r bb3f67ab9fb8 tests/reproducers/signed/SavingCookies/resources/SaveSessionCookieAndGotoCheck.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/SavingCookies/resources/SaveSessionCookieAndGotoCheck.html	Fri Aug 17 10:40:22 2012 -0400
@@ -0,0 +1,50 @@
+<!--
+
+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



More information about the distro-pkg-dev mailing list