01: /*
02: * Title: Oyster Project
03: * Description: S/MIME email sending capabilities
04: * @Author Vladimir Radisic
05: * @Version 2.1.6
06: */
07:
08: package org.enhydra.oyster.cms;
09:
10: import org.enhydra.oyster.exception.SMIMEException;
11: import org.enhydra.oyster.der.DERSequencePr;
12:
13: /**
14: * EnvelopedData is DER encoded container for information represented in
15: * ASN.1 notation according to RFC2630, used for construction CMS object
16: * of encrypted message.<BR>
17: * <BR>
18: * <DL>
19: * EnvelopedData ::= SEQUENCE {<BR>
20: * <DD> version CMSVersion,<BR>
21: * <DD> originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL,<BR>
22: * <DD> recipientInfos RecipientInfos,<BR>
23: * <DD> encryptedContentInfo EncryptedContentInfo,<BR>
24: * <DD> unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL }<BR>
25: * </DL>
26: */
27: public class EnvelopedData extends DERSequencePr {
28:
29: /**
30: * Determinate order of adding commponents
31: */
32: int orderIdentifier = 0;
33:
34: /**
35: * Constructs empty Enveloped Data.
36: * @exception SMIMEException thrown from super class constructor.
37: */
38: public EnvelopedData() throws SMIMEException {
39: }
40:
41: /**
42: * Adds CMS Version.
43: * @param ver0 CMS version represented as byte array
44: * @exception SMIMEException if order of adding components is wrong. Also, it
45: * can be thrown from super class addContent method.
46: */
47: public void addCMSVersion(byte[] ver0) throws SMIMEException {
48: if (orderIdentifier == 0) {
49: super .addContent(ver0);
50: orderIdentifier++;
51: orderIdentifier++;
52: } else
53: throw new SMIMEException(1018);
54: }
55:
56: /**
57: * Adds Recipient Infos.
58: * @param info0 Recipient Infos represented as byte array
59: * @exception SMIMEException if order of adding components is wrong. Also, it
60: * can be thrown from super class addContent method.
61: */
62: public void addRecipientInfos(byte[] info0) throws SMIMEException {
63: if (orderIdentifier == 2) {
64: super .addContent(info0);
65: orderIdentifier++;
66: } else
67: throw new SMIMEException(1018);
68: }
69:
70: /**
71: * Adds Encrypt Content Info.
72: * @param info0 Encrypt Content Info represented as byte array
73: * @exception SMIMEException if order of adding components is wrong. Also, it
74: * can be thrown from super class addContent method.
75: */
76: public void addEncryptContentInfo(byte[] info0)
77: throws SMIMEException {
78: if (orderIdentifier == 3) {
79: super .addContent(info0);
80: orderIdentifier++;
81: } else
82: throw new SMIMEException(1018);
83: }
84: }
|