iaik.smime
Class SMimeMultipart

java.lang.Object
  extended by javax.mail.Multipart
      extended by javax.mail.internet.MimeMultipart
          extended by iaik.smime.SMimeMultipart

public class SMimeMultipart
extends javax.mail.internet.MimeMultipart

Extends the MimeMultipart class of the javax.mail.internet package.

This class shall used when creating a multipart object to be send within a multipart/signed message. When using the parent MimeMultipart class no canonicalization is performed.


Field Summary
 
Fields inherited from class javax.mail.internet.MimeMultipart
ds, parsed
 
Fields inherited from class javax.mail.Multipart
contentType, parent, parts
 
Constructor Summary
SMimeMultipart()
          Default constructor.
SMimeMultipart(javax.activation.DataSource ds)
          Creates a new MimeMultipart and its bodyparts from the given DataSource.
SMimeMultipart(java.lang.String subtype)
          Creates a new MimeMultipart for the given subtype.
 
Method Summary
 void addBodyPart(javax.mail.BodyPart part)
          Adds a body part.
 void addBodyPart(javax.mail.BodyPart part, int index)
          Inserts a body part at the given index.
 void checkForSMimeParts(boolean checkForSMimeParts)
          Turns on/off control to use SMimeBodyParts insteadof MimeBodyParts when adding a bodypart to this multipart.
protected  void updateHeaders()
          Updates the headers of all included body parts.
 
Methods inherited from class javax.mail.internet.MimeMultipart
createInternetHeaders, createMimeBodyPart, createMimeBodyPart, getBodyPart, getBodyPart, getCount, parse, setSubType, writeTo
 
Methods inherited from class javax.mail.Multipart
getContentType, getParent, removeBodyPart, removeBodyPart, setMultipartDataSource, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMimeMultipart

public SMimeMultipart()
Default constructor. Creates an empty SMimeMultipart.


SMimeMultipart

public SMimeMultipart(javax.activation.DataSource ds)
               throws javax.mail.MessagingException
Creates a new MimeMultipart and its bodyparts from the given DataSource.

Only calls the corresponding constructor of the MimeMultipart super class.

Parameters:
ds - the DataSource from which to create the MimeMultipart
Throws:
javax.mail.MessagingException - if an error occurs when creating the MimeMultipart

SMimeMultipart

public SMimeMultipart(java.lang.String subtype)
Creates a new MimeMultipart for the given subtype.

Only calls the corresponding constructor of the MimeMultipart super class.

Parameters:
subtype - the Mime subtype
Method Detail

updateHeaders

protected void updateHeaders()
                      throws javax.mail.MessagingException
Updates the headers of all included body parts.

The SignedContent class must have access to this protected method. And that is the reason for extending the javax.mail.internet.MimeMultipart class.

Overrides:
updateHeaders in class javax.mail.internet.MimeMultipart
Throws:
javax.mail.MessagingException - if an error occurs during the updating process

addBodyPart

public void addBodyPart(javax.mail.BodyPart part)
                 throws javax.mail.MessagingException
Adds a body part.

Overrides:
addBodyPart in class javax.mail.Multipart
Parameters:
part - the body part to be added
Throws:
javax.mail.MessagingException - if an error occurs when adding the body part (e.g. the supplied bodypart is no SMimeBodyPart in the case of SMimePart control is enabled

addBodyPart

public void addBodyPart(javax.mail.BodyPart part,
                        int index)
                 throws javax.mail.MessagingException
Inserts a body part at the given index.

Overrides:
addBodyPart in class javax.mail.Multipart
Parameters:
part - the body part to be inserted
index - the index where the body part shall be inserted
Throws:
javax.mail.MessagingException - if an error occurs when adding the body part (e.g. the supplied body part is no SMimeBodyPart in the case of SMimePart control is enabled

checkForSMimeParts

public void checkForSMimeParts(boolean checkForSMimeParts)
Turns on/off control to use SMimeBodyParts insteadof MimeBodyParts when adding a bodypart to this multipart. Especially when creating a signed message of type multipart/signed ("clear-signed") care has to be taken to properly canonicalize -- in particular text -- messages to give the same unique representation on the sender side where the signature is created and on the recipient side where the signature is verified.
The content of a signed message may be composed of MimeMultiparts consiting theirselves of several MimeBodyParts. To ensure that these body parts are canonicalized, they have to be modelled as SMimeBodyPart objects rather than using plain MimeBodyParts. When building a multipart entity from several body parts, the SMimeBodyParts have to be inserted into a SMimeMultipart object instead of using a plain MimeMultipart.
To avoid verification problems due to usage of not canonicalized parts, IAIK-CMS by default checks if SMimeMultiparts and SMimeBodyParts are used when creating a signed message. An exception is thrown if only plain MimeBodyParts and MimeMultiparts are used. However, when signing an already canonicalized entity (e.g. the content of a message just parsed) this check for SMimeMultiparts/SMimeBodyParts may not be required. In this case it might give some processing overhead to convert any MimeMultipart and MimeBodyPart to the required SMimeMultipart respectively SMimeBodyPart. For that reason it is possible to turn off the SMimePart check for a particular SignedContent, SMimeMultipart and/or SMimeBodyPart object or generally disable the SMimeBodyPart check throughout the whole application environment. When choosing the latter option by calling
 SMimeParameters.setCheckForSMimeParts(false);
 
take care to continue to use SMimeBodyParts and SMimeMultiparts when signing a newly created yet not canoinicalized content.

Parameters:
checkForSMimeParts - whether to turn on/off SMimePart checking

This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note).

IAIK-CMS 6.0, (c) 2002 IAIK, (c) 2003, 2023 SIC