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


Java RecipientId.setSerialNumber方法代码示例

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


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

示例1: decryptEnvelope

import org.bouncycastle.cms.RecipientId; //导入方法依赖的package包/类
/**
 * Try to decrypt the provided envelope with the provided certificate 
 * and private key. 
 */
public static MimeBodyPart decryptEnvelope(SMIMEEnveloped enveloped, 
							Key key, X509Certificate cert)
	throws Exception
{
	 // look for our recipient identifier
    RecipientId recId = new RecipientId();
    recId.setSerialNumber(cert.getSerialNumber());
    recId.setIssuer(cert.getIssuerX500Principal().getEncoded());

    RecipientInformationStore recipients = enveloped.getRecipientInfos();
    RecipientInformation recipient = recipients.get(recId);

    // decryption step
	if (recipient != null)
		return SMIMEUtil.toMimeBodyPart(recipient.getContent(key, "BC"));
	else
		return null;
}
 
开发者ID:edeoliveira,项目名称:Mailster,代码行数:23,代码来源:SmimeUtilities.java

示例2: addDecryptionSettings

import org.bouncycastle.cms.RecipientId; //导入方法依赖的package包/类
private void addDecryptionSettings() throws Exception {
    char[] smimePw = new String(decryptionKeystorePass).toCharArray();

    Security.addProvider(new BouncyCastleProvider());
    ks = KeyStore.getInstance(PKCS_KEYSTORE_TYPE, BOUNCY_CASTLE_PROVIDER);

    InputStream decryptionStream  = new URL(decryptionKeystore).openStream();
    try {
        ks.load(decryptionStream, smimePw);
    } finally {
        decryptionStream.close();
    }

    if ("".equals(decryptionKeyAlias)) {
        Enumeration aliases = ks.aliases();
        while (aliases.hasMoreElements()) {
            String alias = (String) aliases.nextElement();

            if (ks.isKeyEntry(alias)) {
                decryptionKeyAlias = alias;
            }
        }

        if ("".equals(decryptionKeyAlias)) {
            throw new Exception("Can't find a private key!");
        }
    }

    //
    // find the certificate for the private key and generate a
    // suitable recipient identifier.
    //
    X509Certificate cert = (X509Certificate)ks.getCertificate(decryptionKeyAlias);
    if (null == cert) {
        throw new Exception("Can't find a key pair with alias \"" + decryptionKeyAlias +
                "\" in the given keystore");
    }
    if (verifyCertificate) {
        cert.checkValidity();
    }

    recId = new RecipientId();
    recId.setSerialNumber(cert.getSerialNumber());
    recId.setIssuer(cert.getIssuerX500Principal().getEncoded());
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:46,代码来源:GetMailMessage.java


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