KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > oyster > der > IdentifierStorage


1 /*
2  * Title: Oyster Project
3  * Description: S/MIME email sending capabilities
4  * @Author Vladimir Radisic
5  * @Version 2.1.5
6  */

7
8 package org.enhydra.oyster.der;
9
10 /**
11  * IdentifierStorage is used for storing different types of OID-s (Object
12  * Identifiers). OID-s are necessary for forming ASN.1 notation of SMIME
13  * structured data.
14  */

15 public class IdentifierStorage {
16   // Name Attributes
17
// id-at OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 4}
18
private static final int[] COMMONNAME = { 2, 5, 4, 3 };
19   private static final int[] SURNAME = { 2, 5, 4, 4 };
20   private static final int[] COUNTRYNAME = { 2, 5, 4, 6 };
21   private static final int[] LOCALITYNAME = { 2, 5, 4, 7 };
22   private static final int[] STATEORPROVINCENAME = { 2, 5, 4, 8 };
23   private static final int[] STREETADDRESS = { 2, 5, 4, 9 };
24   private static final int[] ORGANIZATIONNAME = { 2, 5, 4, 10 };
25   private static final int[] ORGANIZATIONALUNITNAME = { 2, 5, 4, 11 };
26   private static final int[] TITLE = { 2, 5, 4, 12 };
27   private static final int[] POSTALCODE = { 2, 5, 4, 17 };
28   private static final int[] PHONENUMBER = { 2, 5, 4, 20 };
29   private static final int[] NAME = { 2, 5, 4, 41 };
30   private static final int[] GIVENNAME = { 2, 5, 4, 42 };
31   private static final int[] INITIALS = { 2, 5, 4, 43 };
32   private static final int[] GENERATIONQUALIFIER = { 2, 5, 4, 44 };
33   private static final int[] DNQUALIFIER = { 2, 5, 4, 46 };
34   // Certificate Extensions
35
// id-ce OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29}
36
private static final int[] SUBJECTDIRECTORYATTRIBUTES = { 2, 5, 29, 9 };
37   private static final int[] SUBJECTKEYIDENTIFIER = { 2, 5, 29, 14 };
38   private static final int[] KEYUSAGE = { 2, 5, 29, 15 };
39   private static final int[] PRIVATEKEYUSAGEPERIOD = { 2, 5, 29, 16 };
40   private static final int[] SUBJECTALTNAME = { 2, 5, 29, 17 };
41   private static final int[] ISSUERALTNAME = { 2, 5, 29, 18 };
42   private static final int[] BASICCONSTRAINTS = { 2, 5, 29, 19 };
43   private static final int[] CRLNUMBER = { 2, 5, 29, 20 };
44   private static final int[] CRLREASON = { 2, 5, 29, 21 };
45   private static final int[] HOLDINSTRUCTIONCODE = { 2, 5, 29, 23 };
46   private static final int[] INVALIDITYDATE = { 2, 5, 29, 24 };
47   private static final int[] DELTACRLINDICATOR = { 2, 5, 29, 27 };
48   private static final int[] ISSUINGDISTRIBUTIONPOINT = { 2, 5, 29, 28 };
49   private static final int[] CERTIFICATEISSUER = { 2, 5, 29, 29 };
50   private static final int[] NAMECONSTRAINTS = { 2, 5, 29, 30 };
51   private static final int[] CRLDISTRIBUTIONPOINTS = { 2, 5, 29, 31 };
52   private static final int[] CERTIFICATEPOLICIES = { 2, 5, 29, 32 };
53   private static final int[] POLICYMAPPINGS = { 2, 5, 29, 33 };
54   private static final int[] AUTHORITYKEYIDENTIFIER = { 2, 5, 29, 35 };
55   private static final int[] POLICYCONSTRAINTS = { 2, 5, 29, 36 };
56   private static final int[] EXTKEYUSAGE = { 2, 5, 29, 37 };
57   // Legacy Attributes
58
private static final int[] EMAILADDRESS = { 1, 2, 840, 113549, 1, 9, 1 };
59   // Content Type Object Identifiers
60
private static final int[] ID_CONTENTINFO = { 1, 2, 840, 113549, 1, 9, 16, 1, 6 };
61   private static final int[] ID_DATA = { 1, 2, 840, 113549, 1, 7, 1 };
62   private static final int[] ID_SIGNEDDATA = { 1, 2, 840, 113549, 1, 7, 2 };
63   private static final int[] ID_ENVELOPEDDATA = { 1, 2, 840, 113549, 1, 7, 3 };
64   private static final int[] ID_SIGNEDANDENVELOPEDDATA = { 1, 2, 840, 113549, 1, 7, 4 };
65   private static final int[] ID_DIGESTEDDATA = { 1, 2, 840, 113549, 1, 7, 5 };
66   private static final int[] ID_ENCRYPTEDDATA = { 1, 2, 840, 113549, 1, 7, 6 };
67   private static final int[] ID_AUTHDATA = { 1, 2, 840, 113549, 1, 9, 16, 1, 2 };
68   // Attribute Object Identifiers
69
private static final int[] ID_CONTENTTYPE = { 1, 2, 840, 113549, 1, 9, 3 };
70   private static final int[] ID_MESSAGEDIGEST = { 1, 2, 840, 113549, 1, 9, 4 };
71   private static final int[] ID_SIGNINGTIME = { 1, 2, 840, 113549, 1, 9, 5 };
72   private static final int[] ID_SMIMECAPABILITIES = { 1, 2, 840, 113549, 1, 9, 15 };
73   private static final int[] ID_COUNTERSIGNATURE = { 1, 2, 840, 113549, 1, 9, 6 };
74   // Algorithm Identifiers
75
private static final int[] SHA1 = { 1, 3, 14, 3, 2, 26 };
76   private static final int[] MD2 = { 1, 2, 840, 113549, 2, 2 };
77   private static final int[] MD5 = { 1, 2, 840, 113549, 2, 5 };
78   private static final int[] MD2_WITH_RSA = { 1, 2, 840, 113549, 1, 1, 2 };
79   private static final int[] MD5_WITH_RSA = { 1, 2, 840, 113549, 1, 1, 4 };
80   private static final int[] SHA1_WITH_RSA = { 1, 2, 840, 113549, 1, 1, 5 };
81   private static final int[] SHA1_WITH_DSA = { 1, 2, 840, 10040, 4, 3 };
82   private static final int[] RSA = { 1, 2, 840, 113549, 1, 1, 1 };
83   private static final int[] DSA = { 1, 2, 840, 10040, 4, 1 };
84   private static final int[] DH_PUBLIC_NUMBER = { 1, 2, 840, 10046, 2, 1 };
85   private static final int[] ESDH = { 1, 2, 840, 113549, 1, 9, 16, 3, 5 };
86   private static final int[] CMS3DESWRAP = { 1, 2, 840, 113549, 1, 9, 16, 3, 6 };
87   private static final int[] CMSRC2WRAP = { 1, 2, 840, 113549, 1, 9, 16, 3, 7 };
88   private static final int[] HMAC_SHA1 = { 1, 3, 6, 1, 5, 5, 8, 1, 2 };
89   private static final int[] DES_EDE3_CBC = { 1, 2, 840, 113549, 3, 7 };
90   private static final int[] RC2_CBC = { 1, 2, 840, 113549, 3, 2 };
91   private static final int[] DES = { 1, 3, 14, 3, 2, 7 };
92
93 /**
94  * Returns OID-s as int array which corresponds to the defined name
95  * necessary for forming ASN.1 notation of Object Identifiers.
96  * @param s0 name of desired OID-s (Object Identifiers)
97  * @return OID-s (in the case of error returns -1)
98  */

99   public static int[] getID (String JavaDoc s0) {
100     if (s0.equalsIgnoreCase("COMMONNAME"))
101       return COMMONNAME;
102     else if (s0.equalsIgnoreCase("SURNAME"))
103       return SURNAME;
104     else if (s0.equalsIgnoreCase("COUNTRYNAME"))
105       return COUNTRYNAME;
106     else if (s0.equalsIgnoreCase("LOCALITYNAME"))
107       return LOCALITYNAME;
108     else if (s0.equalsIgnoreCase("STATEORPROVINCENAME"))
109       return STATEORPROVINCENAME;
110     else if (s0.equalsIgnoreCase("STREETADDRESS"))
111       return STREETADDRESS;
112     else if (s0.equalsIgnoreCase("ORGANIZATIONNAME"))
113       return ORGANIZATIONNAME;
114     else if (s0.equalsIgnoreCase("ORGANIZATIONALUNITNAME"))
115       return ORGANIZATIONALUNITNAME;
116     else if (s0.equalsIgnoreCase("TITLE"))
117       return TITLE;
118     else if (s0.equalsIgnoreCase("POSTALCODE"))
119       return POSTALCODE;
120     else if (s0.equalsIgnoreCase("POSTALCODE"))
121       return POSTALCODE;
122     else if (s0.equalsIgnoreCase("NAME"))
123       return NAME;
124     else if (s0.equalsIgnoreCase("GIVENNAME"))
125       return GIVENNAME;
126     else if (s0.equalsIgnoreCase("INITIALS"))
127       return INITIALS;
128     else if (s0.equalsIgnoreCase("GENERATIONQUALIFIER"))
129       return GENERATIONQUALIFIER;
130     else if (s0.equalsIgnoreCase("DNQUALIFIER"))
131       return DNQUALIFIER;
132     //--------------------------------------------------------------------------
133
else if (s0.equalsIgnoreCase("SUBJECTDIRECTORYATTRIBUTES"))
134       return SUBJECTDIRECTORYATTRIBUTES;
135     else if (s0.equalsIgnoreCase("SUBJECTKEYIDENTIFIER"))
136       return SUBJECTKEYIDENTIFIER;
137     else if (s0.equalsIgnoreCase("KEYUSAGE"))
138       return KEYUSAGE;
139     else if (s0.equalsIgnoreCase("PRIVATEKEYUSAGEPERIOD"))
140       return PRIVATEKEYUSAGEPERIOD;
141     else if (s0.equalsIgnoreCase("SUBJECTALTNAME"))
142       return SUBJECTALTNAME;
143     else if (s0.equalsIgnoreCase("ISSUERALTNAME"))
144       return ISSUERALTNAME;
145     else if (s0.equalsIgnoreCase("BASICCONSTRAINTS"))
146       return BASICCONSTRAINTS;
147     else if (s0.equalsIgnoreCase("CRLNUMBER"))
148       return CRLNUMBER;
149     else if (s0.equalsIgnoreCase("CRLREASON"))
150       return CRLREASON;
151     else if (s0.equalsIgnoreCase("HOLDINSTRUCTIONCODE"))
152       return HOLDINSTRUCTIONCODE;
153     else if (s0.equalsIgnoreCase("INVALIDITYDATE"))
154       return INVALIDITYDATE;
155     else if (s0.equalsIgnoreCase("DELTACRLINDICATOR"))
156       return DELTACRLINDICATOR;
157     else if (s0.equalsIgnoreCase("ISSUINGDISTRIBUTIONPOINT"))
158       return ISSUINGDISTRIBUTIONPOINT;
159     else if (s0.equalsIgnoreCase("CERTIFICATEISSUER"))
160       return CERTIFICATEISSUER;
161     else if (s0.equalsIgnoreCase("NAMECONSTRAINTS"))
162       return NAMECONSTRAINTS;
163     else if (s0.equalsIgnoreCase("CRLDISTRIBUTIONPOINTS"))
164       return CRLDISTRIBUTIONPOINTS;
165     else if (s0.equalsIgnoreCase("CERTIFICATEPOLICIES"))
166       return CERTIFICATEPOLICIES;
167     else if (s0.equalsIgnoreCase("POLICYMAPPINGS"))
168       return POLICYMAPPINGS;
169     else if (s0.equalsIgnoreCase("AUTHORITYKEYIDENTIFIER"))
170       return AUTHORITYKEYIDENTIFIER;
171     else if (s0.equalsIgnoreCase("POLICYCONSTRAINTS"))
172       return POLICYCONSTRAINTS;
173     else if (s0.equalsIgnoreCase("EXTKEYUSAGE"))
174       return EXTKEYUSAGE;
175     //--------------------------------------------------------------------------
176
else if (s0.equalsIgnoreCase("EMAILADDRESS"))
177       return EMAILADDRESS;
178     //--------------------------------------------------------------------------
179
else if (s0.equalsIgnoreCase("ID_CONTENTINFO"))
180       return ID_CONTENTINFO;
181     else if (s0.equalsIgnoreCase("ID_DATA"))
182       return ID_DATA;
183     else if (s0.equalsIgnoreCase("ID_SIGNEDDATA"))
184       return ID_SIGNEDDATA;
185     else if (s0.equalsIgnoreCase("ID_ENVELOPEDDATA"))
186       return ID_ENVELOPEDDATA;
187     else if (s0.equalsIgnoreCase("ID_SIGNEDANDENVELOPEDDATA"))
188       return ID_SIGNEDANDENVELOPEDDATA;
189     else if (s0.equalsIgnoreCase("ID_DIGESTEDDATA"))
190       return ID_DIGESTEDDATA;
191     else if (s0.equalsIgnoreCase("ID_ENCRYPTEDDATA"))
192       return ID_ENCRYPTEDDATA;
193     else if (s0.equalsIgnoreCase("ID_AUTHDATA"))
194       return ID_AUTHDATA;
195     //--------------------------------------------------------------------------
196
else if (s0.equalsIgnoreCase("ID_CONTENTTYPE"))
197       return ID_CONTENTTYPE;
198     else if (s0.equalsIgnoreCase("ID_MESSAGEDIGEST"))
199       return ID_MESSAGEDIGEST;
200     else if (s0.equalsIgnoreCase("ID_SIGNINGTIME"))
201       return ID_SIGNINGTIME;
202     else if (s0.equalsIgnoreCase("ID_SMIMECAPABILITIES"))
203       return ID_SMIMECAPABILITIES;
204     else if (s0.equalsIgnoreCase("ID_COUNTERSIGNATURE"))
205       return ID_COUNTERSIGNATURE;
206     //--------------------------------------------------------------------------
207
else if (s0.equalsIgnoreCase("SHA1"))
208       return SHA1;
209     else if (s0.equalsIgnoreCase("MD2"))
210       return MD2;
211     else if (s0.equalsIgnoreCase("MD5"))
212       return MD5;
213     else if (s0.equalsIgnoreCase("MD2_WITH_RSA"))
214       return MD2_WITH_RSA;
215     else if (s0.equalsIgnoreCase("MD5_WITH_RSA"))
216       return MD5_WITH_RSA;
217     else if (s0.equalsIgnoreCase("SHA1_WITH_RSA"))
218       return SHA1_WITH_RSA;
219     else if (s0.equalsIgnoreCase("SHA1_WITH_DSA"))
220       return SHA1_WITH_DSA;
221     else if (s0.equalsIgnoreCase("RSA"))
222       return RSA;
223     else if (s0.equalsIgnoreCase("DSA"))
224       return DSA;
225     else if (s0.equalsIgnoreCase("DH_PUBLIC_NUMBER"))
226       return DH_PUBLIC_NUMBER;
227     else if (s0.equalsIgnoreCase("ESDH"))
228       return ESDH;
229     else if (s0.equalsIgnoreCase("CMS3DESWRAP"))
230       return CMS3DESWRAP;
231     else if (s0.equalsIgnoreCase("CMSRC2WRAP"))
232       return CMSRC2WRAP;
233     else if (s0.equalsIgnoreCase("HMAC_SHA1"))
234       return HMAC_SHA1;
235     else if (s0.equalsIgnoreCase("DES_EDE3_CBC"))
236       return DES_EDE3_CBC;
237     else if (s0.equalsIgnoreCase("RC2_CBC"))
238       return RC2_CBC;
239     else if (s0.equalsIgnoreCase("DES"))
240       return DES;
241     else {
242       int[] failure = { -1 };
243       return failure;
244     }
245   }
246 }
247
248
249
250
Popular Tags