summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Gayed <grant_gayed@ca.ibm.com>2011-10-20 16:37:41 -0400
committerGrant Gayed <grant_gayed@ca.ibm.com>2011-10-20 16:37:41 -0400
commit9a54c1aa04b815cd59a20141bb2dcedb14acb097 (patch)
tree05f0551d581e2485bd7f3a95f945be1c96acc50f
parent83784a0bd43bf551a0a4fb21e5409eeadecd384d (diff)
downloadeclipse.platform.swt-9a54c1aa04b815cd59a20141bb2dcedb14acb097.tar.gz
eclipse.platform.swt-9a54c1aa04b815cd59a20141bb2dcedb14acb097.tar.xz
eclipse.platform.swt-9a54c1aa04b815cd59a20141bb2dcedb14acb097.zip
Bug 299013 - invalid certificate dialog not shown following
redirect
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp27
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java247
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/PromptService2.java29
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHttpChannel.java119
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHttpHeaderVisitor.java47
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsISeekableStream.java61
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIUploadChannel.java51
10 files changed, 556 insertions, 60 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp
index 1e5ec46838..484f719ea0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1210,6 +1210,31 @@ fail:
}
#endif
+#if (!defined(NO__1VtblCall__IIIJ) && !defined(JNI64)) || (!defined(NO__1VtblCall__IJIJ) && defined(JNI64))
+#ifndef JNI64
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(_1VtblCall__IIIJ)(JNIEnv *env, jclass that, jint arg0, jintLong arg1, jint arg2, jlong arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(_1VtblCall__IIIJ)(JNIEnv *env, jclass that, jint arg0, jintLong arg1, jint arg2, jlong arg3)
+#else
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(_1VtblCall__IJIJ)(JNIEnv *env, jclass that, jint arg0, jintLong arg1, jint arg2, jlong arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(_1VtblCall__IJIJ)(JNIEnv *env, jclass that, jint arg0, jintLong arg1, jint arg2, jlong arg3)
+#endif
+{
+ jint rc = 0;
+#ifndef JNI64
+ XPCOM_NATIVE_ENTER(env, that, _1VtblCall__IIIJ_FUNC);
+#else
+ XPCOM_NATIVE_ENTER(env, that, _1VtblCall__IJIJ_FUNC);
+#endif
+ rc = (jint)((jint (STDMETHODCALLTYPE *)(jintLong, jint, jlong))(*(jintLong **)arg1)[arg0])(arg1, arg2, arg3);
+#ifndef JNI64
+ XPCOM_NATIVE_EXIT(env, that, _1VtblCall__IIIJ_FUNC);
+#else
+ XPCOM_NATIVE_EXIT(env, that, _1VtblCall__IJIJ_FUNC);
+#endif
+ return rc;
+}
+#endif
+
#if (!defined(NO__1VtblCall__IIIJJ) && !defined(JNI64)) || (!defined(NO__1VtblCall__IJIJJ) && defined(JNI64))
#ifndef JNI64
extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(_1VtblCall__IIIJJ)(JNIEnv *env, jclass that, jint arg0, jintLong arg1, jint arg2, jlong arg3, jlong arg4);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp
index f0ac6ad2af..82abbf78b7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,8 +14,8 @@
#ifdef NATIVE_STATS
-int XPCOM_nativeFunctionCount = 226;
-int XPCOM_nativeFunctionCallCount[226];
+int XPCOM_nativeFunctionCount = 227;
+int XPCOM_nativeFunctionCallCount[227];
char * XPCOM_nativeFunctionNames[] = {
#ifndef JNI64
"_1Call__I",
@@ -219,6 +219,11 @@ char * XPCOM_nativeFunctionNames[] = {
"_1VtblCall__IJII_3J",
#endif
#ifndef JNI64
+ "_1VtblCall__IIIJ",
+#else
+ "_1VtblCall__IJIJ",
+#endif
+#ifndef JNI64
"_1VtblCall__IIIJJ",
#else
"_1VtblCall__IJIJJ",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h
index eef0e1bcb9..f51bdc96ca 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -227,6 +227,11 @@ typedef enum {
_1VtblCall__IJII_3J_FUNC,
#endif
#ifndef JNI64
+ _1VtblCall__IIIJ_FUNC,
+#else
+ _1VtblCall__IJIJ_FUNC,
+#endif
+#ifndef JNI64
_1VtblCall__IIIJJ_FUNC,
#else
_1VtblCall__IJIJJ_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
index bea10f2751..12721e336a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
@@ -46,7 +46,7 @@ class Mozilla extends WebBrowser {
int chromeFlags = nsIWebBrowserChrome.CHROME_DEFAULT;
int registerFunctionsOnState = 0;
int refCount, lastKeyCode, lastCharCode, authCount;
- int /*long*/ request;
+ int /*long*/ request, badCertRequest;
Point location, size;
boolean visible, isChild, ignoreDispose, isRetrievingBadCert, isViewingErrorPage, ignoreAllMessages, untrustedText;
boolean updateLastNavigateUrl;
@@ -2514,6 +2514,10 @@ void onDispose (Display display) {
locationListeners = oldLocationListeners;
}
+ if (badCertRequest != 0) {
+ new nsISupports (badCertRequest).Release ();
+ }
+
int rc = webBrowser.RemoveWebBrowserListener (weakReference.getAddress (), nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID);
if (rc != XPCOM.NS_OK) error (rc);
@@ -2593,6 +2597,150 @@ void Deactivate () {
webBrowserFocus.Release ();
}
+void navigate (int /*long*/ requestHandle) {
+ nsIRequest request = new nsIRequest (requestHandle);
+
+ /* get the request post data, if any */
+ int /*long*/[] result = new int /*long*/[1];
+ byte[] postData = null;
+ final Vector headers = new Vector ();
+ int rc = request.QueryInterface (nsIUploadChannel.NS_IUPLOADCHANNEL_IID, result);
+ if (rc == XPCOM.NS_OK && result[0] != 0) {
+ nsIUploadChannel uploadChannel = new nsIUploadChannel (result[0]);
+ result[0] = 0;
+ rc = uploadChannel.GetUploadStream (result);
+ if (rc == XPCOM.NS_OK && result[0] != 0) {
+ nsIInputStream inputStream = new nsIInputStream (result[0]);
+ result[0] = 0;
+ rc = inputStream.QueryInterface (nsISeekableStream.NS_ISEEKABLESTREAM_IID, result);
+ if (rc == XPCOM.NS_OK && result[0] != 0) {
+ nsISeekableStream seekableStream = new nsISeekableStream (result[0]);
+ result[0] = 0;
+ long[] initialOffset = new long[1];
+ rc = seekableStream.Tell (initialOffset);
+ if (rc == XPCOM.NS_OK) {
+ rc = seekableStream.Seek (nsISeekableStream.NS_SEEK_SET, 0);
+ if (rc == XPCOM.NS_OK) {
+ int[] available = new int[1];
+ rc = inputStream.Available (available);
+ if (rc == XPCOM.NS_OK) {
+ int length = available[0];
+ byte[] bytes = new byte[length];
+ int[] retVal = new int[1];
+ rc = inputStream.Read (bytes, length, retVal);
+ if (rc == XPCOM.NS_OK) {
+ int start = 0;
+ for (int i = 0; i < length; i++) {
+ if (bytes[i] == 13) {
+ byte[] current = new byte[i - start];
+ System.arraycopy (bytes, start, current, 0, i - start);
+ String string = new String (current).trim ();
+ if (string.length () != 0) {
+ headers.add (string);
+ } else {
+ start = i + 2; /* skip \r\n */
+ postData = new byte[length - start];
+ System.arraycopy (bytes, start, postData, 0, length - start);
+ break;
+ }
+ start = i;
+ }
+ }
+ }
+ }
+ }
+ seekableStream.Seek (nsISeekableStream.NS_SEEK_SET, initialOffset[0]);
+ }
+ seekableStream.Release ();
+ }
+ inputStream.Release ();
+ }
+ uploadChannel.Release ();
+ }
+
+ /* get the request headers */
+ XPCOMObject visitor = new XPCOMObject (new int[] {2, 0, 0, 2}) {
+ int refCount = 0;
+ public int /*long*/ method0 (int /*long*/[] args) {
+ /* QueryInterface */
+ int /*long*/ riid = args[0];
+ int /*long*/ ppvObject = args[1];
+ if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+ nsID guid = new nsID ();
+ XPCOM.memmove (guid, riid, nsID.sizeof);
+ if (guid.Equals (nsISupports.NS_ISUPPORTS_IID) || guid.Equals (nsIHttpHeaderVisitor.NS_IHTTPHEADERVISITOR_IID)) {
+ XPCOM.memmove (ppvObject, new int /*long*/[] {getAddress ()}, C.PTR_SIZEOF);
+ refCount++;
+ return XPCOM.NS_OK;
+ }
+ XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+ return XPCOM.NS_ERROR_NO_INTERFACE;
+ }
+ public int /*long*/ method1 (int /*long*/[] args) {
+ /* AddRef */
+ return ++refCount;
+ }
+ public int /*long*/ method2 (int /*long*/[] args) {
+ /* Release */
+ if (--refCount == 0) dispose ();
+ return refCount;
+ }
+ public int /*long*/ method3 (int /*long*/[] args) {
+ /* VisitHeader */
+ int /*long*/ aHeader = args[0];
+ int /*long*/ aValue = args[1];
+
+ int length = XPCOM.nsEmbedCString_Length (aHeader);
+ int /*long*/ buffer = XPCOM.nsEmbedCString_get (aHeader);
+ byte[] dest = new byte[length];
+ XPCOM.memmove (dest, buffer, length);
+ String header = new String (dest);
+
+ length = XPCOM.nsEmbedCString_Length (aValue);
+ buffer = XPCOM.nsEmbedCString_get (aValue);
+ dest = new byte[length];
+ XPCOM.memmove (dest, buffer, length);
+ String value = new String (dest);
+
+ headers.add(header + ':' + value);
+ return XPCOM.NS_OK;
+ }
+ };
+
+ new nsISupports (visitor.getAddress ()).AddRef ();
+ rc = request.QueryInterface (nsIHttpChannel.NS_IHTTPCHANNEL_IID, result);
+ if (rc == XPCOM.NS_OK && result[0] != 0) {
+ nsIHttpChannel httpChannel = new nsIHttpChannel (result[0]);
+ result[0] = 0;
+ httpChannel.VisitRequestHeaders (visitor.getAddress ());
+ httpChannel.Release ();
+ }
+ new nsISupports (visitor.getAddress ()).Release ();
+
+ String[] headersArray = null;
+ int size = headers.size ();
+ if (size > 0) {
+ headersArray = new String[size];
+ headers.copyInto (headersArray);
+ }
+
+ /* a request's name often (but not always) is its url */
+ String url = lastNavigateURL;
+ int /*long*/ name = XPCOM.nsEmbedCString_new ();
+ rc = request.GetName (name);
+ if (rc == XPCOM.NS_OK) {
+ int length = XPCOM.nsEmbedCString_Length (name);
+ int /*long*/ buffer = XPCOM.nsEmbedCString_get (name);
+ byte[] bytes = new byte[length];
+ XPCOM.memmove (bytes, buffer, length);
+ String value = new String (bytes);
+ if (value.indexOf (":/") != -1) url = value; //$NON-NLS-1$
+ }
+ XPCOM.nsEmbedCString_delete (name);
+
+ setUrl (url, postData, headersArray);
+}
+
void onResize () {
Rectangle rect = browser.getClientArea ();
int width = Math.max (1, rect.width);
@@ -2782,6 +2930,14 @@ public boolean setText (String html, boolean trusted) {
}
public boolean setUrl (String url, String postData, String[] headers) {
+ byte[] postDataBytes = null;
+ if (postData != null) {
+ postDataBytes = MozillaDelegate.wcsToMbcs (null, postData, false);
+ }
+ return setUrl (url, postDataBytes, headers);
+}
+
+boolean setUrl (String url, byte[] postData, String[] headers) {
htmlBytes = null;
int /*long*/[] result = new int /*long*/[1];
@@ -2814,8 +2970,7 @@ public boolean setUrl (String url, String postData, String[] headers) {
componentManager.Release();
if (rc == XPCOM.NS_OK && result[0] != 0) { /* nsIMIMEInputStream is not in mozilla 1.4 */
- byte[] bytes = MozillaDelegate.wcsToMbcs (null, postData, false);
- dataStream = new InputStream (bytes);
+ dataStream = new InputStream (postData);
dataStream.AddRef ();
postDataStream = new nsIMIMEInputStream (result[0]);
rc = postDataStream.SetData (dataStream.getAddress ());
@@ -3201,7 +3356,6 @@ int OnStateChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateF
* callbacks on the channel so that our nsIBadCertListener2 will be invoked.
*/
if (isRetrievingBadCert) {
- isRetrievingBadCert = false;
nsIRequest request = new nsIRequest (aRequest);
int rc = request.QueryInterface (nsIChannel.NS_ICHANNEL_IID, result);
if (rc != XPCOM.NS_OK) error (rc);
@@ -3233,6 +3387,37 @@ int OnStateChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateF
registerFunctionsOnState = nsIWebProgressListener.STATE_TRANSFERRING;
updateLastNavigateUrl = true;
} else if ((aStateFlags & nsIWebProgressListener.STATE_STOP) != 0) {
+ if (isRetrievingBadCert) {
+ isRetrievingBadCert = false;
+ return XPCOM.NS_OK;
+ }
+
+ /*
+ * If a site with a bad certificate is being encountered for the first time
+ * then store the request for future reference, set the isRetrievingBadCert
+ * flag and re-navigate to the site so that notification callbacks can be
+ * hooked on it to get its certificate info.
+ */
+ switch (aStatus) {
+ case XPCOM.SSL_ERROR_BAD_CERT_DOMAIN:
+ case XPCOM.SEC_ERROR_CA_CERT_INVALID:
+ case XPCOM.SEC_ERROR_EXPIRED_CERTIFICATE:
+ case XPCOM.SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE:
+ case XPCOM.SEC_ERROR_INADEQUATE_KEY_USAGE:
+ case XPCOM.SEC_ERROR_UNKNOWN_ISSUER:
+ case XPCOM.SEC_ERROR_UNTRUSTED_CERT:
+ case XPCOM.SEC_ERROR_UNTRUSTED_ISSUER: {
+ new nsISupports (aRequest).AddRef ();
+ if (badCertRequest != 0) {
+ new nsISupports (badCertRequest).Release ();
+ }
+ badCertRequest = aRequest;
+ isRetrievingBadCert = true;
+ navigate (aRequest);
+ return XPCOM.NS_OK;
+ }
+ }
+
/*
* If this page's nsIDOMWindow handle is still in unhookedDOMWindows then
* add its DOM listeners now. It's possible for this to happen since
@@ -3973,7 +4158,7 @@ int OnStartURIOpen (int /*long*/ aURI, int /*long*/ retval) {
if (value.indexOf ("aboutCertError.xhtml") != -1 || (isViewingErrorPage && value.indexOf ("javascript:showSecuritySection") != -1)) { //$NON-NLS-1$ //$NON-NLS-2$
XPCOM.memmove (retval, new int[] {1}, 4); /* PRBool */
isRetrievingBadCert = true;
- setUrl (lastNavigateURL, null, null);
+ setUrl (lastNavigateURL, (byte[])null, null);
return XPCOM.NS_OK;
}
isViewingErrorPage = value.indexOf ("netError.xhtml") != -1; //$NON-NLS-1$
@@ -4635,33 +4820,35 @@ int NotifyCertProblem (int /*long*/ socketInfo, int /*long*/ status, int /*long*
browser.getDisplay().asyncExec(new Runnable() {
public void run() {
if (browser.isDisposed ()) return;
- if (!url.equals (lastNavigateURL)) return; /* user has navigated elsewhere */
-
- String message = Compatibility.getMessage ("SWT_InvalidCert_Message", new String[] {urlPort}); //$NON-NLS-1$
- if (new PromptDialog (browser.getShell ()).invalidCert (browser, message, finalProblems, cert)) {
- int /*long*/[] result = new int /*long*/[1];
- int rc = XPCOM.NS_GetServiceManager (result);
- if (rc != XPCOM.NS_OK) error (rc);
- if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
-
- nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
- result[0] = 0;
- byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_CERTOVERRIDE_CONTRACTID, true);
- rc = serviceManager.GetServiceByContractID (aContractID, nsICertOverrideService.NS_ICERTOVERRIDESERVICE_IID, result);
- if (rc != XPCOM.NS_OK) error (rc);
- if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
- serviceManager.Release ();
-
- nsICertOverrideService overrideService = new nsICertOverrideService (result[0]);
- result[0] = 0;
- byte[] hostBytes = MozillaDelegate.wcsToMbcs (null, host, false);
- int /*long*/ hostString = XPCOM.nsEmbedCString_new (hostBytes, hostBytes.length);
- rc = overrideService.RememberValidityOverride (hostString, port, cert.getAddress (), finalFlags, 1);
- browser.setUrl (url);
- XPCOM.nsEmbedCString_delete (hostString);
- overrideService.Release ();
+ if (url.equals (lastNavigateURL)) {
+ String message = Compatibility.getMessage ("SWT_InvalidCert_Message", new String[] {urlPort}); //$NON-NLS-1$
+ if (new PromptDialog (browser.getShell ()).invalidCert (browser, message, finalProblems, cert)) {
+ int /*long*/[] result = new int /*long*/[1];
+ int rc = XPCOM.NS_GetServiceManager (result);
+ if (rc != XPCOM.NS_OK) error (rc);
+ if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+ nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+ result[0] = 0;
+ byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_CERTOVERRIDE_CONTRACTID, true);
+ rc = serviceManager.GetServiceByContractID (aContractID, nsICertOverrideService.NS_ICERTOVERRIDESERVICE_IID, result);
+ if (rc != XPCOM.NS_OK) error (rc);
+ if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+ serviceManager.Release ();
+
+ nsICertOverrideService overrideService = new nsICertOverrideService (result[0]);
+ result[0] = 0;
+ byte[] hostBytes = MozillaDelegate.wcsToMbcs (null, host, false);
+ int /*long*/ hostString = XPCOM.nsEmbedCString_new (hostBytes, hostBytes.length);
+ rc = overrideService.RememberValidityOverride (hostString, port, cert.getAddress (), finalFlags, 1);
+ navigate (badCertRequest);
+ XPCOM.nsEmbedCString_delete (hostString);
+ overrideService.Release ();
+ }
}
cert.Release ();
+ new nsISupports (badCertRequest).Release ();
+ badCertRequest = 0;
}
});
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/PromptService2.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/PromptService2.java
index 7f1d718a43..c641a2409b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/PromptService2.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/PromptService2.java
@@ -21,17 +21,6 @@ class PromptService2 {
XPCOMObject promptService2;
int refCount = 0;
- static final String[] certErrorCodes = new String[] {
- "ssl_error_bad_cert_domain",
- "sec_error_ca_cert_invalid",
- "sec_error_expired_certificate",
- "sec_error_expired_issuer_certificate",
- "sec_error_inadequate_key_usage",
- "sec_error_unknown_issuer",
- "sec_error_untrusted_cert",
- "sec_error_untrusted_issuer",
- }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
-
PromptService2 () {
createCOMInterfaces ();
}
@@ -173,22 +162,12 @@ int Alert (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText)
String textLabel = new String (dest);
/*
- * If mozilla is showing its errors with dialogs (as opposed to pages) then the only
- * opportunity to detect that a page has an invalid certificate, without receiving
- * all notification callbacks on the channel, is to detect the displaying of an alert
- * whose message contains an internal cert error code. If a such a message is
- * detected then instead of showing it, re-navigate to the page with the invalid
- * certificate so that the browser's nsIBadCertListener2 will be invoked.
+ * If mozilla is re-navigating to a page with a bad certificate in order
+ * to get its certificate info then do not show cert error message alerts.
*/
if (browser != null) {
- for (int i = 0; i < certErrorCodes.length; i++) {
- if (textLabel.indexOf (certErrorCodes[i]) != -1) {
- Mozilla mozilla = (Mozilla)browser.webBrowser;
- mozilla.isRetrievingBadCert = true;
- browser.setUrl (mozilla.lastNavigateURL);
- return XPCOM.NS_OK;
- }
- }
+ Mozilla mozilla = (Mozilla)browser.webBrowser;
+ if (mozilla.isRetrievingBadCert) return XPCOM.NS_OK;
}
Shell shell = browser == null ? new Shell () : browser.getShell ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java
index 3d8d084526..203fc0ce16 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java
@@ -132,6 +132,14 @@ public class XPCOM extends C {
public static final int NS_ERROR_HTMLPARSER_UNRESOLVEDDTD = 0x804e03f3;
public static final int NS_ERROR_FILE_NOT_FOUND = 0x80520012;
public static final int NS_ERROR_FILE_UNRECOGNIZED_PATH = 0x80520001;
+ public static final int SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE = 0x805A1FE2;
+ public static final int SEC_ERROR_CA_CERT_INVALID = 0x805A1FDC;
+ public static final int SEC_ERROR_EXPIRED_CERTIFICATE = 0x805A1FF5;
+ public static final int SEC_ERROR_INADEQUATE_KEY_USAGE = 0x805A1FA6;
+ public static final int SEC_ERROR_UNKNOWN_ISSUER = 0x805A1FF3;
+ public static final int SEC_ERROR_UNTRUSTED_CERT = 0x805A1FEB;
+ public static final int SEC_ERROR_UNTRUSTED_ISSUER = 0x805A1FEC;
+ public static final int SSL_ERROR_BAD_CERT_DOMAIN = 0x805A2FF4;
public static final native int nsDynamicFunctionLoad_sizeof ();
@@ -663,6 +671,15 @@ static final int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1)
lock.unlock();
}
}
+static final native int _VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, long arg1);
+static final int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, long arg1) {
+ lock.lock();
+ try {
+ return _VtblCall(fnNumber, ppVtbl, arg0, arg1);
+ } finally {
+ lock.unlock();
+ }
+}
static final native int _VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, int arg1);
static final int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, int arg1) {
lock.lock();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHttpChannel.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHttpChannel.java
new file mode 100644
index 0000000000..eb19f2a696
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHttpChannel.java
@@ -0,0 +1,119 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * - Binding to permit interfacing between Mozilla and SWT
+ * - Copyright (C) 2011 IBM Corp. All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIHttpChannel extends nsIChannel {
+
+ static final int LAST_METHOD_ID = nsIChannel.LAST_METHOD_ID + 19;
+
+ public static final String NS_IHTTPCHANNEL_IID_STR =
+ "9277fe09-f0cc-4cd9-bbce-581dd94b0260";
+
+ public static final nsID NS_IHTTPCHANNEL_IID =
+ new nsID(NS_IHTTPCHANNEL_IID_STR);
+
+ public nsIHttpChannel(int /*long*/ address) {
+ super(address);
+ }
+
+ public int GetRequestMethod(int /*long*/ aRequestMethod) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 1, getAddress(), aRequestMethod);
+ }
+
+ public int SetRequestMethod(int /*long*/ aRequestMethod) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 2, getAddress(), aRequestMethod);
+ }
+
+ public int GetReferrer(int /*long*/[] aReferrer) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 3, getAddress(), aReferrer);
+ }
+
+ public int SetReferrer(int /*long*/ aReferrer) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 4, getAddress(), aReferrer);
+ }
+
+ public int GetRequestHeader(int /*long*/ aHeader, int /*long*/ _retval) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 5, getAddress(), aHeader, _retval);
+ }
+
+ public int SetRequestHeader(int /*long*/ aHeader, int /*long*/ aValue, int aMerge) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 6, getAddress(), aHeader, aValue, aMerge);
+ }
+
+ public int VisitRequestHeaders(int /*long*/ aVisitor) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 7, getAddress(), aVisitor);
+ }
+
+ public int GetAllowPipelining(int[] aAllowPipelining) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 8, getAddress(), aAllowPipelining);
+ }
+
+ public int SetAllowPipelining(int aAllowPipelining) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 9, getAddress(), aAllowPipelining);
+ }
+
+ public int GetRedirectionLimit(int[] aRedirectionLimit) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 10, getAddress(), aRedirectionLimit);
+ }
+
+ public int SetRedirectionLimit(int aRedirectionLimit) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 11, getAddress(), aRedirectionLimit);
+ }
+
+ public int GetResponseStatus(int[] aResponseStatus) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 12, getAddress(), aResponseStatus);
+ }
+
+ public int GetResponseStatusText(int /*long*/ aResponseStatusText) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 13, getAddress(), aResponseStatusText);
+ }
+
+ public int GetRequestSucceeded(int[] aRequestSucceeded) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 14, getAddress(), aRequestSucceeded);
+ }
+
+ public int GetResponseHeader(int /*long*/ header, int /*long*/ _retval) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 15, getAddress(), header, _retval);
+ }
+
+ public int SetResponseHeader(int /*long*/ header, int /*long*/ value, int merge) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 16, getAddress(), header, value, merge);
+ }
+
+ public int VisitResponseHeaders(int /*long*/ aVisitor) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 17, getAddress(), aVisitor);
+ }
+
+ public int IsNoStoreResponse(int[] _retval) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 18, getAddress(), _retval);
+ }
+
+ public int IsNoCacheResponse(int[] _retval) {
+ return XPCOM.VtblCall(nsIChannel.LAST_METHOD_ID + 19, getAddress(), _retval);
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHttpHeaderVisitor.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHttpHeaderVisitor.java
new file mode 100644
index 0000000000..556a5e22c8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHttpHeaderVisitor.java
@@ -0,0 +1,47 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * - Binding to permit interfacing between Mozilla and SWT
+ * - Copyright (C) 2011 IBM Corp. All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIHttpHeaderVisitor extends nsISupports {
+
+ static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 1;
+
+ public static final String NS_IHTTPHEADERVISITOR_IID_STR =
+ "0cf40717-d7c1-4a94-8c1e-d6c9734101bb";
+
+ public static final nsID NS_IHTTPHEADERVISITOR_IID =
+ new nsID(NS_IHTTPHEADERVISITOR_IID_STR);
+
+ public nsIHttpHeaderVisitor(int /*long*/ address) {
+ super(address);
+ }
+
+ public int VisitHeader(int /*long*/ aHeader, int /*long*/ aValue) {
+ return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aHeader, aValue);
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsISeekableStream.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsISeekableStream.java
new file mode 100644
index 0000000000..32a49203cf
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsISeekableStream.java
@@ -0,0 +1,61 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * - Binding to permit interfacing between Mozilla and SWT
+ * - Copyright (C) 2011 IBM Corp. All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsISeekableStream extends nsISupports {
+
+ static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 3;
+
+ public static final String NS_ISEEKABLESTREAM_IID_STR =
+ "8429d350-1040-4661-8b71-f2a6ba455980";
+
+ public static final nsID NS_ISEEKABLESTREAM_IID =
+ new nsID(NS_ISEEKABLESTREAM_IID_STR);
+
+ public nsISeekableStream(int /*long*/ address) {
+ super(address);
+ }
+
+ public static final int NS_SEEK_SET = 0;
+
+ public static final int NS_SEEK_CUR = 1;
+
+ public static final int NS_SEEK_END = 2;
+
+ public int Seek(int whence, long offset) {
+ return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), whence, offset);
+ }
+
+ public int Tell(long[] _retval) {
+ return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), _retval);
+ }
+
+ public int SetEOF() {
+ return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress());
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIUploadChannel.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIUploadChannel.java
new file mode 100644
index 0000000000..08807366f7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIUploadChannel.java
@@ -0,0 +1,51 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * - Binding to permit interfacing between Mozilla and SWT
+ * - Copyright (C) 2011 IBM Corp. All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIUploadChannel extends nsISupports {
+
+ static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 2;
+
+ public static final String NS_IUPLOADCHANNEL_IID_STR =
+ "ddf633d8-e9a4-439d-ad88-de636fd9bb75";
+
+ public static final nsID NS_IUPLOADCHANNEL_IID =
+ new nsID(NS_IUPLOADCHANNEL_IID_STR);
+
+ public nsIUploadChannel(int /*long*/ address) {
+ super(address);
+ }
+
+ public int SetUploadStream(int /*long*/ aStream, int /*long*/ aContentType, int aContentLength) {
+ return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aStream, aContentType, aContentLength);
+ }
+
+ public int GetUploadStream(int /*long*/[] aUploadStream) {
+ return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aUploadStream);
+ }
+}