private class NocWebViewClient extends WebViewClient {
@Override
public void onReceivedClientCertRequest(WebView view, final ClientCertRequest request) {
Log.v(getClass().getSimpleName(), "===> certificate required!");
KeyChain.choosePrivateKeyAlias(Form1.this, new KeyChainAliasCallback(){
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void alias(String alias) {
Log.v(getClass().getSimpleName(), "===>Key alias is: " + alias);
try {
PrivateKey changPrivateKey = KeyChain.getPrivateKey(Form1.this, alias);
X509Certificate[] certificates = KeyChain.getCertificateChain(Form1.this, alias);
Log.v(getClass().getSimpleName(), "===>Getting Private Key Success!" );
request.proceed(changPrivateKey, certificates);
} catch (KeyChainException e) {
Log.e(getClass().getSimpleName(), Util.printException(e));
} catch (InterruptedException e) {
Log.e(getClass().getSimpleName(), Util.printException(e));
}
}
},new String[]{"RSA"}, null, null, -1, null);
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
return true;
}
@Override
public void onPageFinished(WebView view, String url){
}