diff options
| author | 2011-06-28 09:38:47 -0700 | |
|---|---|---|
| committer | 2011-06-28 09:38:47 -0700 | |
| commit | fa487ca830cb150be5822d8d73c3d832672f7108 (patch) | |
| tree | e786e3a110230badb207c30d075721897c347710 | |
| parent | 5ba369f4f7ea4ad7e643c2aaae3ea49643510556 (diff) | |
| parent | 3015516a4611db23ce56ae057d281c9328cfdf24 (diff) | |
Merge "Gets the URL that has a cert error and carrys it in SslError."
| -rw-r--r-- | api/current.txt | 7 | ||||
| -rw-r--r-- | core/java/android/net/http/SslError.java | 68 | ||||
| -rw-r--r-- | core/java/android/webkit/BrowserFrame.java | 5 |
3 files changed, 73 insertions, 7 deletions
diff --git a/api/current.txt b/api/current.txt index e2f7f8b618c4..f5db8da77f7a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -11445,11 +11445,14 @@ package android.net.http { } public class SslError { - ctor public SslError(int, android.net.http.SslCertificate); - ctor public SslError(int, java.security.cert.X509Certificate); + ctor public deprecated SslError(int, android.net.http.SslCertificate); + ctor public deprecated SslError(int, java.security.cert.X509Certificate); + ctor public SslError(int, android.net.http.SslCertificate, java.lang.String); + ctor public SslError(int, java.security.cert.X509Certificate, java.lang.String); method public boolean addError(int); method public android.net.http.SslCertificate getCertificate(); method public int getPrimaryError(); + method public java.lang.String getUrl(); method public boolean hasError(int); field public static final int SSL_EXPIRED = 1; // 0x1 field public static final int SSL_IDMISMATCH = 2; // 0x2 diff --git a/core/java/android/net/http/SslError.java b/core/java/android/net/http/SslError.java index e1b9debb8f2b..1e1cb49dabad 100644 --- a/core/java/android/net/http/SslError.java +++ b/core/java/android/net/http/SslError.java @@ -59,36 +59,97 @@ public class SslError { /** * The SSL certificate associated with the error set */ - SslCertificate mCertificate; + final SslCertificate mCertificate; + + /** + * The URL associated with the error set. + */ + final String mUrl; /** * Creates a new SSL error set object * @param error The SSL error * @param certificate The associated SSL certificate + * @deprecated Use {@link #SslError(int, SslCertificate, String)} */ + @Deprecated public SslError(int error, SslCertificate certificate) { addError(error); + if (certificate == null) { + throw new NullPointerException("certificate is null."); + } mCertificate = certificate; + mUrl = ""; } /** * Creates a new SSL error set object * @param error The SSL error * @param certificate The associated SSL certificate + * @deprecated Use {@link #SslError(int, X509Certificate, String)} */ + @Deprecated public SslError(int error, X509Certificate certificate) { addError(error); + if (certificate == null) { + throw new NullPointerException("certificate is null."); + } mCertificate = new SslCertificate(certificate); + mUrl = ""; } /** - * @return The SSL certificate associated with the error set + * Creates a new SSL error set object + * @param error The SSL error + * @param certificate The associated SSL certificate + * @param url The associated URL. + */ + public SslError(int error, SslCertificate certificate, String url) { + addError(error); + if (certificate == null) { + throw new NullPointerException("certificate is null."); + } + mCertificate = certificate; + if (url == null) { + throw new NullPointerException("url is null."); + } + mUrl = url; + } + + /** + * Creates a new SSL error set object + * @param error The SSL error + * @param certificate The associated SSL certificate + * @param url The associated URL. + */ + public SslError(int error, X509Certificate certificate, String url) { + addError(error); + if (certificate == null) { + throw new NullPointerException("certificate is null."); + } + mCertificate = new SslCertificate(certificate); + if (url == null) { + throw new NullPointerException("url is null."); + } + mUrl = url; + } + + /** + * @return The SSL certificate associated with the error set, non-null. */ public SslCertificate getCertificate() { return mCertificate; } /** + * @return The URL associated with the error set, non-null. + * "" if one of the deprecated constructors is used. + */ + public String getUrl() { + return mUrl; + } + + /** * Adds the SSL error to the error set * @param error The SSL error to add * @return True iff the error being added is a known SSL error @@ -137,6 +198,7 @@ public class SslError { */ public String toString() { return "primary error: " + getPrimaryError() + - " certificate: " + getCertificate(); + " certificate: " + getCertificate() + + " on URL: " + getUrl(); } } diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java index 2f4774f61e17..79a5affffa44 100644 --- a/core/java/android/webkit/BrowserFrame.java +++ b/core/java/android/webkit/BrowserFrame.java @@ -1150,11 +1150,12 @@ class BrowserFrame extends Handler { * {@link #nativeSslCertErrorProceed(int)} or * {@link #nativeSslCertErrorCancel(int, int)}. */ - private void reportSslCertError(final int handle, final int cert_error, byte cert_der[]) { + private void reportSslCertError( + final int handle, final int cert_error, byte cert_der[], String url) { final SslError ssl_error; try { X509Certificate cert = new X509CertImpl(cert_der); - ssl_error = new SslError(cert_error, cert); + ssl_error = new SslError(cert_error, cert, url); } catch (IOException e) { // Can't get the certificate, not much to do. Log.e(LOGTAG, "Can't get the certificate from WebKit, canceling"); |