SslErrorpublic class SslError extends Object This class represents a set of one or more SSL errors and the associated SSL
certificate. |
Fields Summary |
---|
public static final int | SSL_NOTYETVALIDThe certificate is not yet valid | public static final int | SSL_EXPIREDThe certificate has expired | public static final int | SSL_IDMISMATCHHostname mismatch | public static final int | SSL_UNTRUSTEDThe certificate authority is not trusted | public static final int | SSL_DATE_INVALIDThe date of the certificate is invalid | public static final int | SSL_INVALIDA generic error occurred | public static final int | SSL_MAX_ERRORThe number of different SSL errors. | int | mErrorsThe SSL error set bitfield (each individual error is a bit index;
multiple individual errors can be OR-ed) | final SslCertificate | mCertificateThe SSL certificate associated with the error set | final String | mUrlThe URL associated with the error set. |
Constructors Summary |
---|
public SslError(int error, SslCertificate certificate)Creates a new SslError object using the supplied error and certificate.
The URL will be set to the empty string.
this(error, certificate, "");
| public SslError(int error, X509Certificate certificate)Creates a new SslError object using the supplied error and certificate.
The URL will be set to the empty string.
this(error, certificate, "");
| public SslError(int error, SslCertificate certificate, String url)Creates a new SslError object using the supplied error, certificate and
URL.
assert certificate != null;
assert url != null;
addError(error);
mCertificate = certificate;
mUrl = url;
| public SslError(int error, X509Certificate certificate, String url)Creates a new SslError object using the supplied error, certificate and
URL.
this(error, new SslCertificate(certificate), url);
|
Methods Summary |
---|
public static android.net.http.SslError | SslErrorFromChromiumErrorCode(int error, SslCertificate cert, java.lang.String url)Creates an SslError object from a chromium error code.
// The chromium error codes are in:
// external/chromium/net/base/net_error_list.h
assert (error >= -299 && error <= -200);
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 codes to SSL_INVALID.
return new SslError(SSL_INVALID, cert, url);
| public boolean | addError(int error)Adds the supplied SSL error to the set.
boolean rval = (0 <= error && error < SslError.SSL_MAX_ERROR);
if (rval) {
mErrors |= (0x1 << error);
}
return rval;
| public SslCertificate | getCertificate()Gets the SSL certificate associated with this object.
return mCertificate;
| public int | getPrimaryError()Gets the most severe SSL error in this object's set of errors.
Returns -1 if the set is empty.
if (mErrors != 0) {
// go from the most to the least severe errors
for (int error = SslError.SSL_MAX_ERROR - 1; error >= 0; --error) {
if ((mErrors & (0x1 << error)) != 0) {
return error;
}
}
// mErrors should never be set to an invalid value.
assert false;
}
return -1;
| public java.lang.String | getUrl()Gets the URL associated with this object.
return mUrl;
| public boolean | hasError(int error)Determines whether this object includes the supplied error.
boolean rval = (0 <= error && error < SslError.SSL_MAX_ERROR);
if (rval) {
rval = ((mErrors & (0x1 << error)) != 0);
}
return rval;
| public java.lang.String | toString()Returns a string representation of this object.
return "primary error: " + getPrimaryError() +
" certificate: " + getCertificate() +
" on URL: " + getUrl();
|
|