本文整理汇总了Java中org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator类的典型用法代码示例。如果您正苦于以下问题:Java SMIMEEnvelopedGenerator类的具体用法?Java SMIMEEnvelopedGenerator怎么用?Java SMIMEEnvelopedGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SMIMEEnvelopedGenerator类属于org.bouncycastle.mail.smime包,在下文中一共展示了SMIMEEnvelopedGenerator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testHeaders
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
public void testHeaders()
throws Exception
{
MimeBodyPart msg = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");
SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();
gen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(_reciCert).setProvider(BC));
//
// generate a MimeBodyPart object which encapsulates the content
// we want encrypted.
//
MimeBodyPart mp = gen.generate(msg, new JceCMSContentEncryptorBuilder(CMSAlgorithm.DES_EDE3_CBC).setProvider(BC).build());
assertEquals("application/pkcs7-mime; name=\"smime.p7m\"; smime-type=enveloped-data", mp.getHeader("Content-Type")[0]);
assertEquals("attachment; filename=\"smime.p7m\"", mp.getHeader("Content-Disposition")[0]);
assertEquals("S/MIME Encrypted Message", mp.getHeader("Content-Description")[0]);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:21,代码来源:NewSMIMEEnvelopedTest.java
示例2: cryptMessage
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
private static MimeMultipart cryptMessage(MimeBodyPart mbp)
throws Exception
{
// Open the key store
char[] pwd = "password".toCharArray();
KeyStore ks = MailsterKeyStoreFactory.loadKeyStore("PKCS12", "clients.p12", pwd);
SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();
gen.addKeyTransRecipient((X509Certificate) ks.getCertificate(MailsterKeyStoreFactory.DEFAULT_CERT_ALIAS));
// generate the enveloped message
MimeBodyPart envPart = gen.generate(mbp, SMIMEEnvelopedGenerator.AES256_CBC, "BC");
MimeMultipart multipart = new MimeMultipart();
multipart.addBodyPart(envPart);
return multipart;
}
开发者ID:edeoliveira,项目名称:Mailster,代码行数:19,代码来源:EncryptedMailTest.java
示例3: testHeaders
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
public void testHeaders()
throws Exception
{
MimeBodyPart _msg = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");
SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();
gen.addKeyTransRecipient(_reciCert);
//
// generate a MimeBodyPart object which encapsulates the content
// we want encrypted.
//
MimeBodyPart mp = gen.generate(_msg, SMIMEEnvelopedGenerator.DES_EDE3_CBC, "BC");
assertEquals("application/pkcs7-mime; name=\"smime.p7m\"; smime-type=enveloped-data", mp.getHeader("Content-Type")[0]);
assertEquals("attachment; filename=\"smime.p7m\"", mp.getHeader("Content-Disposition")[0]);
assertEquals("S/MIME Encrypted Message", mp.getHeader("Content-Description")[0]);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:21,代码来源:SMIMEEnvelopedTest.java
示例4: verifyAlgorithm
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
private void verifyAlgorithm(
String algorithmOid,
MimeBodyPart msg)
throws Exception
{
SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();
gen.addKeyTransRecipient(_reciCert);
//
// generate a MimeBodyPart object which encapsulates the content
// we want encrypted.
//
MimeBodyPart mp = gen.generate(msg, algorithmOid, "BC");
SMIMEEnveloped m = new SMIMEEnveloped(mp);
RecipientId recId = getRecipientId(_reciCert);
RecipientInformationStore recipients = m.getRecipientInfos();
RecipientInformation recipient = recipients.get(recId);
MimeBodyPart res = SMIMEUtil.toMimeBodyPart(recipient.getContent(_reciKP.getPrivate(), "BC"));
verifyMessageBytes(msg, res);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:26,代码来源:SMIMEEnvelopedTest.java
示例5: verifyParserAlgorithm
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
private void verifyParserAlgorithm(
String algorithmOid,
MimeBodyPart msg)
throws Exception
{
SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();
gen.addKeyTransRecipient(_reciCert);
//
// generate a MimeBodyPart object which encapsulates the content
// we want encrypted.
//
MimeBodyPart mp = gen.generate(msg, algorithmOid, "BC");
SMIMEEnvelopedParser m = new SMIMEEnvelopedParser(mp);
RecipientId recId = getRecipientId(_reciCert);
RecipientInformationStore recipients = m.getRecipientInfos();
RecipientInformation recipient = recipients.get(recId);
MimeBodyPart res = SMIMEUtil.toMimeBodyPart(recipient.getContent(_reciKP.getPrivate(), "BC"));
verifyMessageBytes(msg, res);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:26,代码来源:SMIMEEnvelopedTest.java
示例6: verifyAlgorithm
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
private void verifyAlgorithm(
String algorithmOid,
MimeBodyPart msg)
throws Exception
{
SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();
gen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(_reciCert).setProvider(BC));
//
// generate a MimeBodyPart object which encapsulates the content
// we want encrypted.
//
MimeBodyPart mp = gen.generate(msg, new JceCMSContentEncryptorBuilder(new ASN1ObjectIdentifier(algorithmOid)).setProvider(BC).build());
SMIMEEnveloped m = new SMIMEEnveloped(mp);
RecipientId recId = getRecipientId(_reciCert);
RecipientInformationStore recipients = m.getRecipientInfos();
RecipientInformation recipient = recipients.get(recId);
MimeBodyPart res = SMIMEUtil.toMimeBodyPart(recipient.getContent(new JceKeyTransEnvelopedRecipient(_reciKP.getPrivate()).setProvider(BC)));
verifyMessageBytes(msg, res);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:26,代码来源:NewSMIMEEnvelopedTest.java
示例7: verifyParserAlgorithm
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
private void verifyParserAlgorithm(
String algorithmOid,
MimeBodyPart msg)
throws Exception
{
SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();
gen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(_reciCert).setProvider(BC));
//
// generate a MimeBodyPart object which encapsulates the content
// we want encrypted.
//
MimeBodyPart mp = gen.generate(msg, new JceCMSContentEncryptorBuilder(new ASN1ObjectIdentifier(algorithmOid)).setProvider(BC).build());
SMIMEEnvelopedParser m = new SMIMEEnvelopedParser(mp);
RecipientId recId = getRecipientId(_reciCert);
RecipientInformationStore recipients = m.getRecipientInfos();
RecipientInformation recipient = recipients.get(recId);
MimeBodyPart res = SMIMEUtil.toMimeBodyPart(recipient.getContent(new JceKeyTransEnvelopedRecipient(_reciKP.getPrivate()).setProvider(BC)));
verifyMessageBytes(msg, res);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:26,代码来源:NewSMIMEEnvelopedTest.java
示例8: testHeaders
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
@Test
public void testHeaders()
throws Exception {
InternetHeaders ih = new InternetHeaders();
ih.addHeader("Content-Type", "application/xml");
MimeBodyPart _msg = new MimeBodyPart(ih, "<customer name=\"bill\"/>".getBytes());
SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();
OutputEncryptor encryptor = new JceCMSContentEncryptorBuilder(CMSAlgorithm.DES_EDE3_CBC)
.setProvider("BC")
.build();
RecipientInfoGenerator generator = new JceKeyTransRecipientInfoGenerator(cert);
gen.addRecipientInfoGenerator(generator);
//
// generate a MimeBodyPart object which encapsulates the content
// we want encrypted.
//
MimeBodyPart mp = gen.generate(_msg, encryptor);
output(mp);
}
开发者ID:gini,项目名称:jersey-smime,代码行数:27,代码来源:EnvelopedTest.java
示例9: encrypt
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
/**
* Encrypts the encapsulated MIME body part.
*
* @param cert the certificate for encryption.
* @return an S/MIME message encapsulating the encrypted MIME body part.
* @throws SMimeException if unable to encrpyt the body part.
*/
public SMimeMessage encrypt(X509Certificate cert) throws SMimeException {
try {
try {
if (cert == null) {
throw new SMimeException("No certificate for encryption");
}
setDefaults();
/* Create the encrypter */
SMIMEEnvelopedGenerator encrypter = new SMIMEEnvelopedGenerator();
encrypter.setContentTransferEncoding(getContentTransferEncoding());
// encrypter.addKeyTransRecipient(cert); // Deprecated
encrypter.addRecipientInfoGenerator(
// JceKeyTransRecipientInfoGenerator(X509Certificate,
// [org.bouncycastle.asn1.x509.AlgorithmIdentifier])
new JceKeyTransRecipientInfoGenerator(cert).setProvider(SECURITY_PROVIDER));
/* Encrypt the body part */
MimeBodyPart encryptedPart =
// encrypter.generate(bodyPart, getEncryptAlgorithm(), SECURITY_PROVIDER); // Deprecated
// encryptor.generate(MimeBodyPart, JceCMSContentEncryptorBuilder(
// org.bouncycastle.asn1.ANS1ObjectIdentifier, [int keySize])
encrypter.generate(bodyPart,
new JceCMSContentEncryptorBuilder(new ASN1ObjectIdentifier(getEncryptAlgorithm()))
.setProvider(SECURITY_PROVIDER).build());
return new SMimeMessage(encryptedPart, this);
}
catch (org.bouncycastle.mail.smime.SMIMEException ex) {
throw new SMimeException(ex.getMessage(), ex.getUnderlyingException());
}
}
catch (Exception e) {
throw new SMimeException("Unable to encrypt body part", e);
}
}
开发者ID:cecid,项目名称:hermes,代码行数:44,代码来源:SMimeMessage.java
示例10: encrypt
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
private MimeBodyPart encrypt(MimeBodyPart bodyPart) throws Exception{
// Create Encrypter
SMIMEEnvelopedGenerator encrypter = new SMIMEEnvelopedGenerator();
encrypter.setContentTransferEncoding("base64");
encrypter.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(partnershipDVO.getEncryptX509Certificate())
.setProvider(SECURITY_PROVIDER));
// Encrypt BodyPart
MimeBodyPart encryptedPart = encrypter.generate(bodyPart,
new JceCMSContentEncryptorBuilder(
new ASN1ObjectIdentifier(SMIMEEnvelopedGenerator.DES_EDE3_CBC))
.setProvider(SECURITY_PROVIDER).build());
return encryptedPart;
}
开发者ID:cecid,项目名称:hermes,代码行数:15,代码来源:IncomingMessageProcessorTest.java
示例11: encrypt
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
public void encrypt(X509Certificate cert, String encryptAlg) throws SFRMException {
try {
/* Create the encrypter */
SMIMEEnvelopedGenerator encrypter = new SMIMEEnvelopedGenerator();
encrypter.setContentTransferEncoding("binary");
encrypter.addRecipientInfoGenerator(
new JceKeyTransRecipientInfoGenerator(cert).setProvider(SECURITY_PROVIDER));
/* Encrypt the body part */
if (encryptAlg.equalsIgnoreCase(ALG_ENCRYPT_RC2))
this.bodyPart = encrypter.generate(bodyPart,
new JceCMSContentEncryptorBuilder(
new ASN1ObjectIdentifier(SMIMEEnvelopedGenerator.RC2_CBC))
.setProvider(SECURITY_PROVIDER).build());
else if (encryptAlg.equalsIgnoreCase(ALG_ENCRYPT_3DES))
this.bodyPart = encrypter.generate(bodyPart,
new JceCMSContentEncryptorBuilder(
new ASN1ObjectIdentifier(SMIMEEnvelopedGenerator.DES_EDE3_CBC))
.setProvider(SECURITY_PROVIDER).build());
else
throw new SFRMException("Encryption algorithm error - " + encryptAlg);
this.setIsEncrypted(true);
} catch (org.bouncycastle.mail.smime.SMIMEException ex) {
throw new SFRMException("Unable to encrypt body part", ex.getUnderlyingException());
} catch (Exception e) {
throw new SFRMException("Unable to encrypt body part", e);
}
}
开发者ID:cecid,项目名称:hermes,代码行数:31,代码来源:SFRMMessage.java
示例12: testDESEDE3Encrypted
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
public void testDESEDE3Encrypted()
throws Exception
{
MimeBodyPart msg = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");
String algorithm = SMIMEEnvelopedGenerator.DES_EDE3_CBC;
verifyAlgorithm(algorithm, msg);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:9,代码来源:SMIMEEnvelopedTest.java
示例13: testParserDESEDE3Encrypted
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
public void testParserDESEDE3Encrypted()
throws Exception
{
MimeBodyPart msg = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");
String algorithm = SMIMEEnvelopedGenerator.DES_EDE3_CBC;
verifyParserAlgorithm(algorithm, msg);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:9,代码来源:SMIMEEnvelopedTest.java
示例14: testIDEAEncrypted
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
public void testIDEAEncrypted()
throws Exception
{
if (isPresent("IDEA"))
{
MimeBodyPart msg = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");
String algorithm = SMIMEEnvelopedGenerator.IDEA_CBC;
verifyAlgorithm(algorithm, msg);
}
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:12,代码来源:SMIMEEnvelopedTest.java
示例15: testRC2Encrypted
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
public void testRC2Encrypted()
throws Exception
{
MimeBodyPart msg = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");
String algorithm = SMIMEEnvelopedGenerator.RC2_CBC;
verifyAlgorithm(algorithm, msg);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:9,代码来源:SMIMEEnvelopedTest.java
示例16: testCASTEncrypted
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
public void testCASTEncrypted()
throws Exception
{
MimeBodyPart msg = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");
String algorithm = SMIMEEnvelopedGenerator.CAST5_CBC;
verifyAlgorithm(algorithm, msg);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:9,代码来源:SMIMEEnvelopedTest.java
示例17: testAES128Encrypted
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
public void testAES128Encrypted()
throws Exception
{
MimeBodyPart msg = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");
String algorithm = SMIMEEnvelopedGenerator.AES128_CBC;
verifyAlgorithm(algorithm, msg);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:9,代码来源:SMIMEEnvelopedTest.java
示例18: testAES192Encrypted
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
public void testAES192Encrypted()
throws Exception
{
MimeBodyPart msg = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");
String algorithm = SMIMEEnvelopedGenerator.AES192_CBC;
verifyAlgorithm(algorithm, msg);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:9,代码来源:SMIMEEnvelopedTest.java
示例19: testAES256Encrypted
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
public void testAES256Encrypted()
throws Exception
{
MimeBodyPart msg = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");
String algorithm = SMIMEEnvelopedGenerator.AES256_CBC;
verifyAlgorithm(algorithm, msg);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:9,代码来源:SMIMEEnvelopedTest.java
示例20: testCapEncrypt
import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator; //导入依赖的package包/类
public void testCapEncrypt()
throws Exception
{
MimeBodyPart _msg = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");
SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();
//
// create a subject key id - this has to be done the same way as
// it is done in the certificate associated with the private key
//
MessageDigest dig = MessageDigest.getInstance("SHA1", "BC");
dig.update(_reciCert.getPublicKey().getEncoded());
gen.addKeyTransRecipient(_reciCert.getPublicKey(), dig.digest());
//
// generate a MimeBodyPart object which encapsulates the content
// we want encrypted.
//
MimeBodyPart mp = gen.generate(_msg, SMIMEEnvelopedGenerator.RC2_CBC, 40, "BC");
SMIMEEnveloped m = new SMIMEEnveloped(mp);
dig.update(_reciCert.getPublicKey().getEncoded());
RecipientId recId = new KeyTransRecipientId(dig.digest());
RecipientInformationStore recipients = m.getRecipientInfos();
RecipientInformation recipient = recipients.get(recId);
MimeBodyPart res = SMIMEUtil.toMimeBodyPart(recipient.getContent(_reciKP.getPrivate(), "BC"));
verifyMessageBytes(_msg, res);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:37,代码来源:SMIMEEnvelopedTest.java
注:本文中的org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论