Merge "Part of fix for bug 4997380: Some error types unknown to SslError"

This commit is contained in:
Kristian Monsen
2011-07-28 06:50:40 -07:00
committed by Android (Google) Code Review
3 changed files with 41 additions and 4 deletions

View File

@@ -11206,7 +11206,7 @@ package android.net.http {
method public boolean hasError(int);
field public static final int SSL_EXPIRED = 1; // 0x1
field public static final int SSL_IDMISMATCH = 2; // 0x2
field public static final int SSL_MAX_ERROR = 4; // 0x4
field public static final int SSL_MAX_ERROR = 6; // 0x6
field public static final int SSL_NOTYETVALID = 0; // 0x0
field public static final int SSL_UNTRUSTED = 3; // 0x3
}

View File

@@ -11541,9 +11541,11 @@ package android.net.http {
method public int getPrimaryError();
method public java.lang.String getUrl();
method public boolean hasError(int);
field public static final int SSL_DATE_INVALID = 4; // 0x4
field public static final int SSL_EXPIRED = 1; // 0x1
field public static final int SSL_IDMISMATCH = 2; // 0x2
field public static final int SSL_MAX_ERROR = 4; // 0x4
field public static final int SSL_INVALID = 5; // 0x5
field public static final deprecated int SSL_MAX_ERROR = 6; // 0x6
field public static final int SSL_NOTYETVALID = 0; // 0x0
field public static final int SSL_UNTRUSTED = 3; // 0x3
}

View File

@@ -30,7 +30,7 @@ public class SslError {
/**
* The certificate is not yet valid
*/
public static final int SSL_NOTYETVALID = 0;
public static final int SSL_NOTYETVALID = 0;
/**
* The certificate has expired
*/
@@ -43,12 +43,23 @@ public class SslError {
* The certificate authority is not trusted
*/
public static final int SSL_UNTRUSTED = 3;
/**
* The date of the certificate is invalid
*/
public static final int SSL_DATE_INVALID = 4;
/**
* The certificate is invalid
*/
public static final int SSL_INVALID = 5;
/**
* The number of different SSL errors (update if you add a new SSL error!!!)
* @deprecated This constant is not necessary for using the SslError API and
* can change from release to release.
*/
public static final int SSL_MAX_ERROR = 4;
@Deprecated
public static final int SSL_MAX_ERROR = 6;
/**
* The SSL error set bitfield (each individual error is an bit index;
@@ -116,6 +127,30 @@ public class SslError {
mUrl = url;
}
/**
* Creates an SslError object from a chromium error code.
* @param error The chromium error code
* @param certificate The associated SSL certificate
* @param url The associated URL.
* @hide chromium error codes only available inside the framework
*/
public static SslError SslErrorFromChromiumErrorCode(
int error, SslCertificate cert, String url) {
// The chromium error codes are in:
// external/chromium/net/base/net_error_list.h
if (error > -200 || error < -299) {
throw new NullPointerException("Not a valid chromium SSL error code.");
}
if (error == -200)
return new SslError(SSL_IDMISMATCH, cert, url);
if (error == -201)
return new SslError(SSL_DATE_INVALID, cert, url);
if (error == -202)
return new SslError(SSL_UNTRUSTED, cert, url);
// Map all other errors to SSL_INVALID
return new SslError(SSL_INVALID, cert, url);
}
/**
* Creates a new SSL error set object
* @param error The SSL error