001: /*
002: * Title: Oyster Project
003: * Description: S/MIME email sending capabilities
004: * @Author Vladimir Radisic
005: * @Version 2.1.5
006: */
007:
008: package org.enhydra.oyster.der;
009:
010: /**
011: * IdentifierStorage is used for storing different types of OID-s (Object
012: * Identifiers). OID-s are necessary for forming ASN.1 notation of SMIME
013: * structured data.
014: */
015: public class IdentifierStorage {
016: // Name Attributes
017: // id-at OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 4}
018: private static final int[] COMMONNAME = { 2, 5, 4, 3 };
019: private static final int[] SURNAME = { 2, 5, 4, 4 };
020: private static final int[] COUNTRYNAME = { 2, 5, 4, 6 };
021: private static final int[] LOCALITYNAME = { 2, 5, 4, 7 };
022: private static final int[] STATEORPROVINCENAME = { 2, 5, 4, 8 };
023: private static final int[] STREETADDRESS = { 2, 5, 4, 9 };
024: private static final int[] ORGANIZATIONNAME = { 2, 5, 4, 10 };
025: private static final int[] ORGANIZATIONALUNITNAME = { 2, 5, 4, 11 };
026: private static final int[] TITLE = { 2, 5, 4, 12 };
027: private static final int[] POSTALCODE = { 2, 5, 4, 17 };
028: private static final int[] PHONENUMBER = { 2, 5, 4, 20 };
029: private static final int[] NAME = { 2, 5, 4, 41 };
030: private static final int[] GIVENNAME = { 2, 5, 4, 42 };
031: private static final int[] INITIALS = { 2, 5, 4, 43 };
032: private static final int[] GENERATIONQUALIFIER = { 2, 5, 4, 44 };
033: private static final int[] DNQUALIFIER = { 2, 5, 4, 46 };
034: // Certificate Extensions
035: // id-ce OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29}
036: private static final int[] SUBJECTDIRECTORYATTRIBUTES = { 2, 5, 29,
037: 9 };
038: private static final int[] SUBJECTKEYIDENTIFIER = { 2, 5, 29, 14 };
039: private static final int[] KEYUSAGE = { 2, 5, 29, 15 };
040: private static final int[] PRIVATEKEYUSAGEPERIOD = { 2, 5, 29, 16 };
041: private static final int[] SUBJECTALTNAME = { 2, 5, 29, 17 };
042: private static final int[] ISSUERALTNAME = { 2, 5, 29, 18 };
043: private static final int[] BASICCONSTRAINTS = { 2, 5, 29, 19 };
044: private static final int[] CRLNUMBER = { 2, 5, 29, 20 };
045: private static final int[] CRLREASON = { 2, 5, 29, 21 };
046: private static final int[] HOLDINSTRUCTIONCODE = { 2, 5, 29, 23 };
047: private static final int[] INVALIDITYDATE = { 2, 5, 29, 24 };
048: private static final int[] DELTACRLINDICATOR = { 2, 5, 29, 27 };
049: private static final int[] ISSUINGDISTRIBUTIONPOINT = { 2, 5, 29,
050: 28 };
051: private static final int[] CERTIFICATEISSUER = { 2, 5, 29, 29 };
052: private static final int[] NAMECONSTRAINTS = { 2, 5, 29, 30 };
053: private static final int[] CRLDISTRIBUTIONPOINTS = { 2, 5, 29, 31 };
054: private static final int[] CERTIFICATEPOLICIES = { 2, 5, 29, 32 };
055: private static final int[] POLICYMAPPINGS = { 2, 5, 29, 33 };
056: private static final int[] AUTHORITYKEYIDENTIFIER = { 2, 5, 29, 35 };
057: private static final int[] POLICYCONSTRAINTS = { 2, 5, 29, 36 };
058: private static final int[] EXTKEYUSAGE = { 2, 5, 29, 37 };
059: // Legacy Attributes
060: private static final int[] EMAILADDRESS = { 1, 2, 840, 113549, 1,
061: 9, 1 };
062: // Content Type Object Identifiers
063: private static final int[] ID_CONTENTINFO = { 1, 2, 840, 113549, 1,
064: 9, 16, 1, 6 };
065: private static final int[] ID_DATA = { 1, 2, 840, 113549, 1, 7, 1 };
066: private static final int[] ID_SIGNEDDATA = { 1, 2, 840, 113549, 1,
067: 7, 2 };
068: private static final int[] ID_ENVELOPEDDATA = { 1, 2, 840, 113549,
069: 1, 7, 3 };
070: private static final int[] ID_SIGNEDANDENVELOPEDDATA = { 1, 2, 840,
071: 113549, 1, 7, 4 };
072: private static final int[] ID_DIGESTEDDATA = { 1, 2, 840, 113549,
073: 1, 7, 5 };
074: private static final int[] ID_ENCRYPTEDDATA = { 1, 2, 840, 113549,
075: 1, 7, 6 };
076: private static final int[] ID_AUTHDATA = { 1, 2, 840, 113549, 1, 9,
077: 16, 1, 2 };
078: // Attribute Object Identifiers
079: private static final int[] ID_CONTENTTYPE = { 1, 2, 840, 113549, 1,
080: 9, 3 };
081: private static final int[] ID_MESSAGEDIGEST = { 1, 2, 840, 113549,
082: 1, 9, 4 };
083: private static final int[] ID_SIGNINGTIME = { 1, 2, 840, 113549, 1,
084: 9, 5 };
085: private static final int[] ID_SMIMECAPABILITIES = { 1, 2, 840,
086: 113549, 1, 9, 15 };
087: private static final int[] ID_COUNTERSIGNATURE = { 1, 2, 840,
088: 113549, 1, 9, 6 };
089: // Algorithm Identifiers
090: private static final int[] SHA1 = { 1, 3, 14, 3, 2, 26 };
091: private static final int[] MD2 = { 1, 2, 840, 113549, 2, 2 };
092: private static final int[] MD5 = { 1, 2, 840, 113549, 2, 5 };
093: private static final int[] MD2_WITH_RSA = { 1, 2, 840, 113549, 1,
094: 1, 2 };
095: private static final int[] MD5_WITH_RSA = { 1, 2, 840, 113549, 1,
096: 1, 4 };
097: private static final int[] SHA1_WITH_RSA = { 1, 2, 840, 113549, 1,
098: 1, 5 };
099: private static final int[] SHA1_WITH_DSA = { 1, 2, 840, 10040, 4, 3 };
100: private static final int[] RSA = { 1, 2, 840, 113549, 1, 1, 1 };
101: private static final int[] DSA = { 1, 2, 840, 10040, 4, 1 };
102: private static final int[] DH_PUBLIC_NUMBER = { 1, 2, 840, 10046,
103: 2, 1 };
104: private static final int[] ESDH = { 1, 2, 840, 113549, 1, 9, 16, 3,
105: 5 };
106: private static final int[] CMS3DESWRAP = { 1, 2, 840, 113549, 1, 9,
107: 16, 3, 6 };
108: private static final int[] CMSRC2WRAP = { 1, 2, 840, 113549, 1, 9,
109: 16, 3, 7 };
110: private static final int[] HMAC_SHA1 = { 1, 3, 6, 1, 5, 5, 8, 1, 2 };
111: private static final int[] DES_EDE3_CBC = { 1, 2, 840, 113549, 3, 7 };
112: private static final int[] RC2_CBC = { 1, 2, 840, 113549, 3, 2 };
113: private static final int[] DES = { 1, 3, 14, 3, 2, 7 };
114:
115: /**
116: * Returns OID-s as int array which corresponds to the defined name
117: * necessary for forming ASN.1 notation of Object Identifiers.
118: * @param s0 name of desired OID-s (Object Identifiers)
119: * @return OID-s (in the case of error returns -1)
120: */
121: public static int[] getID(String s0) {
122: if (s0.equalsIgnoreCase("COMMONNAME"))
123: return COMMONNAME;
124: else if (s0.equalsIgnoreCase("SURNAME"))
125: return SURNAME;
126: else if (s0.equalsIgnoreCase("COUNTRYNAME"))
127: return COUNTRYNAME;
128: else if (s0.equalsIgnoreCase("LOCALITYNAME"))
129: return LOCALITYNAME;
130: else if (s0.equalsIgnoreCase("STATEORPROVINCENAME"))
131: return STATEORPROVINCENAME;
132: else if (s0.equalsIgnoreCase("STREETADDRESS"))
133: return STREETADDRESS;
134: else if (s0.equalsIgnoreCase("ORGANIZATIONNAME"))
135: return ORGANIZATIONNAME;
136: else if (s0.equalsIgnoreCase("ORGANIZATIONALUNITNAME"))
137: return ORGANIZATIONALUNITNAME;
138: else if (s0.equalsIgnoreCase("TITLE"))
139: return TITLE;
140: else if (s0.equalsIgnoreCase("POSTALCODE"))
141: return POSTALCODE;
142: else if (s0.equalsIgnoreCase("POSTALCODE"))
143: return POSTALCODE;
144: else if (s0.equalsIgnoreCase("NAME"))
145: return NAME;
146: else if (s0.equalsIgnoreCase("GIVENNAME"))
147: return GIVENNAME;
148: else if (s0.equalsIgnoreCase("INITIALS"))
149: return INITIALS;
150: else if (s0.equalsIgnoreCase("GENERATIONQUALIFIER"))
151: return GENERATIONQUALIFIER;
152: else if (s0.equalsIgnoreCase("DNQUALIFIER"))
153: return DNQUALIFIER;
154: //--------------------------------------------------------------------------
155: else if (s0.equalsIgnoreCase("SUBJECTDIRECTORYATTRIBUTES"))
156: return SUBJECTDIRECTORYATTRIBUTES;
157: else if (s0.equalsIgnoreCase("SUBJECTKEYIDENTIFIER"))
158: return SUBJECTKEYIDENTIFIER;
159: else if (s0.equalsIgnoreCase("KEYUSAGE"))
160: return KEYUSAGE;
161: else if (s0.equalsIgnoreCase("PRIVATEKEYUSAGEPERIOD"))
162: return PRIVATEKEYUSAGEPERIOD;
163: else if (s0.equalsIgnoreCase("SUBJECTALTNAME"))
164: return SUBJECTALTNAME;
165: else if (s0.equalsIgnoreCase("ISSUERALTNAME"))
166: return ISSUERALTNAME;
167: else if (s0.equalsIgnoreCase("BASICCONSTRAINTS"))
168: return BASICCONSTRAINTS;
169: else if (s0.equalsIgnoreCase("CRLNUMBER"))
170: return CRLNUMBER;
171: else if (s0.equalsIgnoreCase("CRLREASON"))
172: return CRLREASON;
173: else if (s0.equalsIgnoreCase("HOLDINSTRUCTIONCODE"))
174: return HOLDINSTRUCTIONCODE;
175: else if (s0.equalsIgnoreCase("INVALIDITYDATE"))
176: return INVALIDITYDATE;
177: else if (s0.equalsIgnoreCase("DELTACRLINDICATOR"))
178: return DELTACRLINDICATOR;
179: else if (s0.equalsIgnoreCase("ISSUINGDISTRIBUTIONPOINT"))
180: return ISSUINGDISTRIBUTIONPOINT;
181: else if (s0.equalsIgnoreCase("CERTIFICATEISSUER"))
182: return CERTIFICATEISSUER;
183: else if (s0.equalsIgnoreCase("NAMECONSTRAINTS"))
184: return NAMECONSTRAINTS;
185: else if (s0.equalsIgnoreCase("CRLDISTRIBUTIONPOINTS"))
186: return CRLDISTRIBUTIONPOINTS;
187: else if (s0.equalsIgnoreCase("CERTIFICATEPOLICIES"))
188: return CERTIFICATEPOLICIES;
189: else if (s0.equalsIgnoreCase("POLICYMAPPINGS"))
190: return POLICYMAPPINGS;
191: else if (s0.equalsIgnoreCase("AUTHORITYKEYIDENTIFIER"))
192: return AUTHORITYKEYIDENTIFIER;
193: else if (s0.equalsIgnoreCase("POLICYCONSTRAINTS"))
194: return POLICYCONSTRAINTS;
195: else if (s0.equalsIgnoreCase("EXTKEYUSAGE"))
196: return EXTKEYUSAGE;
197: //--------------------------------------------------------------------------
198: else if (s0.equalsIgnoreCase("EMAILADDRESS"))
199: return EMAILADDRESS;
200: //--------------------------------------------------------------------------
201: else if (s0.equalsIgnoreCase("ID_CONTENTINFO"))
202: return ID_CONTENTINFO;
203: else if (s0.equalsIgnoreCase("ID_DATA"))
204: return ID_DATA;
205: else if (s0.equalsIgnoreCase("ID_SIGNEDDATA"))
206: return ID_SIGNEDDATA;
207: else if (s0.equalsIgnoreCase("ID_ENVELOPEDDATA"))
208: return ID_ENVELOPEDDATA;
209: else if (s0.equalsIgnoreCase("ID_SIGNEDANDENVELOPEDDATA"))
210: return ID_SIGNEDANDENVELOPEDDATA;
211: else if (s0.equalsIgnoreCase("ID_DIGESTEDDATA"))
212: return ID_DIGESTEDDATA;
213: else if (s0.equalsIgnoreCase("ID_ENCRYPTEDDATA"))
214: return ID_ENCRYPTEDDATA;
215: else if (s0.equalsIgnoreCase("ID_AUTHDATA"))
216: return ID_AUTHDATA;
217: //--------------------------------------------------------------------------
218: else if (s0.equalsIgnoreCase("ID_CONTENTTYPE"))
219: return ID_CONTENTTYPE;
220: else if (s0.equalsIgnoreCase("ID_MESSAGEDIGEST"))
221: return ID_MESSAGEDIGEST;
222: else if (s0.equalsIgnoreCase("ID_SIGNINGTIME"))
223: return ID_SIGNINGTIME;
224: else if (s0.equalsIgnoreCase("ID_SMIMECAPABILITIES"))
225: return ID_SMIMECAPABILITIES;
226: else if (s0.equalsIgnoreCase("ID_COUNTERSIGNATURE"))
227: return ID_COUNTERSIGNATURE;
228: //--------------------------------------------------------------------------
229: else if (s0.equalsIgnoreCase("SHA1"))
230: return SHA1;
231: else if (s0.equalsIgnoreCase("MD2"))
232: return MD2;
233: else if (s0.equalsIgnoreCase("MD5"))
234: return MD5;
235: else if (s0.equalsIgnoreCase("MD2_WITH_RSA"))
236: return MD2_WITH_RSA;
237: else if (s0.equalsIgnoreCase("MD5_WITH_RSA"))
238: return MD5_WITH_RSA;
239: else if (s0.equalsIgnoreCase("SHA1_WITH_RSA"))
240: return SHA1_WITH_RSA;
241: else if (s0.equalsIgnoreCase("SHA1_WITH_DSA"))
242: return SHA1_WITH_DSA;
243: else if (s0.equalsIgnoreCase("RSA"))
244: return RSA;
245: else if (s0.equalsIgnoreCase("DSA"))
246: return DSA;
247: else if (s0.equalsIgnoreCase("DH_PUBLIC_NUMBER"))
248: return DH_PUBLIC_NUMBER;
249: else if (s0.equalsIgnoreCase("ESDH"))
250: return ESDH;
251: else if (s0.equalsIgnoreCase("CMS3DESWRAP"))
252: return CMS3DESWRAP;
253: else if (s0.equalsIgnoreCase("CMSRC2WRAP"))
254: return CMSRC2WRAP;
255: else if (s0.equalsIgnoreCase("HMAC_SHA1"))
256: return HMAC_SHA1;
257: else if (s0.equalsIgnoreCase("DES_EDE3_CBC"))
258: return DES_EDE3_CBC;
259: else if (s0.equalsIgnoreCase("RC2_CBC"))
260: return RC2_CBC;
261: else if (s0.equalsIgnoreCase("DES"))
262: return DES;
263: else {
264: int[] failure = { -1 };
265: return failure;
266: }
267: }
268: }
|