diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/admin/DevicePolicyManager.java | 39 | ||||
-rw-r--r-- | core/java/android/app/admin/IDevicePolicyManager.aidl | 4 |
2 files changed, 21 insertions, 22 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 99f68d0..e80c761 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -1506,11 +1506,12 @@ public class DevicePolicyManager { * * @return false if the certBuffer cannot be parsed or installation is * interrupted, otherwise true + * @hide */ - public boolean installCaCert(ComponentName who, byte[] certBuffer) { + public boolean installCaCert(byte[] certBuffer) { if (mService != null) { try { - return mService.installCaCert(who, certBuffer); + return mService.installCaCert(certBuffer); } catch (RemoteException e) { Log.w(TAG, "Failed talking with device policy service", e); } @@ -1520,14 +1521,13 @@ public class DevicePolicyManager { /** * Uninstalls the given certificate from the list of User CAs, if present. + * + * @hide */ - public void uninstallCaCert(ComponentName who, byte[] certBuffer) { + public void uninstallCaCert(byte[] certBuffer) { if (mService != null) { try { - final String alias = getCaCertAlias(certBuffer); - mService.uninstallCaCert(who, alias); - } catch (CertificateException e) { - Log.w(TAG, "Unable to parse certificate", e); + mService.uninstallCaCert(certBuffer); } catch (RemoteException e) { Log.w(TAG, "Failed talking with device policy service", e); } @@ -1536,8 +1536,10 @@ public class DevicePolicyManager { /** * Returns whether there are any user-installed CA certificates. + * + * @hide */ - public boolean hasAnyCaCertsInstalled() { + public static boolean hasAnyCaCertsInstalled() { TrustedCertificateStore certStore = new TrustedCertificateStore(); Set<String> aliases = certStore.userAliases(); return aliases != null && !aliases.isEmpty(); @@ -1545,10 +1547,18 @@ 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 { - return getCaCertAlias(certBuffer) != null; + CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); + X509Certificate cert = (X509Certificate) certFactory.generateCertificate( + new ByteArrayInputStream(certBuffer)); + return certStore.getCertificateAlias(cert) != null; } catch (CertificateException ce) { Log.w(TAG, "Could not parse certificate", ce); } @@ -1556,17 +1566,6 @@ 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 e935da7..a1caa21 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 ComponentName admin, in byte[] certBuffer); - void uninstallCaCert(in ComponentName admin, in String alias); + boolean installCaCert(in byte[] certBuffer); + void uninstallCaCert(in byte[] certBuffer); void addPersistentPreferredActivity(in ComponentName admin, in IntentFilter filter, in ComponentName activity); void clearPackagePersistentPreferredActivities(in ComponentName admin, String packageName); |