summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java39
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl4
2 files changed, 22 insertions, 21 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 04be028..1f0ced0 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -1506,12 +1506,11 @@ public class DevicePolicyManager {
*
* @return false if the certBuffer cannot be parsed or installation is
* interrupted, otherwise true
- * @hide
*/
- public boolean installCaCert(byte[] certBuffer) {
+ public boolean installCaCert(ComponentName who, byte[] certBuffer) {
if (mService != null) {
try {
- return mService.installCaCert(certBuffer);
+ return mService.installCaCert(who, certBuffer);
} catch (RemoteException e) {
Log.w(TAG, "Failed talking with device policy service", e);
}
@@ -1521,13 +1520,14 @@ public class DevicePolicyManager {
/**
* Uninstalls the given certificate from the list of User CAs, if present.
- *
- * @hide
*/
- public void uninstallCaCert(byte[] certBuffer) {
+ public void uninstallCaCert(ComponentName who, byte[] certBuffer) {
if (mService != null) {
try {
- mService.uninstallCaCert(certBuffer);
+ final String alias = getCaCertAlias(certBuffer);
+ mService.uninstallCaCert(who, alias);
+ } catch (CertificateException e) {
+ Log.w(TAG, "Unable to parse certificate", e);
} catch (RemoteException e) {
Log.w(TAG, "Failed talking with device policy service", e);
}
@@ -1536,10 +1536,8 @@ public class DevicePolicyManager {
/**
* Returns whether there are any user-installed CA certificates.
- *
- * @hide
*/
- public static boolean hasAnyCaCertsInstalled() {
+ public boolean hasAnyCaCertsInstalled() {
TrustedCertificateStore certStore = new TrustedCertificateStore();
Set<String> aliases = certStore.userAliases();
return aliases != null && !aliases.isEmpty();
@@ -1547,18 +1545,10 @@ public class DevicePolicyManager {
/**
* Returns whether this certificate has been installed as a User CA.
- *
- * @hide
*/
public boolean hasCaCertInstalled(byte[] certBuffer) {
- TrustedCertificateStore certStore = new TrustedCertificateStore();
- String alias;
- byte[] pemCert;
try {
- CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
- X509Certificate cert = (X509Certificate) certFactory.generateCertificate(
- new ByteArrayInputStream(certBuffer));
- return certStore.getCertificateAlias(cert) != null;
+ return getCaCertAlias(certBuffer) != null;
} catch (CertificateException ce) {
Log.w(TAG, "Could not parse certificate", ce);
}
@@ -1566,6 +1556,17 @@ public class DevicePolicyManager {
}
/**
+ * Returns the alias of a given CA certificate in the certificate store, or null if it
+ * doesn't exist.
+ */
+ private static String getCaCertAlias(byte[] certBuffer) throws CertificateException {
+ final CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
+ final X509Certificate cert = (X509Certificate) certFactory.generateCertificate(
+ new ByteArrayInputStream(certBuffer));
+ return new TrustedCertificateStore().getCertificateAlias(cert);
+ }
+
+ /**
* Called by an application that is administering the device to disable all cameras
* on the device. After setting this, no applications will be able to access any cameras
* on the device.
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index f8df780..b25341d 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -115,8 +115,8 @@ interface IDevicePolicyManager {
String getProfileOwnerName(int userHandle);
void setProfileEnabled(in ComponentName who);
- boolean installCaCert(in byte[] certBuffer);
- void uninstallCaCert(in byte[] certBuffer);
+ boolean installCaCert(in ComponentName admin, in byte[] certBuffer);
+ void uninstallCaCert(in ComponentName admin, in String alias);
void addPersistentPreferredActivity(in ComponentName admin, in IntentFilter filter, in ComponentName activity);
void clearPackagePersistentPreferredActivities(in ComponentName admin, String packageName);