KickJava   Java API By Example, From Geeks To Geeks.

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


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.DERSequencePr;
13 import org.enhydra.oyster.der.DERObjectIdentifier;
14 import org.enhydra.oyster.der.DERNull;
15
16
17 /**
18  * AlgorithmIdentifier class is DER encoded Algorithm identifier represented in ASN.1
19  * notation according to RFC2630.<BR>
20  * <BR>
21  * <DL>
22  * AlgorithmIdentifier ::= SEQUENCE {<BR>
23  * <DD> algorithm AlgorithmIdentifier,<BR>
24  * <DD> parameters ANY DEFINED BY algorithm OPTIONAL }<BR>
25  * </DL>
26  * <BR>
27  * AlgorithmIdentifier ::= OBJECT IDENTIFIER<BR>
28  */

29 public class AlgorithmIdentifier extends DERSequencePr {
30
31 /**
32  * This constructor has two different forms, depend on parameter typeConstruction0,
33  * which can be: DOT_SEPARATED_ARRAY or NAME_STRING. If typeConstruction0 parameter
34  * is DOT_SEPARATED_ARRAY then id0 definition is represented by numbers separated
35  * with dots (example: "1.2.840.113549.1.1.1"). In case of NAME_STRING, id0
36  * definition is name of object identifier (example: "RSA").
37  * @param id0 defines Object Identifier in representation determined by second
38  * parameter - typeConstruction0.
39  * @param typeConstruction0 can take values DOT_SEPARATED_ARRAY and NAME_STRING
40  * @exception SMIMEException if wrong type of parameters are passed to the
41  * constructor. Also, it can be thrown from super class constructor or its
42  * addContent method.
43  */

44   public AlgorithmIdentifier (String JavaDoc id0, String JavaDoc typeConstruction0) throws SMIMEException
45   {
46     DERObjectIdentifier temp = new DERObjectIdentifier(id0, typeConstruction0); // Finding apropriate identifier
47
super.addContent(temp.getDEREncoded()); // Adding identifier to AlgorithmIdentifier
48
}
49
50 /**
51  * Array of numbers is used for construction of DERObjectIdentifier. Every number in
52  * array represents one number between dots in object identifier string.
53  * @param arrayID0 array of defined numbers (example: for RSA algoriths, numbers
54  * are 1, 2, 840, 113549, 1, 1, and 1)
55  * @exception SMIMEException if wrong type of parameters are passed to the
56  * constructor. Also, it can be thrown from super class constructor or its
57  * addContent method.
58  */

59   public AlgorithmIdentifier (int[] arrayID0) throws SMIMEException
60   {
61     DERObjectIdentifier temp = new DERObjectIdentifier(arrayID0); // Finding apropriate identifier
62
super.addContent(temp.getDEREncoded()); // Adding identifier to AlgorithmIdentifier
63
}
64
65 /**
66  * Adds DERNull parameter to AlgorithmIdentifier
67  * @exception SMIMEException thrown from super class addContent method.
68  */

69   public void addNullToAlgorithmId () throws SMIMEException {
70     super.addContent(new DERNull().getDEREncoded());
71   }
72
73 /**
74  * Adds parameter to AlgorithmIdentifier
75  * @param parameter0 byte array representation of appropriate parameter
76  * @exception SMIMEException thrown from super class addContent method.
77  */

78   public void addParamToAlgorithmId (byte[] parameter0) throws SMIMEException {
79     super.addContent(parameter0);
80   }
81 }
82
83
84
85
Popular Tags