KickJava   Java API By Example, From Geeks To Geeks.

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


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.DERSequencePr;
13
14
15 /**
16  * EnvelopedData is DER encoded container for information represented in
17  * ASN.1 notation according to RFC2630, used for construction CMS object
18  * of encrypted message.<BR>
19  * <BR>
20  * <DL>
21  * EnvelopedData ::= SEQUENCE {<BR>
22  * <DD> version CMSVersion,<BR>
23  * <DD> originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL,<BR>
24  * <DD> recipientInfos RecipientInfos,<BR>
25  * <DD> encryptedContentInfo EncryptedContentInfo,<BR>
26  * <DD> unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL }<BR>
27  * </DL>
28  */

29 public class EnvelopedData extends DERSequencePr {
30
31 /**
32  * Determinate order of adding commponents
33  */

34   int orderIdentifier = 0;
35
36 /**
37  * Constructs empty Enveloped Data.
38  * @exception SMIMEException thrown from super class constructor.
39  */

40   public EnvelopedData () throws SMIMEException
41   {
42   }
43
44 /**
45  * Adds CMS Version.
46  * @param ver0 CMS version represented as byte array
47  * @exception SMIMEException if order of adding components is wrong. Also, it
48  * can be thrown from super class addContent method.
49  */

50   public void addCMSVersion (byte[] ver0) throws SMIMEException {
51     if (orderIdentifier == 0) {
52       super.addContent(ver0);
53       orderIdentifier++;
54       orderIdentifier++;
55     }
56     else
57       throw new SMIMEException(this, 1018);
58   }
59
60 /**
61  * Adds Recipient Infos.
62  * @param info0 Recipient Infos represented as byte array
63  * @exception SMIMEException if order of adding components is wrong. Also, it
64  * can be thrown from super class addContent method.
65  */

66   public void addRecipientInfos (byte[] info0) throws SMIMEException {
67     if (orderIdentifier == 2) {
68       super.addContent(info0);
69       orderIdentifier++;
70     }
71     else
72       throw new SMIMEException(this, 1018);
73   }
74
75 /**
76  * Adds Encrypt Content Info.
77  * @param info0 Encrypt Content Info represented as byte array
78  * @exception SMIMEException if order of adding components is wrong. Also, it
79  * can be thrown from super class addContent method.
80  */

81   public void addEncryptContentInfo (byte[] info0) throws SMIMEException {
82     if (orderIdentifier == 3) {
83       super.addContent(info0);
84       orderIdentifier++;
85     }
86     else
87       throw new SMIMEException(this, 1018);
88   }
89 }
90
91
92
93
Popular Tags