KickJava   Java API By Example, From Geeks To Geeks.

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


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.DERSetPr;
13
14
15 /**
16  * DigestAlgorithmIdentifiers class is DER encoded set of Digest Algorithm
17  * Identifiers represented in ASN.1 notation according to RFC2630. This class is
18  * used in CMS objects for signed messages and represents container for all Digest
19  * Algorithm Identifiers (one or more) used in the process of signing.<BR>
20  * <BR>
21  * DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier<BR>
22  * <BR>
23  * <DL>
24  * DigestAlgorithmIdentifier ::= SEQUENCE {<BR>
25  * <DD> algorithm AlgorithmIdentifier,<BR>
26  * <DD> parameters ANY DEFINED BY algorithm OPTIONAL }<BR>
27  * </DL>
28  * <BR>
29  * AlgorithmIdentifier ::= OBJECT IDENTIFIER<BR>
30  */

31 public class DigestAlgorithmIdentifiers extends DERSetPr {
32
33 /**
34  * Construction of empty container for Digest Algorithm Identifiers
35  * @exception SMIMEException thrown from super class constructor.
36  */

37   public DigestAlgorithmIdentifiers () throws SMIMEException
38   {
39   }
40
41 /**
42  * Adds Digest Object Identifier to the instance of class
43  * DigestAlgorithmIdentifiers with no additional parameters. This method has two
44  * different forms, depend on parameter typeConstruction0, which can be:
45  * DOT_SEPARATED_ARRAY or NAME_STRING. If typeConstruction0 parameter is
46  * DOT_SEPARATED_ARRAY then id0 definition is represented by numbers separated
47  * with dots (example: "1.3.14.3.2.26"). In case of NAME_STRING id0 definition is
48  * name of object identifier (example: "SHA1").
49  * @param id0 defines Object Identifier in representation determined by second
50  * parameter - typeConstruction0.
51  * @param typeConstruction0 can take values DOT_SEPARATED_ARRAY and NAME_STRING
52  * @exception SMIMEException if wrong type of parameters are passed. Also, it
53  * can be thrown from super class addContent method.
54  */

55   public void addDigestAlgId (String JavaDoc id0, String JavaDoc typeConstruction0) throws SMIMEException {
56     AlgorithmIdentifier algID = new AlgorithmIdentifier(id0, typeConstruction0); // Finding apropriate identifier
57
super.addContent(algID.getDEREncoded()); // Adding identifier to DigestAlgorithmIdentifier
58
}
59
60 /**
61  * Adds Digest Object Identifier to the instance of class DigestAlgorithmIdentifiers
62  * with DER encoded null value for parameter. This method has two different
63  * forms, depend on parameter typeConstruction0, which can be: DOT_SEPARATED_ARRAY
64  * or NAME_STRING. If typeConstruction0 parameter is DOT_SEPARATED_ARRAY then id0
65  * definition is represented by numbers separated with dots (example: "1.3.14.3.2.26").
66  * In case of NAME_STRING id0 definition is name of object identifier (example:
67  * "SHA1").
68  * @param id0 defines Object Identifier in representation determined by second
69  * parameter - typeConstruction0.
70  * @param typeConstruction0 can take values DOT_SEPARATED_ARRAY and NAME_STRING
71  * @exception SMIMEException if wrong type of parameters are passed. Also, it
72  * can be thrown from super class addContent method.
73  */

74   public void addDigestAlgIdNullPar (String JavaDoc id0, String JavaDoc typeConstruction0) throws SMIMEException {
75     AlgorithmIdentifier algID = new AlgorithmIdentifier(id0, typeConstruction0); // Finding apropriate identifier
76
algID.addNullToAlgorithmId(); // Adding null parameter
77
super.addContent(algID.getDEREncoded()); // Adding identifier to DigestAlgorithmIdentifier
78
}
79
80 /**
81  * Adds Digest Object Identifier to the instance of class
82  * DigestAlgorithmIdentifiers with parameters represented as byte array. This
83  * method has two different forms, depend on parameter typeConstruction0, which
84  * can be: DOT_SEPARATED_ARRAY or NAME_STRING. If typeConstruction0 parameter is
85  * DOT_SEPARATED_ARRAY then id0 definition is represented by numbers separated
86  * with dots (example: "1.3.14.3.2.26"). In case of NAME_STRING id0 definition is
87  * name of object identifier (example: "SHA1").
88  * @param id0 defines Object Identifier in representation determined by second
89  * parameter - typeConstruction0.
90  * @param typeConstruction0 can take values DOT_SEPARATED_ARRAY and NAME_STRING
91  * @param algParam0 byte array representation of Digest Algorithm Identifier
92  * parameter
93  * @exception SMIMEException if wrong type of parameters are passed. Also, it
94  * can be thrown from super class addContent method.
95  */

96   public void addDigestAlgId (String JavaDoc id0, String JavaDoc typeConstruction0, byte[] algParam0) throws SMIMEException {
97     AlgorithmIdentifier algID = new AlgorithmIdentifier(id0, typeConstruction0); // Finding apropriate identifier
98
algID.addParamToAlgorithmId(algParam0); // If algorithm parameter have to be other than null
99
super.addContent(algID.getDEREncoded()); // Adding identifier to DigestAlgorithmIdentifier
100
}
101
102 /**
103  * Adds Digest Object Identifier to the instance of class
104  * DigestAlgorithmIdentifiers with no additional parameters. Array of numbers
105  * is Digest Algorithm Identifier which will be added. All numbers in the array
106  * represent one number between dots in object identifier string.
107  * @param arrayID0 array of given numbers (example: for SHA1 algorithm,
108  * numbers are 1, 3, 14, 3, 2 and 26).
109  * @exception SMIMEException if wrong type of parameters are passed. Also, it
110  * can be thrown from super class addContent method.
111  */

112   public void addDigestAlgId (int[] arrayID0) throws SMIMEException {
113     AlgorithmIdentifier algID = new AlgorithmIdentifier(arrayID0); // Finding apropriate identifier
114
super.addContent(algID.getDEREncoded()); // Adding identifier to DigestAlgorithmIdentifier
115
}
116
117 /**
118  * Adds Digest Object Identifier to the instance of class DigestAlgorithmIdentifiers
119  * with DER encoded null value for parameter. Array of numbers is
120  * Digest Algorithm Identifier which will be added. All numbers in the array
121  * represent one number between dots in object identifier string.
122  * @param arrayID0 array of given numbers (example: for SHA1 algorithm,
123  * numbers are 1, 3, 14, 3, 2 and 26).
124  * @exception SMIMEException if wrong type of parameters are passed. Also, it
125  * can be thrown from super class addContent method.
126  */

127   public void addDigestAlgIdNullPar (int[] arrayID0) throws SMIMEException {
128     AlgorithmIdentifier algID = new AlgorithmIdentifier(arrayID0); // Finding apropriate identifier
129
algID.addNullToAlgorithmId(); // Adding null parameter
130
super.addContent(algID.getDEREncoded()); // Adding identifier to DigestAlgorithmIdentifier
131
}
132
133 /**
134  * Adds Digest Object Identifier to the instance of class
135  * DigestAlgorithmIdentifiers with parameters represented as byte array. Array of
136  * numbers is used for construction of Digest Algorithm Identifier which will be
137  * added. All numbers in the array represent one number between dots in object
138  * identifier string.
139  * @param arrayID0 array of given numbers (example: for SHA1 algorithm,
140  * numbers are 1, 3, 14, 3, 2 and 26).
141  * @param algParam0 byte array representation of Digest Algorithm Identifier
142  * parameter
143  * @exception SMIMEException if wrong type of parameters are passed. Also, it
144  * can be thrown from super class addContent method.
145  */

146   public void addDigestAlgId (int[] arrayID0, byte[] algParam0) throws SMIMEException {
147     AlgorithmIdentifier algID = new AlgorithmIdentifier(arrayID0); // Finding apropriate identifier
148
algID.addParamToAlgorithmId(algParam0); // If algorithm parameter have to be other than null
149
super.addContent(algID.getDEREncoded()); // Adding identifier to DigestAlgorithmIdentifier
150
}
151 }
152
153
154
155
Popular Tags