Example usage for android.security KeyChain getPrivateKey

List of usage examples for android.security KeyChain getPrivateKey

Introduction

In this page you can find the example usage for android.security KeyChain getPrivateKey.

Prototype

@Nullable
@WorkerThread
public static PrivateKey getPrivateKey(@NonNull Context context, @NonNull String alias)
        throws KeyChainException, InterruptedException 

Source Link

Document

Returns the PrivateKey for the requested alias, or null if there is no result.

Usage

From source file:org.strongswan.android.logic.CharonVpnService.java

/**
 * Function called via JNI to get the private key the user selected.
 *
 * Since this method is called from a thread of charon's thread pool we are safe
 * to call methods on KeyChain directly.
 *
 * @return the private key/*ww  w . j a  va  2  s.  c o  m*/
 * @throws InterruptedException
 * @throws KeyChainException
 * @throws CertificateEncodingException
 */
private PrivateKey getUserKey() throws KeyChainException, InterruptedException {
    return KeyChain.getPrivateKey(getApplicationContext(), mCurrentUserCertificateAlias);
}