From: eunever32 on 10 Jun 2010 05:04 Hi I am trying to obtain the attachment from an encrypted email. The content when I decrypt looks like below. How can I cast this to a MimeMultipart ? The content after I decrypt is a ByteArrayInputStream decryptedContent = envelopedBodyPart.getUnencryptedContent( cert, privateKey ); (I am using com.isnetworks EnvelopedBodyPart.getUnencrypted.) The message is decrypting correctly as below but I am not getting the MimeMultipart that would allow me to get the attachment correctly. Thanks in advance. This is a multipart message in MIME format. --=_mixed 00561CF28025770E_= Content-Type: multipart/alternative; boundary="=_alternative 00561CF28025770E_=" --=_alternative 00561CF28025770E_= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: base64 --=_alternative 00561CF28025770E_= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: base64 DQo= --=_alternative 00561CF28025770E_=-- --=_mixed 00561CF28025770E_= Content-Type: text/plain; name="file100.txt" Content-Disposition: attachment; filename="file100.txt" Content-Transfer-Encoding: quoted-printable etc
From: eunever32 on 10 Jun 2010 05:51 On Jun 10, 10:04 am, "euneve...(a)yahoo.co.uk" <euneve...(a)yahoo.co.uk> wrote: > Hi > > I am trying to obtain the attachment from an encrypted email. > > The content when I decrypt looks like below. > > How can I cast this to a MimeMultipart ? > > The content after I decrypt is a ByteArrayInputStream > decryptedContent = envelopedBodyPart.getUnencryptedContent( cert, > privateKey ); > > (I am using com.isnetworks EnvelopedBodyPart.getUnencrypted.) > > The message is decrypting correctly as below but I am not getting the > MimeMultipart that would allow me to get the attachment correctly. > Thanks in advance. > > This is a multipart message in MIME format. > --=_mixed 00561CF28025770E_= > Content-Type: multipart/alternative; boundary="=_alternative > 00561CF28025770E_=" > > --=_alternative 00561CF28025770E_= > Content-Type: text/plain; charset="UTF-8" > Content-Transfer-Encoding: base64 > > --=_alternative 00561CF28025770E_= > Content-Type: text/html; charset="UTF-8" > Content-Transfer-Encoding: base64 > > DQo= > --=_alternative 00561CF28025770E_=-- > --=_mixed 00561CF28025770E_= > Content-Type: text/plain; name="file100.txt" > Content-Disposition: attachment; filename="file100.txt" > Content-Transfer-Encoding: quoted-printable > > etc By the way This is how the mailcap is defined: mailcap.addMailcap( "application/x-pkcs7-mime; ;" + "x-java-content- handler=com.isnetworks.smime.activation." + "EnvelopedBodyPartDataContentHandler" ); mailcap.addMailcap( "application/pkcs7-mime; ;" + "x-java-content-handler=com.isnetworks.smime.activation." + "EnvelopedBodyPartDataContentHandler" ); mailcap.addMailcap( "multipart/signed; ;" + "x-java-content-handler=com.isnetworks.smime.activation." + "SignedMultipartDataContentHandler" ); mailcap.addMailcap( "application/x-pkcs7-signature; ; " + "x-java-content-handler=com.isnetworks.smime.activation." + "SignedBodyPartDataContentHandler" ); mailcap.addMailcap( "application/pkcs7-signature; ; " + "x-java-content-handler=com.isnetworks.smime.activation." + "SignedBodyPartDataContentHandler" ); Do I need something extra here? Such as multipart/alternative ?? I tried this but not sure exactly how to code for this
From: Roedy Green on 10 Jun 2010 22:04 On Thu, 10 Jun 2010 02:04:40 -0700 (PDT), "eunever32(a)yahoo.co.uk" <eunever32(a)yahoo.co.uk> wrote, quoted or indirectly quoted someone who said : > >How can I cast this to a MimeMultipart ? I have not done this myself, but it seems to me you need four steps: 1. get the armoured encrypted message characters, with headers stripped off. 2. strip off the armouring so you have an array of bytes. 3. run this through the decryption algorithm. 4. convert the decrypted bytes back into characters via some encoding. -- Roedy Green Canadian Mind Products http://mindprod.com Have you ever noticed that any computer search in the movies, is always linear, with, for example, candidate fingerprints flashing up on the screen one after another? The public is still under the delusion that electronic files are microscopic filing cabinets made out of tiny wires or magnetic patches inside the computer. Most lay people are surprised that it is easy for a computer to file things simultaneously by a dozen different schemes, and that they can have any report printed in any number of different sorted orders. With physical files, they are limited to one ordering/access.
From: Martin Gregorie on 11 Jun 2010 08:05 On Thu, 10 Jun 2010 19:04:36 -0700, Roedy Green wrote: > On Thu, 10 Jun 2010 02:04:40 -0700 (PDT), "eunever32(a)yahoo.co.uk" > <eunever32(a)yahoo.co.uk> wrote, quoted or indirectly quoted someone who > said : > > >>How can I cast this to a MimeMultipart ? > > I have not done this myself, but it seems to me you need four steps: > > 1. get the armoured encrypted message characters, with headers stripped > off. > > 2. strip off the armouring so you have an array of bytes. > > 3. run this through the decryption algorithm. > > 4. convert the decrypted bytes back into characters via some encoding. (4) should become: - create a ByteArrayInputStream from the decrypted byte array - pass that to a MimeMessage constructor. At this point you can use the standard MimeMessage and MultiPart methods to parse the message and extract its content. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
From: Martin Gregorie on 11 Jun 2010 08:05 On Thu, 10 Jun 2010 19:04:36 -0700, Roedy Green wrote: > On Thu, 10 Jun 2010 02:04:40 -0700 (PDT), "eunever32(a)yahoo.co.uk" > <eunever32(a)yahoo.co.uk> wrote, quoted or indirectly quoted someone who > said : > > >>How can I cast this to a MimeMultipart ? > > I have not done this myself, but it seems to me you need four steps: > > 1. get the armoured encrypted message characters, with headers stripped > off. > > 2. strip off the armouring so you have an array of bytes. > > 3. run this through the decryption algorithm. > > 4. convert the decrypted bytes back into characters via some encoding. (4) should become: - create a ByteArrayInputStream from the decrypted byte array - pass that to a MimeMessage constructor. At this point you can use the standard MimeMessage and MultiPart methods to parse the message and extract its content. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
|
Next
|
Last
Pages: 1 2 3 4 Prev: Java VM 1.6.0 Sorting Collections Next: Best way to halt Java process? |