KickJava   Java API By Example, From Geeks To Geeks.

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


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.DERObjectIdentifier;
13 import org.enhydra.oyster.der.DERSet;
14
15
16 /**
17  * Content Type Attribute is Signed Attribute and is used for creating CMS
18  * objects for signed messages. It defines type of content (message) used in CMS
19  * objects in information about particular signing.
20  */

21 public class ContentTypeAttribute extends Attribute {
22
23 /**
24  * This constructor has two different forms, depend on parameter typeConstruction0,
25  * which can be: DOT_SEPARATED_ARRAY or NAME_STRING. If typeConstruction0 parameter
26  * is DOT_SEPARATED_ARRAY then id0 definition is represented by numbers separated
27  * with dots (example: "1.2.840.113549.1.7.1"). In case of NAME_STRING, id0
28  * definition is name of object identifier for content attribute (example: "ID_DATA").
29  * @param id0 defines Object Identifier in representation determined by second
30  * parameter - typeConstruction0.
31  * @param typeConstruction0 can take values DOT_SEPARATED_ARRAY and NAME_STRING
32  * @exception SMIMEException if wrong type of parameters are passed to the
33  * constructor. Also, it can be thrown from super class constructor or its
34  * addContent method.
35  */

36   public ContentTypeAttribute (String JavaDoc id0, String JavaDoc typeConstruction0) throws SMIMEException
37   {
38     super("ID_CONTENTTYPE", "NAME_STRING");
39     DERObjectIdentifier temp = new DERObjectIdentifier(id0, typeConstruction0); // Finding apropriate identifier
40
DERSet contType = new DERSet();
41     contType.addContent(temp.getDEREncoded());
42     super.addContent(contType.getDEREncoded());
43   }
44
45 /**
46  * Array of numbers is used for construction of desired attribute DER Object
47  * Identifier. All numbers in array represent one number between dots in
48  * object identifier string.
49  * @param arrayID0 is array of defined numbers (example: for ID_DATA
50  * attributes, numbers are 1, 2, 840, 113549, 1, 7 and 1)
51  * @exception SMIMEException if wrong type of parameters are passed to the
52  * constructor. Also, it can be thrown from super class constructor or its
53  * addContent method.
54  */

55   public ContentTypeAttribute (int[] arrayID0) throws SMIMEException
56   {
57     super("ID_CONTENTTYPE", "NAME_STRING");
58     DERObjectIdentifier temp = new DERObjectIdentifier(arrayID0); // Finding apropriate identifier
59
DERSet contType = new DERSet();
60     contType.addContent(temp.getDEREncoded());
61     super.addContent(contType.getDEREncoded());
62   }
63 }
64
65
66
67
Popular Tags