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


Java KeyChain.getCertificateChain方法代码示例

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


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

示例1: fetchCertificateChain

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

    X509Certificate[] chain = KeyChain.getCertificateChain(context, alias);
    if (chain == null || chain.length == 0) {
        throw new MessagingException("No certificate chain found for: " + alias);
    }
    try {
        for (X509Certificate certificate : chain) {
            certificate.checkValidity();
        }
    } catch (CertificateException e) {
        throw new CertificateValidationException(e.getMessage(), Reason.Expired, alias);
    }

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

示例2: fetchCertificateChain

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

    X509Certificate[] chain = KeyChain.getCertificateChain(context, alias);
    if (chain == null || chain.length == 0) {
        throw new MessagingException("No certificate chain found for: " + alias);
    }
    try {
        for (X509Certificate certificate : chain) {
            certificate.checkValidity();
        }
    } catch (CertificateException e) {
        // Client certificate has expired or is not yet valid
        throw new CertificateValidationException(context.getString(R.string.client_certificate_expired, alias, e.toString()));
    }

    return chain;
}
 
开发者ID:daxslab,项目名称:daxSmail,代码行数:19,代码来源:KeyChainKeyManager.java

示例3: getCertificateChain

import android.security.KeyChain; //导入方法依赖的package包/类
@Override
public X509Certificate[] getCertificateChain(String alias) {
	Log.d(Config.LOGTAG, "getting certificate chain");
	try {
		return KeyChain.getCertificateChain(mXmppConnectionService, alias);
	} catch (Exception e) {
		Log.d(Config.LOGTAG, e.getMessage());
		return new X509Certificate[0];
	}
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:11,代码来源:XmppConnection.java

示例4: getCertificateChain

import android.security.KeyChain; //导入方法依赖的package包/类
@Override
public X509Certificate[] getCertificateChain(String alias) {
    Log.d(Config.LOGTAG, "getting certificate chain");
    try {
        return KeyChain.getCertificateChain(mXmppConnectionService, alias);
    } catch (Exception e) {
        Log.d(Config.LOGTAG, e.getMessage());
        return new X509Certificate[0];
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:11,代码来源:XmppConnection.java

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