KickJava   Java API By Example, From Geeks To Geeks.

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


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.DERClassContextSpecificPr;
13
14
15 /**
16  * SignedAttributes class is DER encoded container for holding particular signed
17  * attributes represented in ASN.1 notation according to RFC2630.<BR>
18  * <BR>
19  * signedAttrs [0] IMPLICIT SignedAttributes OPTIONAL<BR>
20  * <BR>
21  * SignedAttributes ::= SET SIZE (1..MAX) OF Attribute<BR>
22  * <BR>
23  * <DL>
24  * Attribute ::= SEQUENCE {<BR>
25  * <DD> attrType OBJECT IDENTIFIER,<BR>
26  * <DD> attrValues SET OF AttributeValue }<BR>
27  * </DL>
28  * <BR>
29  * attrType ::= OBJECT IDENTIFIER<BR>
30  * <BR>
31  * attrValues ::= SET OF AttributeValue<BR>
32  * <BR>
33  * AttributeValue ::= ANY<BR>
34  */

35 public class SignedAttributes extends DERClassContextSpecificPr {
36
37 /**
38  * Counter of added attributes.
39  */

40   private int attributeIndicator = 0;
41
42 /**
43  * Constructs structured DER encoded object with tag Class Context Specific
44  * @exception SMIMEException thrown in super class constructor.
45  */

46   public SignedAttributes () throws SMIMEException
47   {
48     super(0, true);
49   }
50
51 /**
52  * Adds DER encoded Signed attribute. This function must be performed one or
53  * more times.
54  * @param content0 DER encoded Signed attribute for adding
55  * @exception SMIMEException thrown in super class addContent method.
56  */

57   public void addSignedAttribute (byte[] content0) throws SMIMEException {
58     super.addContent(content0);
59     attributeIndicator++;
60   }
61
62 /**
63  * Returns DER encoded Signed attributes. At least one attribute must be added
64  * before performing this function.
65  * @return Container with all aded signed attributes
66  * @exception SMIMEException if no attribute was added. Also, exception
67  * could be thrown in super class getDEREncoded method.
68  */

69   public byte[] getSignedAttribute () throws SMIMEException {
70     if (attributeIndicator == 0)
71       throw new SMIMEException(this, 1025);
72     return super.getDEREncoded();
73   }
74 }
75
76
77
78
Popular Tags