com.digt.trusted.cms
Class CMSEnvelopedDataGenerator

java.lang.Object
  extended by com.digt.trusted.cms.CMSEnvelopedDataGenerator

public class CMSEnvelopedDataGenerator
extends java.lang.Object

General class for generating a pkcs7-mime message. A simple example of usage.

      CMSEnvelopedDataGenerator  fact = new CMSEnvelopedDataGenerator();

      fact.addKeyTransRecipient(cert);

      CMSEnvelopedData         data = fact.generate(content, algorithm, "DIGT");
 


Field Summary
static java.lang.String AES128_CBC
           
static java.lang.String AES192_CBC
           
static java.lang.String AES256_CBC
           
static java.lang.String CAST5_CBC
           
static java.lang.String DES_EDE3_CBC
           
static java.lang.String GOST28147_CFB
           
static java.lang.String IDEA_CBC
           
static java.lang.String RC2_CBC
           
 
Constructor Summary
CMSEnvelopedDataGenerator()
          base constructor
 
Method Summary
 void addKEKRecipient(javax.crypto.SecretKey key, byte[] keyIdentifier)
          add a KEK recipient.
 void addKeyTransRecipient(java.security.PublicKey key, byte[] subKeyId)
          add a recipient
 void addKeyTransRecipient(java.security.cert.X509Certificate cert)
          add a recipient.
 CMSEnvelopedData generate(CMSProcessable content, java.lang.String encryptionOID, int keySize, java.lang.String provider)
          generate an enveloped object that contains an CMS Enveloped Data object using the given provider.
 CMSEnvelopedData generate(CMSProcessable content, java.lang.String encryptionOID, java.lang.String provider)
          generate an enveloped object that contains an CMS Enveloped Data object using the given provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DES_EDE3_CBC

public static final java.lang.String DES_EDE3_CBC
See Also:
Constant Field Values

RC2_CBC

public static final java.lang.String RC2_CBC
See Also:
Constant Field Values

IDEA_CBC

public static final java.lang.String IDEA_CBC
See Also:
Constant Field Values

CAST5_CBC

public static final java.lang.String CAST5_CBC
See Also:
Constant Field Values

AES128_CBC

public static final java.lang.String AES128_CBC
See Also:
Constant Field Values

AES192_CBC

public static final java.lang.String AES192_CBC
See Also:
Constant Field Values

AES256_CBC

public static final java.lang.String AES256_CBC
See Also:
Constant Field Values

GOST28147_CFB

public static final java.lang.String GOST28147_CFB
See Also:
Constant Field Values
Constructor Detail

CMSEnvelopedDataGenerator

public CMSEnvelopedDataGenerator()
base constructor

Method Detail

addKeyTransRecipient

public void addKeyTransRecipient(java.security.cert.X509Certificate cert)
                          throws java.lang.IllegalArgumentException
add a recipient.

Throws:
java.lang.IllegalArgumentException

addKeyTransRecipient

public void addKeyTransRecipient(java.security.PublicKey key,
                                 byte[] subKeyId)
                          throws java.lang.IllegalArgumentException
add a recipient

Parameters:
key - the public key used by the recipient
subKeyId - the identifier for the recipient's public key
Throws:
java.lang.IllegalArgumentException

addKEKRecipient

public void addKEKRecipient(javax.crypto.SecretKey key,
                            byte[] keyIdentifier)
add a KEK recipient.


generate

public CMSEnvelopedData generate(CMSProcessable content,
                                 java.lang.String encryptionOID,
                                 java.lang.String provider)
                          throws java.security.NoSuchAlgorithmException,
                                 java.security.NoSuchProviderException,
                                 CMSException
generate an enveloped object that contains an CMS Enveloped Data object using the given provider.

Throws:
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
CMSException

generate

public CMSEnvelopedData generate(CMSProcessable content,
                                 java.lang.String encryptionOID,
                                 int keySize,
                                 java.lang.String provider)
                          throws java.security.NoSuchAlgorithmException,
                                 java.security.NoSuchProviderException,
                                 CMSException
generate an enveloped object that contains an CMS Enveloped Data object using the given provider.

Throws:
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
CMSException