Ok. I installed the one provided by eu.agno3.jcifs, but didn't fix the issue.
Andrei Mura On Thu, Feb 3, 2022 at 4:26 PM Andrei Petru Mura <[email protected]> wrote: > Hmmm... Can you give me the group ID too please? Thanks > > Andrei > > On Thu, Feb 3, 2022 at 4:12 PM Jean-Baptiste Onofré <[email protected]> > wrote: > >> Hi >> >> I know that, depending of the use, bouncycastle 1.69 needs >> jcifs-ng/2.1.7 (as it introduced a breaking change). >> >> But probably not related to your issue (the update), but possible it's >> the same issue (due to bc breaking change). >> >> Regards >> JB >> >> On 03/02/2022 14:30, Andrei Petru Mura wrote: >> > Hmm... Which ones? I upgraded many others... Including java mail. I use >> > jakarta.mail 1.6.7 now. >> > >> > Andrei M. >> > >> > On Thu, Feb 3, 2022 at 3:25 PM Jean-Baptiste Onofré <[email protected] >> > <mailto:[email protected]>> wrote: >> > >> > Hi Andrei, >> > >> > Did you upgrade only bouncycastle 1.69 or other dependency ? >> > >> > I remember another deps should be updated. >> > >> > Regards >> > JB >> > >> > On 03/02/2022 14:09, Andrei Petru Mura wrote: >> > > Hi all, >> > > >> > > I upgraded bouncycastle to 1.69 in karaf. When trying to run this >> > code: >> > > >> > > MimeBodyPart textPart = new MimeBodyPart(); >> > > textPart.setContent(new String(body), "text/plain"); >> > > textPart.setHeader("Content-Type", messageContentType); >> > > textPart.setHeader("Content-Transfer-Encoding", "binary"); >> > > textPart.setHeader("Content-Disposition", "attachment; >> filename=" + >> > > fileName); >> > > >> > > SMIMESignedGenerator gen = new SMIMESignedGenerator(); >> > > gen.setContentTransferEncoding("base64"); >> > > JcaSimpleSignerInfoGeneratorBuilder signerInfoGenerator = new >> > > JcaSimpleSignerInfoGeneratorBuilder(); >> > > signerInfoGenerator = signerInfoGenerator.setProvider("BC"); >> > > SignerInfoGenerator signerGenerator = >> > > signerInfoGenerator.build(alg.algorithmWithRSA(), privateKey, >> > certificate); >> > > gen.addSignerInfoGenerator(signerGenerator); >> > > >> > > List<X509Certificate> certList = new >> ArrayList<X509Certificate>(); >> > > certList.add(certificate); >> > > @SuppressWarnings("rawtypes") >> > > Store certs = new JcaCertStore(certList); >> > > >> > > gen.addCertificates(certs); >> > > >> > > MimeMultipart signedReport = gen.generate(replyBody); >> > > ByteArrayOutputStream out = new ByteArrayOutputStream(); >> > > mimeMsg.writeTo(out); //the line which gives problems >> > > out.close(); >> > > >> > > I get this: >> > > >> > > javax.activation.UnsupportedDataTypeException: text/plain >> > > at javax.activation.DataHandler.writeTo(DataHandler.java:75) >> > ~[!/:2.9.0] >> > > at >> javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1670) >> > > ~[!/:1.6.7] >> > > at >> javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:972) >> > > ~[!/:1.6.7] >> > > at >> javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:537) >> > > ~[!/:1.6.7] >> > > >> > > Trying to make the long story short, after investigation, I find >> > that BC >> > > includes a file at META-INF/mailcap >> > > This shouldn't be a problem, but it seems to me that this is a >> > problem. >> > > >> > > If I try to add the mailcap manually before the above code >> > snippet, like >> > > this: >> > > >> > > MailcapCommandMap mc = (MailcapCommandMap) >> > > CommandMap.getDefaultCommandMap(); >> > > mc.addMailcap("text/html;; >> > > x-java-content-handler=com.sun.mail.handlers.text_html"); >> > > mc.addMailcap("text/xml;; >> > > x-java-content-handler=com.sun.mail.handlers.text_xml"); >> > > mc.addMailcap("text/plain;; >> > > x-java-content-handler=com.sun.mail.handlers.text_plain"); >> > > mc.addMailcap("multipart/*;; >> > > x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); >> > > mc.addMailcap("message/rfc822;; >> > > x-java-content-handler=com.sun.mail.handlers.message_rfc822"); >> > > >> > > it has no effect, although I can see that the command handler is >> > set there. >> > > >> > > After all this investigation, I conclude that this is related to >> > OSGI >> > > class loader. Any idea how to fix this or any hints? >> > > >> > > Thanks, >> > > Andrei Mura >> > >> >
