/hg/release/icedtea-web-1.3: 3 new changesets
adomurad at icedtea.classpath.org
adomurad at icedtea.classpath.org
Fri Aug 17 08:47:09 PDT 2012
changeset 7c1698fa1dd7 in /hg/release/icedtea-web-1.3
details: http://icedtea.classpath.org/hg/release/icedtea-web-1.3?cmd=changeset;node=7c1698fa1dd7
author: Adam Domurad <adomurad at redhat.com>
date: Fri Aug 17 11:39:28 2012 -0400
Reproducers for PR588, tests persistent and session cookies
changeset 5586c774341b in /hg/release/icedtea-web-1.3
details: http://icedtea.classpath.org/hg/release/icedtea-web-1.3?cmd=changeset;node=5586c774341b
author: Adam Domurad <adomurad at redhat.com>
date: Fri Aug 17 11:40:49 2012 -0400
Extract plugin message handling into consume_plugin_message
changeset ae0cbdc9008a in /hg/release/icedtea-web-1.3
details: http://icedtea.classpath.org/hg/release/icedtea-web-1.3?cmd=changeset;node=ae0cbdc9008a
author: Adam Domurad <adomurad at redhat.com>
date: Fri Aug 17 11:46:58 2012 -0400
Fixes PR588, Icedtea-web now saves cookies set in java cookie jar
diffstat:
ChangeLog | 50 ++++
NEWS | 1 +
plugin/icedteanp/IcedTeaNPPlugin.cc | 168 +++++++++----
plugin/icedteanp/java/sun/applet/PluginCookieManager.java | 26 ++
plugin/icedteanp/java/sun/applet/PluginMain.java | 7 +-
5 files changed, 192 insertions(+), 60 deletions(-)
diffs (327 lines):
diff -r aecafbcd8efa -r ae0cbdc9008a ChangeLog
--- a/ChangeLog Fri Aug 17 16:37:27 2012 +0200
+++ b/ChangeLog Fri Aug 17 11:46:58 2012 -0400
@@ -1,3 +1,53 @@
+2012-08-17 Adam Domurad <adomurad at redhat.com>
+
+ Fixes PR588, cookies set in the java cookie jar are now stored properly
+ * plugin/icedteanp/IcedTeaNPPlugin.cc
+ (set_cookie_info): New, uses setvalueforurl
+ (consume_plugin_message): Additional message added allowing
+ set_cookie_info to be used from the java side.
+ * plugin/icedteanp/java/sun/applet/PluginCookieManager.java: Now
+ overrides put method, results in set_cookie_info calls in C++
+ * plugin/icedteanp/java/sun/applet/PluginMain.java: Passes
+ PluginStreamHandler to PluginCookieManager to allow C++ side
+ communication
+
+2012-08-17 Adam Domurad <adomurad at redhat.com>
+
+ * plugin/icedteanp/IcedTeaNPPlugin.cc
+ (consume_plugin_message): New, called by consume_message, handles
+ cookie and proxy info retrieval, and setting cookie info
+ (consume_message): Call consume_plugin_message for "plugin ..."
+ messages
+
+2012-08-17 Adam Domurad <adomurad at redhat.com>
+
+ Reproducers for PR588, sets persistent and session cookies in the
+ cookie jar and tries to read them with various means.
+ * tests/reproducers/signed/SavingCookies/resources/CheckCookie.html:
+ Print the cookie store contents
+ * tests/reproducers/signed/SavingCookies/resources/CheckCookieAndGotoClear.html:
+ Print the cookie store contents, and then go to
+ ClearPersistentCookie.html with showDocument
+ * tests/reproducers/signed/SavingCookies/resources/ClearPersistentCookie.html:
+ Clear the test cookie so it does not interfere with further tests
+ * tests/reproducers/signed/SavingCookies/resources/SavePersistentCookie.html:
+ Create a persistent cookie
+ * tests/reproducers/signed/SavingCookies/resources/SavePersistentCookieAndGotoCheck.html:
+ Create a persistent cookie and check it with showDocument
+ * tests/reproducers/signed/SavingCookies/resources/SaveSessionCookie.html:
+ Create a session cookie
+ * tests/reproducers/signed/SavingCookies/resources/SaveSessionCookieAndGotoCheck.html:
+ Create a session cookie and check it with showDocument
+ * tests/reproducers/signed/SavingCookies/srcs/CheckingCookies.java:
+ Checks the contents of the cookie store.
+ Depending on the test, this may go to another page upon completion.
+ * tests/reproducers/signed/SavingCookies/srcs/SavingCookies.java:
+ Store cookies in the java cookie store. Depending on the test, this may
+ go to another page upon completion.
+ * tests/reproducers/signed/SavingCookies/testcases/SavingCookiesTests.java
+ Test driver for testing persistent and session cookies in different
+ ways
+
2012-08-18 Jiri Vanek <jvanek at redhat.com>
* tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java: added
diff -r aecafbcd8efa -r ae0cbdc9008a NEWS
--- a/NEWS Fri Aug 17 16:37:27 2012 +0200
+++ b/NEWS Fri Aug 17 11:46:58 2012 -0400
@@ -26,6 +26,7 @@
- PR1011: Folders treated as jar files in archive tag
- PR1106: Buffer overflow in plugin table
- PR975: Plugin should not include classpaths specified in jar manifests when using jnlp_href
+ - 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 aecafbcd8efa -r ae0cbdc9008a plugin/icedteanp/IcedTeaNPPlugin.cc
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc Fri Aug 17 16:37:27 2012 +0200
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc Fri Aug 17 11:46:58 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
@@ -1189,6 +1204,99 @@
return keep_installed;
}
+static
+void consume_plugin_message(gchar* message) {
+ // internal plugin related message
+ gchar** parts = g_strsplit (message, " ", 5);
+ if (g_str_has_prefix(parts[1], "PluginProxyInfo"))
+ {
+ gchar* proxy;
+ uint32_t len;
+
+ gchar* decoded_url = (gchar*) calloc(strlen(parts[4]) + 1, sizeof(gchar));
+ IcedTeaPluginUtilities::decodeURL(parts[4], &decoded_url);
+ PLUGIN_DEBUG("parts[0]=%s, parts[1]=%s, reference, parts[3]=%s, parts[4]=%s -- decoded_url=%s\n", parts[0], parts[1], parts[3], parts[4], decoded_url);
+
+ gchar* proxy_info;
+
+#if MOZILLA_VERSION_COLLAPSED < 1090100
+ proxy = (char*) malloc(sizeof(char)*2048);
+#endif
+
+ proxy_info = g_strconcat ("plugin PluginProxyInfo reference ", parts[3], " ", NULL);
+ if (get_proxy_info(decoded_url, &proxy, &len) == NPERR_NO_ERROR)
+ {
+ proxy_info = g_strconcat (proxy_info, proxy, NULL);
+ }
+
+ PLUGIN_DEBUG("Proxy info: %s\n", proxy_info);
+ plugin_send_message_to_appletviewer(proxy_info);
+
+ free(decoded_url);
+ decoded_url = NULL;
+ g_free(proxy_info);
+ proxy_info = NULL;
+
+#if MOZILLA_VERSION_COLLAPSED < 1090100
+ g_free(proxy);
+ proxy = NULL;
+#endif
+
+ } else if (g_str_has_prefix(parts[1], "PluginCookieInfo"))
+ {
+ gchar* decoded_url = (gchar*) calloc(strlen(parts[4])+1, sizeof(gchar));
+ IcedTeaPluginUtilities::decodeURL(parts[4], &decoded_url);
+
+ gchar* cookie_info = g_strconcat ("plugin PluginCookieInfo reference ", parts[3], " ", NULL);
+ gchar* cookie_string;
+ uint32_t len;
+ if (get_cookie_info(decoded_url, &cookie_string, &len) == NPERR_NO_ERROR)
+ {
+ cookie_info = g_strconcat (cookie_info, cookie_string, NULL);
+ }
+
+ PLUGIN_DEBUG("Cookie info: %s\n", cookie_info);
+ plugin_send_message_to_appletviewer(cookie_info);
+
+ free(decoded_url);
+ 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;
+}
+
void consume_message(gchar* message) {
PLUGIN_DEBUG (" PIPE: plugin read: %s\n", message);
@@ -1251,65 +1359,7 @@
}
else if (g_str_has_prefix (message, "plugin "))
{
- // internal plugin related message
- gchar** parts = g_strsplit (message, " ", 5);
- if (g_str_has_prefix(parts[1], "PluginProxyInfo"))
- {
- gchar* proxy;
- uint32_t len;
-
- gchar* decoded_url = (gchar*) calloc(strlen(parts[4]) + 1, sizeof(gchar));
- IcedTeaPluginUtilities::decodeURL(parts[4], &decoded_url);
- PLUGIN_DEBUG("parts[0]=%s, parts[1]=%s, reference, parts[3]=%s, parts[4]=%s -- decoded_url=%s\n", parts[0], parts[1], parts[3], parts[4], decoded_url);
-
- gchar* proxy_info;
-
-#if MOZILLA_VERSION_COLLAPSED < 1090100
- proxy = (char*) malloc(sizeof(char)*2048);
-#endif
-
- proxy_info = g_strconcat ("plugin PluginProxyInfo reference ", parts[3], " ", NULL);
- if (get_proxy_info(decoded_url, &proxy, &len) == NPERR_NO_ERROR)
- {
- proxy_info = g_strconcat (proxy_info, proxy, NULL);
- }
-
- PLUGIN_DEBUG("Proxy info: %s\n", proxy_info);
- plugin_send_message_to_appletviewer(proxy_info);
-
- free(decoded_url);
- decoded_url = NULL;
- g_free(proxy_info);
- proxy_info = NULL;
-
-#if MOZILLA_VERSION_COLLAPSED < 1090100
- g_free(proxy);
- proxy = NULL;
-#endif
-
- } else if (g_str_has_prefix(parts[1], "PluginCookieInfo"))
- {
- gchar* decoded_url = (gchar*) calloc(strlen(parts[4])+1, sizeof(gchar));
- IcedTeaPluginUtilities::decodeURL(parts[4], &decoded_url);
-
- gchar* cookie_info = g_strconcat ("plugin PluginCookieInfo reference ", parts[3], " ", NULL);
- gchar* cookie_string;
- uint32_t len;
- if (get_cookie_info(decoded_url, &cookie_string, &len) == NPERR_NO_ERROR)
- {
- cookie_info = g_strconcat (cookie_info, cookie_string, NULL);
- }
-
- PLUGIN_DEBUG("Cookie info: %s\n", cookie_info);
- plugin_send_message_to_appletviewer(cookie_info);
-
- free(decoded_url);
- decoded_url = NULL;
- g_free(cookie_info);
- cookie_info = NULL;
- }
- g_strfreev (parts);
- parts = NULL;
+ consume_plugin_message(message);
}
else
{
diff -r aecafbcd8efa -r ae0cbdc9008a plugin/icedteanp/java/sun/applet/PluginCookieManager.java
--- a/plugin/icedteanp/java/sun/applet/PluginCookieManager.java Fri Aug 17 16:37:27 2012 +0200
+++ b/plugin/icedteanp/java/sun/applet/PluginCookieManager.java Fri Aug 17 11:46:58 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 aecafbcd8efa -r ae0cbdc9008a plugin/icedteanp/java/sun/applet/PluginMain.java
--- a/plugin/icedteanp/java/sun/applet/PluginMain.java Fri Aug 17 16:37:27 2012 +0200
+++ b/plugin/icedteanp/java/sun/applet/PluginMain.java Fri Aug 17 11:46:58 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);
}
}
More information about the distro-pkg-dev
mailing list