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.DERClassContextSpecific;
14 import org.webdocwf.util.smime.der.DERSequencePr;
15 import org.webdocwf.util.smime.der.DEROctetString;
16
17
18 /***
19 * EncapsulatedContentInfo class is DER encoded content info represented in
20 * ASN.1 notation according to RFC2630. This class is used in CMS objects for
21 * signed messages. It contains message content in case of implicit signing.<BR>
22 * <BR>
23 * <DL>
24 * EncapsulatedContentInfo ::= SEQUENCE {<BR>
25 * <DD> eContentType ContentType, <BR>
26 * <DD> eContent [0] EXPLICIT OCTET STRING OPTIONAL }<BR>
27 * </DL>
28 * <BR>
29 * ContentType ::= OBJECT IDENTIFIER<BR>
30 */
31 public class EncapsulatedContentInfo extends DERSequencePr {
32
33 /***
34 * Determinate order of adding commponents.
35 */
36 int orderIdentifier = 0;
37
38 /***
39 * Constructs empty EncapsulatedContentInfo object.
40 * @exception SMIMEException thrown from super class constructor.
41 */
42 public EncapsulatedContentInfo() throws SMIMEException {}
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 } else
55 throw new SMIMEException(this, 1018);
56 }
57
58 /***
59 * Adds Encapsulated Content
60 * @param cont0 content represented as byte array
61 * @exception SMIMEException if order of adding components is wrong. Also, it
62 * can be thrown from super class addContent method.
63 */
64 public void addEncapsulatedContent(byte[] cont0) throws SMIMEException {
65 if (orderIdentifier == 1) {
66 DERClassContextSpecific eContent = new DERClassContextSpecific(0, true);
67
68 eContent.addContent(new DEROctetString(cont0).getDEREncoded());
69 super.addContent(eContent.getDEREncoded());
70 orderIdentifier++;
71 } else
72 throw new SMIMEException(this, 1018);
73 }
74 }
75
This page was automatically generated by Maven