KickJava   Java API By Example, From Geeks To Geeks.

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


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  * ContentInfo class is DER encoded content info represented in ASN.1 notation
17  * according to RFC2630. This class is top level class in construction of CMS
18  * objects (signed or encrypted)<BR>
19  * <BR>
20  * <DL>
21  * ContentInfo ::= SEQUENCE {<BR>
22  * <DD> contentType ContentType,<BR>
23  * <DD> content [0] EXPLICIT ANY DEFINED BY contentType }<BR>
24  * </DL>
25  * <BR>
26  * ContentType ::= OBJECT IDENTIFIER<BR>
27  * <BR>
28  * content [0]<BR>
29  */

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

35   int orderIdentifier = 0;
36
37 /**
38  * Constructs empty Content Info. Both methods addContentType and
39  * addContent must be performed after construction, for obtaining valid CMS
40  * object.
41  * @exception SMIMEException thrown from super class.
42  */

43   public ContentInfo () throws SMIMEException
44   {
45   }
46
47 /**
48  * Adds Content Type to Content Info
49  * @param type0 Content Type represented as byte array
50  * @exception SMIMEException if order of adding components is wrong. Also, it
51  * can be thrown from super class addContent method.
52  */

53   public void addContentType (byte[] type0) throws SMIMEException {
54     if (orderIdentifier == 0) {
55       super.addContent(type0);
56       orderIdentifier++;
57     }
58     else
59       throw new SMIMEException(this, 1018);
60   }
61
62 /**
63  * Adds content to Content Info
64  * @param cont0 Content represented as byte array
65  * @exception SMIMEException if order of adding components is wrong. Also, it
66  * can be thrown from super class addContent method.
67  */

68   public void addContent (byte[] cont0) throws SMIMEException {
69     if (orderIdentifier == 1) {
70       super.addContent(cont0);
71       orderIdentifier++;
72     }
73     else
74       throw new SMIMEException(this, 1018);
75   }
76 }
77
78
79
80
Popular Tags