summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarun Nainani <tnainani@codeaurora.org>2015-07-31 11:37:16 -0700
committerjrizzoli <joey@cyanogenmoditalia.it>2015-08-28 13:15:47 +0200
commitcf41be035f53a4c77a67bb301830896f1969c97c (patch)
treed0228dcf176fabbc4ceb7e1ee36b48ffca0ad607
parent7c762c8c002977068ac965a3a94d47c908a59f3e (diff)
downloadandroid_packages_apps_Gello-cf41be035f53a4c77a67bb301830896f1969c97c.tar.gz
android_packages_apps_Gello-cf41be035f53a4c77a67bb301830896f1969c97c.tar.bz2
android_packages_apps_Gello-cf41be035f53a4c77a67bb301830896f1969c97c.zip
Fix crash while trying to load client certificate
Provide default implementation for PKCS11AuthenticationManager to fix null pointer crash. Clean-up client certificate api as now we use chromium's implementation for the same. Change-Id: I10c69b5d168e03ffb3fd9767bd17d5374e161111
-rw-r--r--src/com/android/browser/Browser.java3
-rw-r--r--src/com/android/browser/KeyChainLookup.java52
-rw-r--r--src/com/android/browser/Tab.java40
-rw-r--r--tests/src/com/android/browser/PopularUrlsTest.java11
-rw-r--r--tests/src/com/android/browser/TestWebViewClient.java12
5 files changed, 2 insertions, 116 deletions
diff --git a/src/com/android/browser/Browser.java b/src/com/android/browser/Browser.java
index 6fb8ca27..8270cfbc 100644
--- a/src/com/android/browser/Browser.java
+++ b/src/com/android/browser/Browser.java
@@ -27,6 +27,7 @@ import android.os.Process;
import org.chromium.chrome.browser.ChromiumApplication;
import org.chromium.chrome.browser.PKCS11AuthenticationManager;
+import org.codeaurora.swe.SWEEmptyPKCS11AuthenticationManager;
import org.codeaurora.swe.Engine;
@@ -126,7 +127,7 @@ public class Browser extends ChromiumApplication {
@Override
protected PKCS11AuthenticationManager getPKCS11AuthenticationManager() {
- return null;
+ return new SWEEmptyPKCS11AuthenticationManager();
}
@Override
diff --git a/src/com/android/browser/KeyChainLookup.java b/src/com/android/browser/KeyChainLookup.java
deleted file mode 100644
index 5bd86b50..00000000
--- a/src/com/android/browser/KeyChainLookup.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 201 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.browser;
-
-import android.content.Context;
-import android.os.AsyncTask;
-import android.security.KeyChain;
-import android.security.KeyChainException;
-import org.codeaurora.swe.ClientCertRequestHandler;
-import java.security.PrivateKey;
-import java.security.cert.X509Certificate;
-
-final class KeyChainLookup extends AsyncTask<Void, Void, Void> {
- private final Context mContext;
- private final ClientCertRequestHandler mHandler;
- private final String mAlias;
- KeyChainLookup(Context context, ClientCertRequestHandler handler, String alias) {
- mContext = context.getApplicationContext();
- mHandler = handler;
- mAlias = alias;
- }
- @Override protected Void doInBackground(Void... params) {
- PrivateKey privateKey;
- X509Certificate[] certificateChain;
- try {
- privateKey = KeyChain.getPrivateKey(mContext, mAlias);
- certificateChain = KeyChain.getCertificateChain(mContext, mAlias);
- } catch (InterruptedException e) {
- mHandler.ignore();
- return null;
- } catch (KeyChainException e) {
- mHandler.ignore();
- return null;
- }
- mHandler.proceed(privateKey, certificateChain);
- return null;
- }
-}
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index f533f6c1..bb1ec9da 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -64,7 +64,6 @@ import com.android.browser.provider.SnapshotProvider.Snapshots;
import org.codeaurora.swe.BrowserCommandLine;
import org.codeaurora.swe.BrowserDownloadListener;
-import org.codeaurora.swe.ClientCertRequestHandler;
import org.codeaurora.swe.HttpAuthHandler;
import org.codeaurora.swe.WebBackForwardList;
import org.codeaurora.swe.WebChromeClient;
@@ -490,45 +489,6 @@ class Tab implements PictureListener {
}
/**
- * Displays client certificate request to the user.
- */
- @Override
- public void onReceivedClientCertRequest(final WebView view,
- final ClientCertRequestHandler handler, final String host_and_port) {
- if (!mInForeground) {
- handler.ignore();
- return;
- }
- int colon = host_and_port.lastIndexOf(':');
- String host;
- int port;
- if (colon == -1) {
- host = host_and_port;
- port = -1;
- } else {
- String portString = host_and_port.substring(colon + 1);
- try {
- port = Integer.parseInt(portString);
- host = host_and_port.substring(0, colon);
- } catch (NumberFormatException e) {
- host = host_and_port;
- port = -1;
- }
- }
- KeyChain.choosePrivateKeyAlias(
- mWebViewController.getActivity(), new KeyChainAliasCallback() {
- @Override
- public void alias(String alias) {
- if (alias == null) {
- handler.cancel();
- return;
- }
- new KeyChainLookup(mContext, handler, alias).execute();
- }
- }, null, null, host, port, null);
- }
-
- /**
* Handles an HTTP authentication request.
*
* @param handler The authentication handler
diff --git a/tests/src/com/android/browser/PopularUrlsTest.java b/tests/src/com/android/browser/PopularUrlsTest.java
index 908ee684..0070948e 100644
--- a/tests/src/com/android/browser/PopularUrlsTest.java
+++ b/tests/src/com/android/browser/PopularUrlsTest.java
@@ -25,7 +25,6 @@ import android.provider.Browser;
import android.test.ActivityInstrumentationTestCase2;
import android.text.TextUtils;
import android.util.Log;
-import android.webkit.ClientCertRequestHandler;
import android.webkit.DownloadListener;
import android.webkit.HttpAuthHandler;
import android.webkit.JsPromptResult;
@@ -230,16 +229,6 @@ public class PopularUrlsTest extends ActivityInstrumentationTestCase2<BrowserAct
}
/**
- * Ignores and logs SSL client certificate requests.
- */
- @Override
- public void onReceivedClientCertRequest(WebView view, ClientCertRequestHandler handler,
- String host_and_port) {
- Log.w(TAG, "SSL client certificate request: " + host_and_port);
- handler.cancel();
- }
-
- /**
* Ignores http auth with dummy username and password
*/
@Override
diff --git a/tests/src/com/android/browser/TestWebViewClient.java b/tests/src/com/android/browser/TestWebViewClient.java
index 7b774480..c092c96e 100644
--- a/tests/src/com/android/browser/TestWebViewClient.java
+++ b/tests/src/com/android/browser/TestWebViewClient.java
@@ -22,7 +22,6 @@ import android.os.Message;
import android.view.KeyEvent;
import android.webkit.WebViewClientClassicExt;
-import org.codeaurora.swe.ClientCertRequestHandler;
import org.codeaurora.swe.HttpAuthHandler;
import org.codeaurora.swe.SslErrorHandler;
import org.codeaurora.swe.WebView;
@@ -104,17 +103,6 @@ abstract class TestWebViewClient extends WebViewClientClassicExt {
/** {@inheritDoc} */
@Override
- public void onReceivedClientCertRequest(WebView view, ClientCertRequestHandler handler,
- String host_and_port) {
- if (mWrappedClient instanceof WebViewClientClassicExt) {
- ((WebViewClientClassicExt) mWrappedClient).onReceivedClientCertRequest(view, handler, host_and_port);
- } else {
- super.onReceivedClientCertRequest(view, handler, host_and_port);
- }
- }
-
- /** {@inheritDoc} */
- @Override
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
mWrappedClient.onReceivedHttpAuthRequest(view, handler, host, realm);