KickJava   Java API By Example, From Geeks To Geeks.

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


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.DERClassContextSpecific;
13 import org.enhydra.oyster.der.DERSequencePr;
14 import org.enhydra.oyster.der.DEROctetString;
15
16 /**
17  * EncapsulatedContentInfo class is DER encoded content info represented in
18  * ASN.1 notation according to RFC2630. This class is used in CMS objects for
19  * signed messages. It contains message content in case of implicit signing.<BR>
20  * <BR>
21  * <DL>
22  * EncapsulatedContentInfo ::= SEQUENCE {<BR>
23  * <DD> eContentType ContentType, <BR>
24  * <DD> eContent [0] EXPLICIT OCTET STRING OPTIONAL }<BR>
25  * </DL>
26  * <BR>
27  * ContentType ::= OBJECT IDENTIFIER<BR>
28  */

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

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

40   public EncapsulatedContentInfo () throws SMIMEException
41   {
42   }
43
44 /**
45  * Adds Content Type
46  * @param contType0 content type 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 addContentType (byte[] contType0) throws SMIMEException {
51     if (orderIdentifier == 0) {
52       super.addContent(contType0);
53       orderIdentifier++;
54     }
55     else
56       throw new SMIMEException(this, 1018);
57   }
58
59 /**
60  * Adds Encapsulated Content
61  * @param cont0 content represented as byte array
62  * @exception SMIMEException if order of adding components is wrong. Also, it
63  * can be thrown from super class addContent method.
64  */

65   public void addEncapsulatedContent (byte[] cont0) throws SMIMEException {
66     if (orderIdentifier == 1) {
67       DERClassContextSpecific eContent = new DERClassContextSpecific(0, true);
68       eContent.addContent(new DEROctetString(cont0).getDEREncoded());
69       super.addContent(eContent.getDEREncoded());
70       orderIdentifier++;
71     }
72     else
73       throw new SMIMEException(this, 1018);
74   }
75 }
76
77
78
79
Popular Tags