talx x1.0.5

talx.util
Class AutoUpdateBodyPart

java.lang.Object
  extended byjavax.mail.BodyPart
      extended byjavax.mail.internet.MimeBodyPart
          extended bytalx.util.AutoUpdateBodyPart
All Implemented Interfaces:
javax.mail.internet.MimePart, javax.mail.Part

public class AutoUpdateBodyPart
extends javax.mail.internet.MimeBodyPart

Overrides the writeTo method to update headers first and use CRLF line breaks. This class extends MimeBodyPart to update the headers before writing out the content. This is necessary in order to sign the content. In the super class, the sequence:

     MimeMessage mm = new MimeMessage();
     MimeMultipart mp = new MimeMultipart();
     MimeBodyPart mbp = new MimeBodyPart();
     mbp.setText(content);
     mbp.writeTo(securityStream);
     mp.addBodyPart(mbp);
     mp.addBodyPart(sign(securityStream));
     mm.setContent(mp);
     transport.send(m);
 
would result in an invalid signature. This is because the updateHeaders method would not be called on mbp until the call to send. Thus, the signature would be valid only for the bytes without the additional headers added for transport. This is inconsistent with the multipart/signed specification (RFC 2633). This class solves that problem by calling updateHeaders prior to writing the bytes to the output stream. So, any additional headers have already been inserted when the output stream is written.


Field Summary
 
Fields inherited from class javax.mail.internet.MimeBodyPart
content, contentStream, dh, headers
 
Fields inherited from class javax.mail.BodyPart
parent
 
Fields inherited from interface javax.mail.Part
ATTACHMENT, INLINE
 
Constructor Summary
AutoUpdateBodyPart()
           
 
Method Summary
 void writeTo(java.io.OutputStream os)
           
 
Methods inherited from class javax.mail.internet.MimeBodyPart
addHeader, addHeaderLine, getAllHeaderLines, getAllHeaders, getContent, getContentID, getContentLanguage, getContentMD5, getContentStream, getContentType, getDataHandler, getDescription, getDisposition, getEncoding, getFileName, getHeader, getHeader, getInputStream, getLineCount, getMatchingHeaderLines, getMatchingHeaders, getNonMatchingHeaderLines, getNonMatchingHeaders, getRawInputStream, getSize, isMimeType, removeHeader, setContent, setContent, setContentID, setContentLanguage, setContentMD5, setDataHandler, setDescription, setDescription, setDisposition, setFileName, setHeader, setText, setText, updateHeaders
 
Methods inherited from class javax.mail.BodyPart
getParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoUpdateBodyPart

public AutoUpdateBodyPart()
Method Detail

writeTo

public void writeTo(java.io.OutputStream os)
             throws java.io.IOException,
                    javax.mail.MessagingException
Throws:
java.io.IOException
javax.mail.MessagingException

talx x1.0.5

© 2001-2005 University of Oregon.
Eugene OR 97403, U.S.A. All Rights Reserved.