Ok some progress I had extended org.apache.james.mime4j.message.DefaultMessageBuilder, to include fields and was not using org.apache.james.jdkim.impl.Message.newMessageBuilder(). I've changed this to use a decorator pattern, so the original code is now untouched.
The classcastexception is no longer being thrown, but the org.apache.james.jdkim.impl.Message.getBodyInputStream() is still returning an empty InputStream, resulting in the wrong body hash. I had looked at Mailets. It seems a useful interface for integration with James server, however it complicates my integration. It is not clear to me how to integrate using Mailets, and I've not been able to find much documentation associated with such an objective. My extension application must integrate with Sendmail MTA, without using a transport socket, where Sendmail milter API is exposed else a standard install of opendkim would be fine. On Wed, Sep 25, 2013 at 9:29 AM, Justin Robinson < dkim-proj...@fluidnotions.com> wrote: > Hi Stefano, > I was very happy to discover that you where signing millions of email's > initially, now I'm just confused. This is an uncaught exception, so I was > thinking maybe it was unnoticed or something. > > I'm using apache-mime4j-0.7.2, apache-jdkim-0.2 lists this as a > dependancy in the maven pom.xml. > > DKIMSign.pl is written in perl, if this is what you are referring to. I am > not a perl developer and can barely read perl. But I'm open to any solution > at this stage, I did see there is a test class > called org.apache.james.jdkim.PerlDKIMTest, how does perl relate to the > apache-jdkim project? > > I've had a look at the causes for the ClassCastException, and it is not > easy to fix, due to inheritance issues. These two classes have > completely different abstract parent classes, they can only be referenced > by org.apache.james.mime4j.dom.Message because their concrete children > implement the interface. > > Are you suggesting I revert to apache-mime4j-0.7 rather then > apache-mime4j-0.7.2? > > > On Wed, Sep 25, 2013 at 9:06 AM, Stefano Bagnara <apa...@bago.org> wrote: > >> 2013/9/25 Justin Robinson <dkim-proj...@fluidnotions.com>: >> > [...] >> > java.lang.ClassCastException: >> org.apache.james.mime4j.message.MultipartImpl >> > cannot be cast to org.apache.james.mime4j.dom.SingleBody >> > at >> org.apache.james.jdkim.impl.Message.getBodyInputStream(Message.java:80) >> > at org.apache.james.jdkim.DKIMSigner.sign(DKIMSigner.java:85) >> >> This may happen if mime4j is not correctly instantiated/invoked. >> mime4j has to be instructed to do raw parsing (instead of the default >> multipart parsing). >> >> BTW I use DKIMSign mailet to sign millions messages. DKIMSign doesn't >> use mime4j. >> Maybe there is a bug in the mime4j parsing part. >> >> Are you using mime4j-0.7 ? >> >> >> http://svn.apache.org/viewvc/james/jdkim/tags/apache-jdkim-project-0.2/main/src/main/java/org/apache/james/jdkim/impl/Message.java?view=markup >> MessageServiceFactory mbf = MessageServiceFactory.newInstance(); >> 70 mbf.setAttribute("MimeEntityConfig", mec); >> 71 mbf.setAttribute("FlatMode", true); >> 72 mbf.setAttribute("ContentDecoding", false); >> >> The FlatMode and ContentDecoding options are needed in order for mime4j >> to work. >> If they are not used or mime4j doesn't get it then you get a >> MultipartImpl object and jdkim doesn't work. >> >> Stefano >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org >> For additional commands, e-mail: server-dev-h...@james.apache.org >> >> >