Search in sources :

Example 11 with IKeyChainService

use of android.security.IKeyChainService in project android_packages_apps_Settings by crdroidandroid.

the class TrustedCredentialsSettings method getX509CertsFromCertHolder.

@Override
public List<X509Certificate> getX509CertsFromCertHolder(CertHolder certHolder) {
    List<X509Certificate> certificates = null;
    try {
        KeyChainConnection keyChainConnection = mKeyChainConnectionByProfileId.get(certHolder.mProfileId);
        IKeyChainService service = keyChainConnection.getService();
        List<String> chain = service.getCaCertificateChainAliases(certHolder.mAlias, true);
        final int n = chain.size();
        certificates = new ArrayList<X509Certificate>(n);
        for (int i = 0; i < n; ++i) {
            byte[] encodedCertificate = service.getEncodedCaCertificate(chain.get(i), true);
            X509Certificate certificate = KeyChain.toCertificate(encodedCertificate);
            certificates.add(certificate);
        }
    } catch (RemoteException ex) {
        Log.e(TAG, "RemoteException while retrieving certificate chain for root " + certHolder.mAlias, ex);
    }
    return certificates;
}
Also used : IKeyChainService(android.security.IKeyChainService) KeyChainConnection(android.security.KeyChain.KeyChainConnection) RemoteException(android.os.RemoteException) X509Certificate(java.security.cert.X509Certificate)

Example 12 with IKeyChainService

use of android.security.IKeyChainService in project platform_packages_apps_Settings by BlissRoms.

the class TrustedCredentialsSettings method getX509CertsFromCertHolder.

@Override
public List<X509Certificate> getX509CertsFromCertHolder(CertHolder certHolder) {
    List<X509Certificate> certificates = null;
    try {
        KeyChainConnection keyChainConnection = mKeyChainConnectionByProfileId.get(certHolder.mProfileId);
        IKeyChainService service = keyChainConnection.getService();
        List<String> chain = service.getCaCertificateChainAliases(certHolder.mAlias, true);
        final int n = chain.size();
        certificates = new ArrayList<X509Certificate>(n);
        for (int i = 0; i < n; ++i) {
            byte[] encodedCertificate = service.getEncodedCaCertificate(chain.get(i), true);
            X509Certificate certificate = KeyChain.toCertificate(encodedCertificate);
            certificates.add(certificate);
        }
    } catch (RemoteException ex) {
        Log.e(TAG, "RemoteException while retrieving certificate chain for root " + certHolder.mAlias, ex);
    }
    return certificates;
}
Also used : IKeyChainService(android.security.IKeyChainService) KeyChainConnection(android.security.KeyChain.KeyChainConnection) RemoteException(android.os.RemoteException) X509Certificate(java.security.cert.X509Certificate)

Example 13 with IKeyChainService

use of android.security.IKeyChainService in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class TrustedCredentialsSettings method getX509CertsFromCertHolder.

@Override
public List<X509Certificate> getX509CertsFromCertHolder(CertHolder certHolder) {
    List<X509Certificate> certificates = null;
    try {
        synchronized (mKeyChainConnectionByProfileId) {
            KeyChainConnection keyChainConnection = mKeyChainConnectionByProfileId.get(certHolder.mProfileId);
            IKeyChainService service = keyChainConnection.getService();
            List<String> chain = service.getCaCertificateChainAliases(certHolder.mAlias, true);
            final int n = chain.size();
            certificates = new ArrayList<X509Certificate>(n);
            for (int i = 0; i < n; ++i) {
                byte[] encodedCertificate = service.getEncodedCaCertificate(chain.get(i), true);
                X509Certificate certificate = KeyChain.toCertificate(encodedCertificate);
                certificates.add(certificate);
            }
        }
    } catch (RemoteException ex) {
        Log.e(TAG, "RemoteException while retrieving certificate chain for root " + certHolder.mAlias, ex);
    }
    return certificates;
}
Also used : IKeyChainService(android.security.IKeyChainService) KeyChainConnection(android.security.KeyChain.KeyChainConnection) RemoteException(android.os.RemoteException) X509Certificate(java.security.cert.X509Certificate)

Aggregations

RemoteException (android.os.RemoteException)13 IKeyChainService (android.security.IKeyChainService)13 KeyChainConnection (android.security.KeyChain.KeyChainConnection)13 X509Certificate (java.security.cert.X509Certificate)7 UserHandle (android.os.UserHandle)3