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


Java KeyChain.getPrivateKey方法代码示例

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


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

示例1: fetchPrivateKey

import android.security.KeyChain; //导入方法依赖的package包/类
private PrivateKey fetchPrivateKey(Context context, String alias) throws KeyChainException,
        InterruptedException, MessagingException {

    PrivateKey privateKey = KeyChain.getPrivateKey(context, alias);
    if (privateKey == null) {
        throw new MessagingException("No private key found for: " + alias);
    }

    /*
     * We need to keep reference to the first private key retrieved so
     * it won't get garbage collected. If it will then the whole app
     * will crash on Android < 4.2 with "Fatal signal 11 code=1". See
     * https://code.google.com/p/android/issues/detail?id=62319
     */
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
        savePrivateKeyReference(privateKey);
    }

    return privateKey;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:21,代码来源:KeyChainKeyManager.java

示例2: getPrivateKey

import android.security.KeyChain; //导入方法依赖的package包/类
@Override
public PrivateKey getPrivateKey(String alias) {
	try {
		return KeyChain.getPrivateKey(mXmppConnectionService, alias);
	} catch (Exception e) {
		return null;
	}
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:9,代码来源:XmppConnection.java

示例3: getPrivateKey

import android.security.KeyChain; //导入方法依赖的package包/类
@Override
public PrivateKey getPrivateKey(String alias) {
    try {
        return KeyChain.getPrivateKey(mXmppConnectionService, alias);
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:9,代码来源:XmppConnection.java

示例4: signWithAlias

import android.security.KeyChain; //导入方法依赖的package包/类
public void signWithAlias(final String path, 
    final String alias, 
    final String name, 
    final String location, 
    final String reason, 
    byte[] imageData,
    int page,
    float x,
    float y,
    float width,
    float height) throws IOException, InterruptedException, KeyChainException 
{
  byte[] buffer = new byte[BUFFER_SIZE];

  this.callbackContext = callbackContext;
  privKey = KeyChain.getPrivateKey(context, alias);
  Certificate[] chain = KeyChain.getCertificateChain(context, alias);
  File document = new File(path);

  if (!(document != null && document.exists()))
    new RuntimeException("");


  Signature signature = new Signature(chain, privKey);
  File outputPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
  outputPath.mkdirs();
  if (imageData.length > 0) {
    ByteArrayInputStream image = new ByteArrayInputStream(imageData);
    signature.setVisual(image, page, x, y, width, height);
    System.err.println("page " + page + ":" + x + "," + y + " " + width + "x" + height);
  }
  signature.sign(path, outputPath.getAbsolutePath(), name, location, reason);

  File outputDocument = new File(outputPath.getAbsolutePath() + "/" + document.getName() + ".signed.pdf");
  File resultDocument = new File(path);
  File removeDocument = new File(document.getPath() + ".unsigned.pdf");

  document.renameTo(removeDocument);
  outputDocument.renameTo(resultDocument);

  return;
}
 
开发者ID:KodeKreatif,项目名称:cordova-plugin-pdfdigisign,代码行数:43,代码来源:PDFDigiSign.java


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