org.webdocwf.util.smime.activation
Class CMSEnvelopedDataSource

java.lang.Object
  |
  +--org.webdocwf.util.smime.activation.CMSEnvelopedDataSource
All Implemented Interfaces:
javax.activation.DataSource

public class CMSEnvelopedDataSource
extends java.lang.Object
implements javax.activation.DataSource

CMSEnvelopedDataSource represents implementation of DataSource interfaces. It is used within MimeMessage as a source of data. Also, object of this class is used to create DER encoded Cryptographic Message Syntax (CMS) object represented in ASN.1 notation according to RFC2630. This object (CMS) is used as the source of data for MimeMessage in the process of sending encrypted message.


Constructor Summary
CMSEnvelopedDataSource(byte[] message0, java.lang.String algType0, int keyLength0)
          Constructs CMS object for encryption with MIME Message in form of byte array and with given values for encryption algorithm.
CMSEnvelopedDataSource(javax.mail.internet.MimeMessage message0, java.lang.String algType0, int keyLength0)
          Constructs CMS object for encryption with MIME Message in form of instance of MimeMessage class and with defined values for encryption algorithm.
 
Method Summary
 void addRecipient(java.security.cert.X509Certificate cert0)
          Adds recipient.
 byte[] getBASE64CMSEnvelopedObject()
          Returns complete DER encoded CMS Enveloped Object with BASE64 encoding
 byte[] getCMSEnvelopedObject()
          Returns complete DER encoded CMS Enveloped Object.
 java.lang.String getContentType()
          Implements getContentType method from DataSource interface
 java.io.InputStream getInputStream()
          Implements getInputStream method from DataSource interface
 java.lang.String getName()
          ImplementS getName method from DataSource interface
 java.io.OutputStream getOutputStream()
          Implements getOutputStream method from DataSource interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CMSEnvelopedDataSource

public CMSEnvelopedDataSource(byte[] message0,
                              java.lang.String algType0,
                              int keyLength0)
                       throws SMIMEException
Constructs CMS object for encryption with MIME Message in form of byte array and with given values for encryption algorithm.
Parameters:
message0 - message for encryption
algType0 - given symmetric algorithm for encryption
keyLength0 - key length in bits
Throws:
SMIMEException - in case of unrecognized type of symmetryc algorithm or invalid key length. Also, it can be caused by problems in construction or work with some inner objects instantiated from classes that belong to org.webdocwf.util.smime.der or org.webdocwf.util.smime.cms packages used in other CMSEnvelopedDataSource constructor.

CMSEnvelopedDataSource

public CMSEnvelopedDataSource(javax.mail.internet.MimeMessage message0,
                              java.lang.String algType0,
                              int keyLength0)
                       throws SMIMEException
Constructs CMS object for encryption with MIME Message in form of instance of MimeMessage class and with defined values for encryption algorithm.
Parameters:
message0 - message for encryption
algType0 - given symmetric algorithm for encryption
keyLength0 - key length in bits
Throws:
SMIMEException - in case of unrecognized type of symmetryc algorithm, invalid key length or in case of failure in MimeMessageConvertor class which performes transformation from MimeMessage object to byte array. Also, it can be caused by problems in construction or work with some inner objects instantiated from classes that belong to org.webdocwf.util.smime.der or org.webdocwf.util.smime.cms packages used in other CMSEnvelopedDataSource constructor.
Method Detail

addRecipient

public void addRecipient(java.security.cert.X509Certificate cert0)
                  throws SMIMEException
Adds recipient. This method must be performed at least once.
Parameters:
cert0 - recipient's X509Certificate (.cer file).
Throws:
SMIMEException - caused by addRecipient method of inner object which is instance of class RecipientInfos.

getCMSEnvelopedObject

public byte[] getCMSEnvelopedObject()
                             throws SMIMEException
Returns complete DER encoded CMS Enveloped Object.
Returns:
DER encoded CMS Enveloped Object represented as byte array
Throws:
SMIMEException - caused by problems in construction or work with some inner objects instantiated from classes that belong to org.webdocwf.util.smime.der or org.webdocwf.util.smime.cms packages.

getBASE64CMSEnvelopedObject

public byte[] getBASE64CMSEnvelopedObject()
                                   throws SMIMEException
Returns complete DER encoded CMS Enveloped Object with BASE64 encoding
Returns:
DER encoded CMS Enveloped Object represented as byte array with performed BASE64 encoding
Throws:
SMIMEException - in case of failure in Base64 encoding performed on the generated SMIME message byte array by Base64ForMime class. Also, it can be caused by problems in construction or work with some inner objects instantiated from classes that belong to org.webdocwf.util.smime.der or org.webdocwf.util.smime.cms packages used in getCMSEnvelopedObject() method.

getContentType

public java.lang.String getContentType()
Implements getContentType method from DataSource interface
Specified by:
getContentType in interface javax.activation.DataSource
Returns:
Content-Type for MIME message header field

getInputStream

public java.io.InputStream getInputStream()
                                   throws SMIMEIOException
Implements getInputStream method from DataSource interface
Specified by:
getInputStream in interface javax.activation.DataSource
Returns:
CMS enveloped object
Throws:
SMIMEIOException - thrown as result of SMIMEException

getName

public java.lang.String getName()
ImplementS getName method from DataSource interface
Specified by:
getName in interface javax.activation.DataSource
Returns:
Name: EnvelopedDataContentInfo

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Implements getOutputStream method from DataSource interface. This method is not in use.
Specified by:
getOutputStream in interface javax.activation.DataSource
Returns:
nothing
Throws:
java.io.IOException - is always thrown when this method is used.


Copyright © 2002-2002 Together Teamlösungen. All Rights Reserved.