Commit 9bf2589b authored by changwan's avatar changwan Committed by Commit bot

Move ChromeShellPKCS11AuthenticationManager to Empty...

Change the name and move it to a more generic place so that it can be used
by ChromeMobileApplication.

BUG=428860

Review URL: https://codereview.chromium.org/1063033002

Cr-Commit-Position: refs/heads/master@{#324381}
parent 0549561d
......@@ -37,6 +37,7 @@ import org.chromium.chrome.browser.preferences.password.ManageSavedPasswordsPref
import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferences;
import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences;
import org.chromium.chrome.browser.services.AndroidEduOwnerCheckCallback;
import org.chromium.chrome.browser.smartcard.PKCS11AuthenticationManager;
import org.chromium.content.app.ContentApplication;
import org.chromium.content.browser.BrowserStartupController;
......
......@@ -4,43 +4,12 @@
package org.chromium.chrome.browser;
import android.content.Context;
import org.chromium.net.AndroidPrivateKey;
import java.security.cert.X509Certificate;
import org.chromium.base.annotations.SuppressFBWarnings;
/**
* Defines API for managing interaction with SmartCard-based certificate storage using PKCS11.
*/
public interface PKCS11AuthenticationManager {
/**
* @return true iff SmartCard-based authentication is available.
*/
public boolean isPKCS11AuthEnabled();
/**
* Retrieves the preferred client certificate alias for the given host, port pair, or null if
* none can be retrieved.
*
* @param hostName The host for which to retrieve client certificate.
* @param port The port to use in conjunction with host to retrieve client certificate.
*/
public String getClientCertificateAlias(String hostName, int port);
/**
* Returns the X509Certificate chain for the requested alias, or null if no there is no result.
*/
public X509Certificate[] getCertificateChain(String alias);
/**
* Performs necessary initializing for using a PKCS11-based KeysStore.
*/
public void initialize(Context context);
/**
* Returns the AndroidPrivateKey for the requested alias, or null if there is no result.
*/
public AndroidPrivateKey getPrivateKey(String alias);
}
// TODO(changwan): remove this after downstream change is merged.
@SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_INTERFACE")
public interface PKCS11AuthenticationManager
extends org.chromium.chrome.browser.smartcard.PKCS11AuthenticationManager {}
\ No newline at end of file
......@@ -15,6 +15,7 @@ import android.util.Log;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.base.ThreadUtils;
import org.chromium.chrome.browser.smartcard.PKCS11AuthenticationManager;
import org.chromium.net.AndroidPrivateKey;
import org.chromium.net.DefaultAndroidKeyStore;
import org.chromium.ui.base.WindowAndroid;
......
......@@ -2,19 +2,29 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.shell;
package org.chromium.chrome.browser.smartcard;
import android.content.Context;
import org.chromium.chrome.browser.PKCS11AuthenticationManager;
import org.chromium.base.ThreadUtils;
import org.chromium.net.AndroidPrivateKey;
import java.security.cert.X509Certificate;
/**
* ChromeShell stub implementation of PKCS11AuthenticationManager.
* Stub implementation of PKCS11AuthenticationManager.
*/
public class ChromeShellPKCS11AuthenticationManager implements PKCS11AuthenticationManager {
public class EmptyPKCS11AuthenticationManager implements PKCS11AuthenticationManager {
private static PKCS11AuthenticationManager sInstance;
public static PKCS11AuthenticationManager getInstance() {
ThreadUtils.assertOnUiThread();
if (sInstance == null) sInstance = new EmptyPKCS11AuthenticationManager();
return sInstance;
}
protected EmptyPKCS11AuthenticationManager() {}
@Override
public boolean isPKCS11AuthEnabled() {
return false;
......@@ -26,9 +36,7 @@ public class ChromeShellPKCS11AuthenticationManager implements PKCS11Authenticat
}
@Override
public void initialize(Context context) {
}
public void initialize(Context context) {}
@Override
public X509Certificate[] getCertificateChain(String alias) {
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.smartcard;
import android.content.Context;
import org.chromium.net.AndroidPrivateKey;
import java.security.cert.X509Certificate;
/**
* Defines API for managing interaction with SmartCard-based certificate storage using PKCS11.
*/
public interface PKCS11AuthenticationManager {
/**
* @return true iff SmartCard-based authentication is available.
*/
public boolean isPKCS11AuthEnabled();
/**
* Retrieves the preferred client certificate alias for the given host, port pair, or null if
* none can be retrieved.
*
* @param hostName The host for which to retrieve client certificate.
* @param port The port to use in conjunction with host to retrieve client certificate.
*/
public String getClientCertificateAlias(String hostName, int port);
/**
* Returns the X509Certificate chain for the requested alias, or null if no there is no result.
*/
public X509Certificate[] getCertificateChain(String alias);
/**
* Performs necessary initializing for using a PKCS11-based KeysStore.
*/
public void initialize(Context context);
/**
* Returns the AndroidPrivateKey for the requested alias, or null if there is no result.
*/
public AndroidPrivateKey getPrivateKey(String alias);
}
......@@ -10,11 +10,12 @@ import org.chromium.base.CommandLine;
import org.chromium.base.PathUtils;
import org.chromium.base.ResourceExtractor;
import org.chromium.chrome.browser.ChromiumApplication;
import org.chromium.chrome.browser.PKCS11AuthenticationManager;
import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory;
import org.chromium.chrome.browser.identity.UuidBasedUniqueIdentificationGenerator;
import org.chromium.chrome.browser.invalidation.UniqueIdInvalidationClientNameGenerator;
import org.chromium.chrome.browser.metrics.UmaUtils;
import org.chromium.chrome.browser.smartcard.EmptyPKCS11AuthenticationManager;
import org.chromium.chrome.browser.smartcard.PKCS11AuthenticationManager;
import org.chromium.chrome.browser.sync.SyncController;
import org.chromium.chrome.shell.preferences.ChromeShellPreferences;
......@@ -115,6 +116,6 @@ public class ChromeShellApplication extends ChromiumApplication {
@Override
protected PKCS11AuthenticationManager getPKCS11AuthenticationManager() {
return new ChromeShellPKCS11AuthenticationManager();
return EmptyPKCS11AuthenticationManager.getInstance();
}
}
......@@ -5,7 +5,7 @@
package org.chromium.chrome.unit_tests_apk;
import org.chromium.chrome.browser.ChromiumApplication;
import org.chromium.chrome.browser.PKCS11AuthenticationManager;
import org.chromium.chrome.browser.smartcard.PKCS11AuthenticationManager;
/**
* A stub implementation of the chrome application to be used in chrome unit_tests.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment