当前位置: 首页>>代码示例>>Java>>正文


Java KeyChain.createInstallIntent方法代码示例

本文整理汇总了Java中android.security.KeyChain.createInstallIntent方法的典型用法代码示例。如果您正苦于以下问题:Java KeyChain.createInstallIntent方法的具体用法?Java KeyChain.createInstallIntent怎么用?Java KeyChain.createInstallIntent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.security.KeyChain的用法示例。


在下文中一共展示了KeyChain.createInstallIntent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: installPkcs12

import android.security.KeyChain; //导入方法依赖的package包/类
/**
 * This method will launch an intent to install the key chain
 */
private void installPkcs12() {
    try {
        BufferedInputStream bis = new BufferedInputStream(getAssets().open(
                PKCS12_FILENAME));
        byte[] keychain = new byte[bis.available()];
        bis.read(keychain);

        Intent installIntent = KeyChain.createInstallIntent();
        installIntent.putExtra(KeyChain.EXTRA_PKCS12, keychain);
        installIntent.putExtra(KeyChain.EXTRA_NAME, DEFAULT_ALIAS);
        startActivityForResult(installIntent, INSTALL_KEYCHAIN_CODE);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:19,代码来源:KeyChainDemoActivity.java

示例2: storeKeyPair

import android.security.KeyChain; //导入方法依赖的package包/类
/**
 * Stores the key pair through the CertInstaller activity.
 * @param context current application context.
 * @param publicKey The public key bytes as DER-encoded SubjectPublicKeyInfo (X.509)
 * @param privateKey The private key as DER-encoded PrivateKeyInfo (PKCS#8).
 * @return: true on success, false on failure.
 *
 * Note that failure means that the function could not launch the CertInstaller
 * activity. Whether the keys are valid or properly installed will be indicated
 * by the CertInstaller UI itself.
 */
@CalledByNative
public static boolean storeKeyPair(Context context, byte[] publicKey, byte[] privateKey) {
    // TODO(digit): Use KeyChain official extra values to pass the public and private
    // keys when they're available. The "KEY" and "PKEY" hard-coded constants were taken
    // from the platform sources, since there are no official KeyChain.EXTRA_XXX definitions
    // for them. b/5859651
    try {
        Intent intent = KeyChain.createInstallIntent();
        intent.putExtra("PKEY", privateKey);
        intent.putExtra("KEY", publicKey);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        Log.w(TAG, "could not store key pair: " + e);
    }
    return false;
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:30,代码来源:AndroidNetworkLibrary.java

示例3: storeCertificate

import android.security.KeyChain; //导入方法依赖的package包/类
/**
  * Adds a cryptographic file (User certificate, a CA certificate or
  * PKCS#12 keychain) through the system's CertInstaller activity.
  *
  * @param context current application context.
  * @param certType cryptographic file type. E.g. CertificateMimeType.X509_USER_CERT
  * @param data certificate/keychain data bytes.
  * @return true on success, false on failure.
  *
  * Note that failure only indicates that the function couldn't launch the
  * CertInstaller activity, not that the certificate/keychain was properly
  * installed to the keystore.
  */
@CalledByNative
public static boolean storeCertificate(Context context, int certType, byte[] data) {
    try {
        Intent intent = KeyChain.createInstallIntent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        switch (certType) {
            case CertificateMimeType.X509_USER_CERT:
            case CertificateMimeType.X509_CA_CERT:
                intent.putExtra(KeyChain.EXTRA_CERTIFICATE, data);
                break;

            case CertificateMimeType.PKCS12_ARCHIVE:
                intent.putExtra(KeyChain.EXTRA_PKCS12, data);
                break;

            default:
                Log.w(TAG, "invalid certificate type: " + certType);
                return false;
        }
        context.startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        Log.w(TAG, "could not store crypto file: " + e);
    }
    return false;
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:41,代码来源:AndroidNetworkLibrary.java

示例4: storeKeyPair

import android.security.KeyChain; //导入方法依赖的package包/类
/**
 * Stores the key pair through the CertInstaller activity.
 * @param publicKey The public key bytes as DER-encoded SubjectPublicKeyInfo (X.509)
 * @param privateKey The private key as DER-encoded PrivateKeyInfo (PKCS#8).
 * @return: true on success, false on failure.
 *
 * Note that failure means that the function could not launch the CertInstaller
 * activity. Whether the keys are valid or properly installed will be indicated
 * by the CertInstaller UI itself.
 */
@CalledByNative
public static boolean storeKeyPair(byte[] publicKey, byte[] privateKey) {
    // TODO(digit): Use KeyChain official extra values to pass the public and private
    // keys when they're available. The "KEY" and "PKEY" hard-coded constants were taken
    // from the platform sources, since there are no official KeyChain.EXTRA_XXX definitions
    // for them. b/5859651
    try {
        Intent intent = KeyChain.createInstallIntent();
        intent.putExtra("PKEY", privateKey);
        intent.putExtra("KEY", publicKey);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        ContextUtils.getApplicationContext().startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        Log.w(TAG, "could not store key pair: " + e);
    }
    return false;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:29,代码来源:AndroidNetworkLibrary.java

示例5: storeKeyPair

import android.security.KeyChain; //导入方法依赖的package包/类
/**
 * Stores the key pair through the CertInstaller activity.
 * @param context: current application context.
 * @param public_key: The public key bytes as DER-encoded SubjectPublicKeyInfo (X.509)
 * @param private_key: The private key as DER-encoded PrivateKeyInfo (PKCS#8).
 * @return: true on success, false on failure.
 *
 * Note that failure means that the function could not launch the CertInstaller
 * activity. Whether the keys are valid or properly installed will be indicated
 * by the CertInstaller UI itself.
 */
@CalledByNative
static public boolean storeKeyPair(Context context, byte[] public_key, byte[] private_key) {
    // TODO(digit): Use KeyChain official extra values to pass the public and private
    // keys when they're available. The "KEY" and "PKEY" hard-coded constants were taken
    // from the platform sources, since there are no official KeyChain.EXTRA_XXX definitions
    // for them. b/5859651
    try {
        Intent intent = KeyChain.createInstallIntent();
        intent.putExtra("PKEY", private_key);
        intent.putExtra("KEY", public_key);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        Log.w(TAG, "could not store key pair: " + e);
    }
    return false;
}
 
开发者ID:openresearch,项目名称:android-chromium-view,代码行数:30,代码来源:AndroidNetworkLibrary.java

示例6: storeCertificate

import android.security.KeyChain; //导入方法依赖的package包/类
/**
  * Adds a cryptographic file (User certificate, a CA certificate or
  * PKCS#12 keychain) through the system's CertInstaller activity.
  *
  * @param context: current application context.
  * @param cert_type: cryptographic file type. E.g. CertificateMimeType.X509_USER_CERT
  * @param data: certificate/keychain data bytes.
  * @return true on success, false on failure.
  *
  * Note that failure only indicates that the function couldn't launch the
  * CertInstaller activity, not that the certificate/keychain was properly
  * installed to the keystore.
  */
@CalledByNative
static public boolean storeCertificate(Context context, int cert_type, byte[] data) {
    try {
        Intent intent = KeyChain.createInstallIntent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        switch (cert_type) {
          case CertificateMimeType.X509_USER_CERT:
          case CertificateMimeType.X509_CA_CERT:
            intent.putExtra(KeyChain.EXTRA_CERTIFICATE, data);
            break;

          case CertificateMimeType.PKCS12_ARCHIVE:
            intent.putExtra(KeyChain.EXTRA_PKCS12, data);
            break;

          default:
            Log.w(TAG, "invalid certificate type: " + cert_type);
            return false;
        }
        context.startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        Log.w(TAG, "could not store crypto file: " + e);
    }
    return false;
}
 
开发者ID:openresearch,项目名称:android-chromium-view,代码行数:41,代码来源:AndroidNetworkLibrary.java


注:本文中的android.security.KeyChain.createInstallIntent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。