diff options
author | Roberto Tyley <roberto.tyley@gmail.com> | 2014-07-15 01:38:01 +0400 |
---|---|---|
committer | Roberto Tyley <roberto.tyley@gmail.com> | 2014-07-26 11:23:17 +0400 |
commit | 7cb752aaf746dc0b473afeb9e892b7fbc12666c5 (patch) | |
tree | cc4f91ddc18332b5adbe82e3fcb040d976c90105 /mail/src/main/java/org/spongycastle/mail/smime/SMIMEEnveloped.java | |
parent | 551830f8ea5177042af2c7dd1fc90888bc67387d (diff) |
Execute become-spongy.sh
https://github.com/rtyley/spongycastle/blob/3040af/become-spongy.sh
Diffstat (limited to 'mail/src/main/java/org/spongycastle/mail/smime/SMIMEEnveloped.java')
-rw-r--r-- | mail/src/main/java/org/spongycastle/mail/smime/SMIMEEnveloped.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/mail/src/main/java/org/spongycastle/mail/smime/SMIMEEnveloped.java b/mail/src/main/java/org/spongycastle/mail/smime/SMIMEEnveloped.java new file mode 100644 index 00000000..bf7a7ff4 --- /dev/null +++ b/mail/src/main/java/org/spongycastle/mail/smime/SMIMEEnveloped.java @@ -0,0 +1,59 @@ +package org.bouncycastle.mail.smime; + +import java.io.IOException; +import java.io.InputStream; + +import javax.mail.MessagingException; +import javax.mail.Part; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimePart; + +import org.bouncycastle.cms.CMSEnvelopedData; +import org.bouncycastle.cms.CMSException; + +/** + * containing class for an S/MIME pkcs7-mime encrypted MimePart. + */ +public class SMIMEEnveloped + extends CMSEnvelopedData +{ + MimePart message; + + private static InputStream getInputStream( + Part bodyPart) + throws MessagingException + { + try + { + return bodyPart.getInputStream(); + } + catch (IOException e) + { + throw new MessagingException("can't extract input stream: " + e); + } + } + + public SMIMEEnveloped( + MimeBodyPart message) + throws MessagingException, CMSException + { + super(getInputStream(message)); + + this.message = message; + } + + public SMIMEEnveloped( + MimeMessage message) + throws MessagingException, CMSException + { + super(getInputStream(message)); + + this.message = message; + } + + public MimePart getEncryptedContent() + { + return message; + } +} |