1616
1717package android .webkit ;
1818
19+ import android .os .Handler ;
1920import java .security .PrivateKey ;
2021import java .security .cert .CertificateEncodingException ;
2122import java .security .cert .X509Certificate ;
2930 *
3031 * @hide
3132 */
32- public final class ClientCertRequestHandler {
33+ public final class ClientCertRequestHandler extends Handler {
3334
3435 private final BrowserFrame mBrowserFrame ;
3536 private final int mHandle ;
@@ -49,30 +50,46 @@ public final class ClientCertRequestHandler {
4950 * Proceed with the specified private key and client certificate chain.
5051 */
5152 public void proceed (PrivateKey privateKey , X509Certificate [] chain ) {
52- byte [] privateKeyBytes = privateKey .getEncoded ();
53- byte [][] chainBytes ;
53+ final byte [] privateKeyBytes = privateKey .getEncoded ();
54+ final byte [][] chainBytes ;
5455 try {
5556 chainBytes = NativeCrypto .encodeCertificates (chain );
57+ mTable .Allow (mHostAndPort , privateKeyBytes , chainBytes );
58+ post (new Runnable () {
59+ public void run () {
60+ mBrowserFrame .nativeSslClientCert (mHandle , privateKeyBytes , chainBytes );
61+ }
62+ });
5663 } catch (CertificateEncodingException e ) {
57- mBrowserFrame .nativeSslClientCert (mHandle , null , null );
58- return ;
64+ post (new Runnable () {
65+ public void run () {
66+ mBrowserFrame .nativeSslClientCert (mHandle , null , null );
67+ return ;
68+ }
69+ });
5970 }
60- mTable .Allow (mHostAndPort , privateKeyBytes , chainBytes );
61- mBrowserFrame .nativeSslClientCert (mHandle , privateKeyBytes , chainBytes );
6271 }
6372
6473 /**
6574 * Igore the request for now, the user may be prompted again.
6675 */
6776 public void ignore () {
68- mBrowserFrame .nativeSslClientCert (mHandle , null , null );
77+ post (new Runnable () {
78+ public void run () {
79+ mBrowserFrame .nativeSslClientCert (mHandle , null , null );
80+ }
81+ });
6982 }
7083
7184 /**
7285 * Cancel this request, remember the users negative choice.
7386 */
7487 public void cancel () {
7588 mTable .Deny (mHostAndPort );
76- mBrowserFrame .nativeSslClientCert (mHandle , null , null );
89+ post (new Runnable () {
90+ public void run () {
91+ mBrowserFrame .nativeSslClientCert (mHandle , null , null );
92+ }
93+ });
7794 }
7895}
0 commit comments