mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Add the ability to customize webview response to client cert requests
Summary: Add the ability to set a custom handler on ReactWebViewManager to handle client certificate challenges during TLS authentication. [Android][Added] - Public method setCustomClientCertRequestHandler to the native com.facebook.react.views.webview.ReactWebViewManager, that allows using a custom response for client certificate challenges. Reviewed By: mjhu Differential Revision: D14609697 fbshipit-source-id: 567c95458af638d1f8233fc3ca0d9cefc061c2bf
This commit is contained in:
committed by
Facebook Github Bot
parent
b10da79fb4
commit
9ddef77b1d
@@ -19,6 +19,7 @@ import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.webkit.ClientCertRequest;
|
||||
import android.webkit.ConsoleMessage;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.GeolocationPermissions;
|
||||
@@ -103,6 +104,8 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
|
||||
// Intent urls are a type of deeplinks which start with: intent://
|
||||
private static final String INTENT_URL_PREFIX = "intent://";
|
||||
|
||||
private static CustomClientCertRequestHandler customClientCertRequestHandler = null;
|
||||
|
||||
protected WebViewConfig mWebViewConfig;
|
||||
protected @Nullable WebView.PictureListener mPictureListener;
|
||||
|
||||
@@ -210,6 +213,15 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedClientCertRequest(WebView webview, ClientCertRequest request) {
|
||||
if (ReactWebViewManager.customClientCertRequestHandler != null) {
|
||||
ReactWebViewManager.customClientCertRequestHandler.handle(webview, request);
|
||||
} else {
|
||||
super.onReceivedClientCertRequest(webview, request);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(
|
||||
WebView webView, int errorCode, String description, String failingUrl) {
|
||||
@@ -734,4 +746,12 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
|
||||
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
|
||||
eventDispatcher.dispatchEvent(event);
|
||||
}
|
||||
|
||||
public static interface CustomClientCertRequestHandler {
|
||||
public void handle(WebView webview, ClientCertRequest request);
|
||||
}
|
||||
|
||||
public static void setCustomClientCertRequestHandler(CustomClientCertRequestHandler handler) {
|
||||
ReactWebViewManager.customClientCertRequestHandler = handler;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user