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.DERObjectIdentifier;
14 import org.webdocwf.util.smime.der.DERSet;
15
16
17 /***
18 * Content Type Attribute is Signed Attribute and is used for creating CMS
19 * objects for signed messages. It defines type of content (message) used in CMS
20 * objects in information about particular signing.
21 */
22 public class ContentTypeAttribute extends Attribute {
23
24 /***
25 * This constructor has two different forms, depend on parameter typeConstruction0,
26 * which can be: DOT_SEPARATED_ARRAY or NAME_STRING. If typeConstruction0 parameter
27 * is DOT_SEPARATED_ARRAY then id0 definition is represented by numbers separated
28 * with dots (example: "1.2.840.113549.1.7.1"). In case of NAME_STRING, id0
29 * definition is name of object identifier for content attribute (example: "ID_DATA").
30 * @param id0 defines Object Identifier in representation determined by second
31 * parameter - typeConstruction0.
32 * @param typeOfAttribute0 can take values DOT_SEPARATED_ARRAY and NAME_STRING
33 * @exception SMIMEException if wrong type of parameters are passed to the
34 * constructor. Also, it can be thrown from super class constructor or its
35 * addContent method.
36 */
37 public ContentTypeAttribute(String id0, String typeConstruction0) throws SMIMEException {
38 super("ID_CONTENTTYPE", "NAME_STRING");
39 DERObjectIdentifier temp = new DERObjectIdentifier(id0, typeConstruction0); // Finding apropriate identifier
40 DERSet contType = new DERSet();
41
42 contType.addContent(temp.getDEREncoded());
43 super.addContent(contType.getDEREncoded());
44 }
45
46 /***
47 * Array of numbers is used for construction of desired attribute DER Object
48 * Identifier. All numbers in array represent one number between dots in
49 * object identifier string.
50 * @param arrayID0 is array of defined numbers (example: for ID_DATA
51 * attributes, numbers are 1, 2, 840, 113549, 1, 7 and 1)
52 * @exception SMIMEException if wrong type of parameters are passed to the
53 * constructor. Also, it can be thrown from super class constructor or its
54 * addContent method.
55 */
56 public ContentTypeAttribute(int[] arrayID0) throws SMIMEException {
57 super("ID_CONTENTTYPE", "NAME_STRING");
58 DERObjectIdentifier temp = new DERObjectIdentifier(arrayID0); // Finding apropriate identifier
59 DERSet contType = new DERSet();
60
61 contType.addContent(temp.getDEREncoded());
62 super.addContent(contType.getDEREncoded());
63 }
64 }
65
This page was automatically generated by Maven