KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > oyster > cms > RecipientInfos


1 /*
2  * Title: Oyster Project
3  * Description: S/MIME email sending capabilities
4  * @Author Vladimir Radisic
5  * @Version 2.1.5
6  */

7
8
9 package org.enhydra.oyster.cms;
10
11 import org.enhydra.oyster.exception.SMIMEException;
12 import org.enhydra.oyster.der.DERSetPr;
13 import java.security.cert.X509Certificate JavaDoc;
14
15
16 /**
17  * RecipientInfos class is DER encoded container, represented in ASN.1 notation
18  * according to RFC2630, used for storing individual information needed for all
19  * recipients of encrypted message. This information, beside other information,
20  * contain specifically encrypted symmetric key for all particular recipients.<BR>
21  * <BR>
22  * RecipientInfos ::= SET OF RecipientInfo<BR>
23  * <BR>
24  * <DL>
25  * RecipientInfo ::= CHOICE { <BR>
26  * <DD> ktri KeyTransRecipientInfo,<BR>
27  * <DD> kari [1] KeyAgreeRecipientInfo,<BR>
28  * <DD> kekri [2] KEKRecipientInfo }<BR>
29  * <BR>
30  * </DL>
31  * <DL>
32  * KeyTransRecipientInfo ::= SEQUENCE { <BR>
33  * <DD> version CMSVersion, -- always set to 0 or 2 <BR>
34  * <DD> rid RecipientIdentifier, <BR>
35  * <DD> keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, <BR>
36  * <DD> encryptedKey EncryptedKey }<BR>
37  * </DL>
38  */

39 public class RecipientInfos extends DERSetPr {
40
41 /**
42  * Container for symetric key initialized by constructor
43  */

44   private byte[] symmetricKey;
45
46 /**
47  * Input information for all recipients is the same: symmetric key. This
48  * constructor is advisable to use.
49  * @param symKey0 symmetric key represented as byte array
50  * @exception SMIMEException thrown by super class constructor.
51  */

52   public RecipientInfos (byte[] symKey0) throws SMIMEException
53   {
54     symmetricKey = symKey0;
55   }
56
57 /**
58  * Adds Recipient via Key Transport Recipient Infos. X509 certificate is used
59  * to obtain all information needed for construction and organise information
60  * about particular recipient of encrypted message.
61  * @param cert0 X509 certificate of partial recipient
62  * @exception SMIMEException thrown in super class addContent method.
63  */

64   public void addRecipient (X509Certificate JavaDoc cert0) throws SMIMEException {
65     KeyTransRecipientInfo keyTrans = new KeyTransRecipientInfo(symmetricKey);
66     keyTrans.addRecipient(cert0);
67     super.addContent(keyTrans.getDEREncoded());
68   }
69 }
70
71
72
73
Popular Tags