public Object getEntity(Class t, Type gt, Annotation[] ann, PrivateKey pKey, X509Certificate cert) { MimeBodyPart decrypted = null; try { MimeBodyPart encryptedBodyPart = body; SMIMEEnveloped m = new SMIMEEnveloped(encryptedBodyPart); JceKeyTransRecipientId recId = new JceKeyTransRecipientId(cert); RecipientInformationStore recipients = m.getRecipientInfos(); RecipientInformation recipient = recipients.get(recId); JceKeyTransRecipient pKeyRecp = new JceKeyTransEnvelopedRecipient(pKey); decrypted = SMIMEUtil.toMimeBodyPart(recipient.getContent(pKeyRecp)); } catch (Exception e1) { throw new RuntimeException(e1); } return extractEntity(t, gt, ann, decrypted, providers); }
final SMIMEEnveloped m = new SMIMEEnveloped(part); final RecipientInformationStore recipients = m.getRecipientInfos(); final RecipientInformation recipient = recipients.get(recId); final JceKeyTransEnvelopedRecipient recip = new JceKeyTransEnvelopedRecipient(entry); System.out.println("Alg OID: " + m.getEncryptionAlgOID());
final SMIMEEnveloped env = new SMIMEEnveloped(new MimeMessage(null, inStream)); String OID = env.getEncryptionAlgOID(); final RecipientInformationStore recipients = env.getRecipientInfos(); Collection<RecipientInformation> reps = recipients.getRecipients(); for (RecipientInformation repInfo : reps)
private MimeBodyPart decryptPart(MimeBodyPart part) throws Exception { SMIMEEnveloped smimeEnveloped = new SMIMEEnveloped(part); RecipientInformationStore recipients = smimeEnveloped.getRecipientInfos(); RecipientInformation recipient = recipients.get(recId); if (null == recipient) { StringBuilder errorMessage = new StringBuilder(); errorMessage.append("This email wasn't encrypted with \"" + recId.toString() + "\".\n"); errorMessage.append("The encryption recId is: "); for (Object rec : recipients.getRecipients()) { if (rec instanceof RecipientInformation) { RecipientId recipientId = ((RecipientInformation) rec).getRID(); errorMessage.append("\"" + recipientId.toString() + "\"\n"); } } throw new Exception(errorMessage.toString()); } return toMimeBodyPart(recipient.getContent(ks.getKey(decryptionKeyAlias, null), BOUNCY_CASTLE_PROVIDER)); }
final SMIMEEnveloped m = new SMIMEEnveloped(encryptedEntity); if (!this.isAllowedEncryptionAlgorithm(m.getEncryptionAlgOID())) throw new NHINDException(MimeError.DisallowedEncryptionAlgorithm, "The encryption algorithm " + m.getEncryptionAlgOID() + " is not allowed"); final RecipientInformationStore recipients = m.getRecipientInfos(); final RecipientInformation recipient = recipients.get(recId); if (recipient == null)
recId.setIssuer(cert.getIssuerX500Principal().getEncoded()); SMIMEEnveloped m = new SMIMEEnveloped((MimeMessage) message); RecipientInformationStore recipients = m.getRecipientInfos(); RecipientInformation recipient = recipients.get(recId);
SMIMEEnveloped envelope = new SMIMEEnveloped(part); RecipientInformationStore recipientInfoStore = envelope.getRecipientInfos();
aEnvelope = new SMIMEEnveloped (aPart); aRecipient = aEnvelope.getRecipientInfos ().get (aRecipientID);
if (message.isMimeType("application/x-pkcs7-mime") || message.isMimeType("application/pkcs7-mime")) { try { SMIMEEnveloped env = new SMIMEEnveloped(message); RecipientInformationStore informationStore = env.getRecipientInfos(); Collection<RecipientInformation> recipients = informationStore.getRecipients(); for (RecipientInformation info : recipients) {
SMIMEEnveloped m = new SMIMEEnveloped(msg); RecipientInformationStore recipients = m.getRecipientInfos(); RecipientInformation recipient = recipients.get(recId); PrivateKey privateKey = (PrivateKey) ks.getKey(aliasOrCN, certPassword.toCharArray());