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); }
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)); }
new BcRSAKeyTransEnvelopedRecipient(PrivateKeyFactory.createKey(PrivateKeyInfo.getInstance(key.getEncoded())))); return SMIMEUtil.toMimeBodyPart(decryptedData); } else
aDecompressedPart = SMIMEUtil.toMimeBodyPart (smimeCompressedParser.getContent (aExpander)); aDecompressedPart = SMIMEUtil.toMimeBodyPart (aCompressed.getContent (aExpander));
public void decompress(AS2Message msg) throws DispositionException { try { if (logger.isDebugEnabled()) { logger.debug("Decompressing a compressed message"); } SMIMECompressed compressed = new SMIMECompressed(msg.getData()); // decompression step MimeBodyPart MimeBodyPart recoveredPart = SMIMEUtil.toMimeBodyPart(compressed.getContent(new ZlibExpanderProvider())); // Update the message object msg.setData(recoveredPart); } catch (Exception ex) { msg.setLogMsg("Error decompressing received message: " + ex.getCause()); logger.error(msg, ex); throw new DispositionException(new DispositionType("automatic-action", "MDN-sent-automatically", "processed", "Error", "unexpected-processing-error"), AS2ReceiverModule.DISP_DECOMPRESSION_ERROR, ex); } }
if (bLargeFileOn) aDecryptedDataBodyPart = SMIMEUtil.toMimeBodyPart (aRecipient.getContentStream (new JceKeyTransEnvelopedRecipient (aPrivateKey).setProvider (m_sSecurityProviderName))); aDecryptedDataBodyPart = SMIMEUtil.toMimeBodyPart (aDecryptedData);
result = SMIMEUtil.toMimeBodyPart(recipient.getContent(jceKey)); if (log.isDebugEnabled()) { log.debug("Successfully decrypted message with subject '" + msg.getSubject()
JceKeyTransEnvelopedRecipient recipient = new JceKeyTransEnvelopedRecipient(keyHolder.getPrivateKey()); strippedMessage = SMIMEUtil.toMimeBodyPart(info.getContent(recipient)); LOGGER.info("Encrypted message decrypted"); } catch (Exception e) {