01: package org.bouncycastle.mail.smime;
02:
03: import java.io.IOException;
04: import java.io.InputStream;
05:
06: import javax.mail.MessagingException;
07: import javax.mail.Part;
08: import javax.mail.internet.MimeBodyPart;
09: import javax.mail.internet.MimeMessage;
10: import javax.mail.internet.MimePart;
11:
12: import org.bouncycastle.cms.CMSEnvelopedData;
13: import org.bouncycastle.cms.CMSException;
14:
15: /**
16: * containing class for an S/MIME pkcs7-mime encrypted MimePart.
17: */
18: public class SMIMEEnveloped extends CMSEnvelopedData {
19: MimePart message;
20:
21: private static InputStream getInputStream(Part bodyPart)
22: throws MessagingException {
23: try {
24: return bodyPart.getInputStream();
25: } catch (IOException e) {
26: throw new MessagingException("can't extract input stream: "
27: + e);
28: }
29: }
30:
31: public SMIMEEnveloped(MimeBodyPart message)
32: throws MessagingException, CMSException {
33: super (getInputStream(message));
34:
35: this .message = message;
36: }
37:
38: public SMIMEEnveloped(MimeMessage message)
39: throws MessagingException, CMSException {
40: super (getInputStream(message));
41:
42: this .message = message;
43: }
44:
45: public MimePart getEncryptedContent() {
46: return message;
47: }
48: }
|