View Javadoc
1 /* 2 * Title: S/MIME Project 3 * Description: S/MIME email sending capabilities 4 * @Author Vladimir Radisic 5 * @Version 2.0.1 6 */ 7 8 9 package org.webdocwf.util.smime.cms; 10 11 12 import org.webdocwf.util.smime.exception.SMIMEException; 13 import org.webdocwf.util.smime.der.DERSetPr; 14 import java.security.cert.X509Certificate; 15 16 17 /*** 18 * RecipientInfos class is DER encoded container, represented in ASN.1 notation 19 * according to RFC2630, used for storing individual information needed for all 20 * recipients of encrypted message. This information, beside other information, 21 * contain specifically encrypted symmetric key for all particular recipients.<BR> 22 * <BR> 23 * RecipientInfos ::= SET OF RecipientInfo<BR> 24 * <BR> 25 * <DL> 26 * RecipientInfo ::= CHOICE { <BR> 27 * <DD> ktri KeyTransRecipientInfo,<BR> 28 * <DD> kari [1] KeyAgreeRecipientInfo,<BR> 29 * <DD> kekri [2] KEKRecipientInfo }<BR> 30 * <BR> 31 * </DL> 32 * <DL> 33 * KeyTransRecipientInfo ::= SEQUENCE { <BR> 34 * <DD> version CMSVersion, -- always set to 0 or 2 <BR> 35 * <DD> rid RecipientIdentifier, <BR> 36 * <DD> keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, <BR> 37 * <DD> encryptedKey EncryptedKey }<BR> 38 * </DL> 39 */ 40 public class RecipientInfos extends DERSetPr { 41 42 /*** 43 * Container for symetric key initialized by constructor 44 */ 45 private byte[] symmetricKey; 46 47 /*** 48 * Input information for all recipients is the same: symmetric key. This 49 * constructor is advisable to use. 50 * @param symKey0 symmetric key represented as byte array 51 * @exception SMIMEException thrown by super class constructor. 52 */ 53 public RecipientInfos(byte[] symKey0) throws SMIMEException { 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 cert0) throws SMIMEException { 65 KeyTransRecipientInfo keyTrans = new KeyTransRecipientInfo(symmetricKey); 66 67 keyTrans.addRecipient(cert0); 68 super.addContent(keyTrans.getDEREncoded()); 69 } 70 } 71

This page was automatically generated by Maven