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.DERSequencePr;
14
15
16 /***
17 * SignedData is DER encoded container for information represented in
18 * ASN.1 notation according to RFC2630, used for construction CMS objects
19 * of signed messages.<BR>
20 * <BR>
21 * <DL>
22 * SignedData ::= SEQUENCE {<BR>
23 * <DD> version CMSVersion,<BR>
24 * <DD> digestAlgorithms DigestAlgorithmIdentifiers,<BR>
25 * <DD> encapContentInfo EncapsulatedContentInfo,<BR>
26 * <DD> certificates [0] IMPLICIT CertificateSet OPTIONAL,<BR>
27 * <DD> crls [1] IMPLICIT CertificateRevocationLists OPTIONAL,<BR>
28 * <DD> signerInfos SignerInfos }<BR>
29 * </DL>
30 */
31 public class SignedData extends DERSequencePr {
32
33 /***
34 * Determinate order of adding commponents
35 */
36 int orderIdentifier = 0;
37
38 /***
39 * Constructs an empty Signed Data
40 * @exception SMIMEException thrown in super class constructor.
41 */
42 public SignedData() throws SMIMEException {}
43
44 /***
45 * Adds DER encoded CMS Version
46 * @param ver0 DER encoded CMS version represented as byte array
47 * @exception SMIMEException if order of adding components is wrong. Also,
48 * exception could be thrown in super class addContent method.
49 */
50 public void addCMSVersion(byte[] ver0) throws SMIMEException {
51 if (orderIdentifier == 0) {
52 super.addContent(ver0);
53 orderIdentifier++;
54 } else
55 throw new SMIMEException(this, 1018);
56 }
57
58 /***
59 * Adds DER encoded Digest Algorithm Identifier
60 * @param digAlg0 DER encoded Digest Algorithm Identifier as byte array
61 * @exception SMIMEException if order of adding components is wrong. Also,
62 * exception could be thrown in super class addContent method.
63 */
64 public void addDigestAlgorithm(byte[] digAlg0) throws SMIMEException {
65 if (orderIdentifier == 1) {
66 super.addContent(digAlg0);
67 orderIdentifier++;
68 } else
69 throw new SMIMEException(this, 1018);
70 }
71
72 /***
73 * Adds DER encoded Encapsulated Content Info
74 * @param encCont0 DER encoded Encapsulated Content Info as byte array
75 * @exception SMIMEException if order of adding components is wrong. Also,
76 * exception could be thrown in super class addContent method.
77 */
78 public void addEncapsulatedContentInfo(byte[] encCont0) throws SMIMEException {
79 if (orderIdentifier == 2) {
80 super.addContent(encCont0);
81 orderIdentifier++;
82 } else
83 throw new SMIMEException(this, 1018);
84 }
85
86 /***
87 * Adds DER encoded Certificate container with one or more X509 certificates
88 * @param cert0 DER encoded Certificate container
89 * @exception SMIMEException if order of adding components is wrong. Also,
90 * exception could be thrown in super class addContent method.
91 */
92 public void addCertificate(byte[] cert0) throws SMIMEException {
93 if (orderIdentifier == 3) {
94 super.addContent(cert0);
95 orderIdentifier++;
96 } else
97 throw new SMIMEException(this, 1018);
98 }
99
100 /***
101 * Adds DER encoded Signer Infos
102 * @param info0 DER encoded Signer Infos
103 * @exception SMIMEException if order of adding components is wrong. Also,
104 * exception could be thrown in super class addContent method.
105 */
106 public void addSignerInfos(byte[] info0) throws SMIMEException {
107 if (orderIdentifier == 3) {
108 super.addContent(info0);
109 orderIdentifier++;
110 orderIdentifier++;
111 } else if (orderIdentifier == 4) {
112 super.addContent(info0);
113 orderIdentifier++;
114 } else
115 throw new SMIMEException(this, 1018);
116 }
117 }
118
This page was automatically generated by Maven