[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: [iaik-jce] How to set the attachment by S/MIME object



Simple replace the UrlDataSource in demo demo.smime.SMimeSend by a
FileDataSource loading your required file.

     MimeBodyPart mbp1 = new SMimeBodyPart();
     mbp1.setText("This is a Test of the IAIK S/MIME implementation!\n\n");
     // try to test an attachment
     // this demo attaches our homepage
     MimeBodyPart attachment = new SMimeBodyPart();
     URL url = new URL("http://www.iaik.tu-graz.ac.at/");
     attachment.setDataHandler(new DataHandler(new URLDataSource(url)));
     attachment.setFileName("index.html");
     Multipart mp = new SMimeMultipart();
     mp.addBodyPart(mbp1);
     mp.addBodyPart(attachment);
     DataHandler multipart = new DataHandler(mp, mp.getContentType());
     ....

     replace by

     MimeBodyPart mbp1 = new SMimeBodyPart();
     mbp1.setText("This is a Test of the IAIK S/MIME implementation!\n\n");
     // try to test an attachment
     // this demo attaches our homepage
     MimeBodyPart attachment = new SMimeBodyPart();
     String fileName = ...;
     FileDataSource fds = new FileDataSource(fileName);
     DataHandler dh = new DataHandler(fds);
     attachment.setDataHandler(dh);
     attachment.setFileName(fileName);
     Multipart mp = new SMimeMultipart();
     mp.addBodyPart(mbp1);
     mp.addBodyPart(attachment);
     DataHandler multipart = new DataHandler(mp, mp.getContentType());
     ....

Dieter Bratko

-----Ursprüngliche Nachricht-----
Von: iaik-jce-owner@iaik.tu-graz.ac.at
[mailto:iaik-jce-owner@iaik.tu-graz.ac.at]Im Auftrag von Henry Yang
Gesendet: Mittwoch, 29. März 2000 02:07
An: IAIK
Betreff: [iaik-jce] How to set the attachment by S/MIME object


Hi, All
I have a question/issue for all experts here.
I couldn't find any useful information to set the attachment for different
file formats in iaik.security.smime package.
All I need is that create a S/MIME signed and encrypted package with an
attachment file inside.
Is this a right method setContent(javax.mail.Multipart multipart) to create
the attachment object inside of it ?
Any suggestion would be really appreciated.

Regards

Henry Yang


smime.p7s