001: package org.enhydra.oyster.exception;
002:
003: /**
004: * Title: Oyster Project
005: * Description: Creating S/MIME email transport capabilities.
006: * Copyright: Copyright (c) 2001
007: * @Author Vladimir Radisic
008: * @Version 2.1.6
009: */
010:
011: /**
012: * ErrorStorage is used for storing SMIME error mesages used in construction
013: * of the SMIMEException.
014: */
015: public class ErrorStorage {
016: /**
017: * Returns error message text according to the given input number parameter.
018: * @param errNumber0 error number
019: * @return error message text coresponding to given error number
020: */
021: public static String getErrorMesage(int errNumber0) {
022: String errMsg = "SMIME Error " + errNumber0 + ": ";
023: switch (errNumber0) {
024: // org.enhydra.oyster.der.DERObject class
025: case 1000:
026: errMsg = errMsg
027: + "Identifier octet in DER encoding value can't be negative!";
028: break;
029: case 1001:
030: errMsg = errMsg
031: + "Identifier octet in DER encoding value must be less than 255!";
032: break;
033: case 1002:
034: errMsg = errMsg
035: + "Complex Identifier octets in DER encoding value are not suported in this version of DERObject!";
036: break;
037: case 1003:
038: errMsg = errMsg
039: + "Can't use addContent method with Null DER object!";
040: break;
041: case 1004:
042: errMsg = errMsg
043: + "Content of DER object must be present. Use addContent method or other constructor!";
044: break;
045: // org.enhydra.oyster.der.DERClassContextSpecificPr class
046: case 1005:
047: errMsg = errMsg
048: + "Content could be added only once in primitive DERClassContextSpecific object!";
049: break;
050: // org.enhydra.oyster.der.DERBitString class
051: case 1006:
052: errMsg = errMsg
053: + "Number of unused bits must be in range 0-7!";
054: break;
055: case 1007:
056: errMsg = errMsg
057: + "BitString can contain only characters 0 or 1!";
058: break;
059: // org.enhydra.oyster.der.DERObjectIdentifier
060: case 1008:
061: errMsg = errMsg
062: + "No dots in \"DOT_SEPARATED_ARRAY\" construction!";
063: break;
064: case 1009:
065: errMsg = errMsg
066: + "Allowable types of construction are: \"DOT_SEPARATED_ARRAY\" and \"NAME_STRING\"!";
067: break;
068: case 1010:
069: errMsg = errMsg + "Unknown type of Object identifier!";
070: break;
071: // org.enhydra.oyster.crypto.SymmetricEncryption
072: case 1011:
073: errMsg = errMsg
074: + "Number of bytes in imported symmetric Key is incorect!";
075: break;
076: // org.enhydra.oyster.crypto.SymmetricEncryption,
077: // org.enhydra.oyster.crypto.DESede3CBCParameter,
078: // org.enhydra.oyster.crypto.RC2CBCParameter
079: case 1012:
080: errMsg = errMsg
081: + "Number of bytes in imported IV must be 8!";
082: break;
083: // org.enhydra.oyster.crypto.Algorithm,
084: // org.enhydra.oyster.cms.CMSEnvelopedDataSource
085: case 1013:
086: errMsg = errMsg
087: + "Allowed algorithm names are: DES_EDE3_CBC, RC2_CBC or DES!";
088: break;
089: // org.enhydra.oyster.crypto.Algorithm
090: // org.enhydra.oyster.crypto.RC2CBCParameter
091: case 1014:
092: errMsg = errMsg
093: + "Key size in bits for RC2 algorithm must be 40, 64 or 128!";
094: break;
095: // org.enhydra.oyster.crypto.Algorithm
096: case 1015:
097: errMsg = errMsg
098: + "SMIME Error 1015: Key size in bits for DESede3 algorithm must be 128 or 192!";
099: break;
100: case 1016:
101: errMsg = errMsg
102: + "Key size in bits for DES algorithm must be 56!";
103: break;
104: // org.enhydra.oyster.cms.Attribute
105: case 1017:
106: errMsg = errMsg + "No value for specified attribute!";
107: break;
108: // org.enhydra.oyster.cms.ContentInfo
109: // org.enhydra.oyster.cms.EncapsulatedContentInfo
110: // org.enhydra.oyster.cms.EncryptedContentInfo
111: // org.enhydra.oyster.cms.EnvelopedData
112: // org.enhydra.oyster.cms.SignedData
113: case 1018:
114: errMsg = errMsg + "Order of adding components is unproper!";
115: break;
116: // org.enhydra.oyster.cms.CMSVersion
117: case 1019:
118: errMsg = errMsg + "CMS Version must be 0,1,2,3 or 4!";
119: break;
120: // org.enhydra.oyster.cms.CapabilitiesAttribute
121: case 1020:
122: errMsg = errMsg
123: + "Unknown type of Capabilities Attributes!";
124: break;
125: // org.enhydra.oyster.cms.IssuerName
126: case 1021:
127: errMsg = errMsg
128: + "Function addAllRelativeDN was already performed!";
129: break;
130: // org.enhydra.oyster.cms.KeyTransRecipientInfo
131: case 1022:
132: errMsg = errMsg + "Recipient is alredy added!";
133: break;
134: // org.enhydra.oyster.cms.RelativeDistinguishedName
135: case 1023:
136: errMsg = errMsg
137: + "This function can not be performed twice for one object!";
138: break;
139: case 1024:
140: errMsg = errMsg
141: + "This function can be performed only with the simplest constructor!";
142: break;
143: // org.enhydra.oyster.cms.SignedAttributes
144: case 1025:
145: errMsg = errMsg + "No attribute was added!";
146: break;
147: // org.enhydra.oyster.cms.SignerInfos
148: case 1026:
149: errMsg = errMsg + "Missing owner's certificate!";
150: break;
151: case 1027:
152: errMsg = errMsg + "Missing owner's private key!";
153: break;
154: // unused
155: // case 1028:
156: // errMsg = errMsg + "Serial numbers of capabilities parameter must be between 0 and 5!";
157: // break;
158: // unused
159: // case 1029:
160: // errMsg = errMsg + "Neither the same group of capabilities can be add twice, nor any group can be added after DEFAULT type!";
161: // break;
162: // org.enhydra.oyster.cms.CMSSignedDataSource
163: // org.enhydra.oyster.smime.BaseSignedSMIMEObject
164: case 1030:
165: errMsg = errMsg
166: + "Type of set capabilities attributes must be: SIGNATURE, SYMMETRIC or ENCIPHER!";
167: break;
168: // org.enhydra.oyster.cms.CMSSignedDataSource
169: case 1031:
170: errMsg = errMsg
171: + "Allowed signing algorithms are: SHA1_WITH_RSA, MD2_WITH_RSA, MD5_WITH_RSA or SHA1_WITH_DSA!";
172: break;
173: // org.enhydra.oyster.util.Base64ForMime
174: case 1032:
175: errMsg = errMsg
176: + "Line breaks must be grather than 0 and less than or equal to 76!";
177: break;
178: // org.enhydra.oyster.util.ByteArrayComparator
179: case 1033:
180: errMsg = errMsg
181: + "Searching array is bigger than / or equal to lookup array!";
182: //org.enhydra.oyster.smime.EnvelopedSMIME
183: //org.enhydra.oyster.smime.BaseSignedSMIMEObject
184: case 1034:
185: errMsg = errMsg + "File does not exist!";
186: break;
187: //org.enhydra.oyster.smime.EnvelopedSMIME
188: case 1035:
189: errMsg = errMsg
190: + "Parameter content shouldn't be null in setContent method!";
191: break;
192: //org.enhydra.oyster.smime.BaseSMIMEObject
193: case 1036:
194: errMsg = errMsg
195: + "Unknown type Content-Transfer-Encoding! Allowable types are: 7bit, quoted-printable and base64!";
196: break;
197: // org.enhydra.oyster.util.PFXUtils
198: case 1037:
199: errMsg = errMsg
200: + "Problem with aliases in pfx or p12 file!";
201: break;
202: case 1038:
203: errMsg = "SMIME Error 1038: Problem with extracting certificate chain"
204: + " from .pfx or .p12 file!";
205: break;
206: // org.enhydra.oyster.mail.EnvelopedAndSignedBodyPart
207: case 1039:
208: errMsg = errMsg
209: + "At least one recipient must be added before performing signing() method!";
210: break;
211: // org.enhydra.oyster.mail.SignedAndEnvelopedBodyPart
212: case 1040:
213: errMsg = errMsg
214: + "At least one signer must be added before performing enveloping() method!";
215: break;
216: //org.enhydra.oyster.smime.BaseSMIMEObject
217: case 1041:
218: errMsg = errMsg
219: + "FROM address or name of SMTP host is null!";
220: break;
221: case 1042:
222: errMsg = errMsg + "Type must be TO, CC, or BCC!";
223: break;
224: case 1043:
225: errMsg = errMsg
226: + "One of recipients must be declared as TO recipient!";
227: break;
228: case 1044:
229: errMsg = errMsg
230: + "There is no message for enveloping/signing!";
231: break;
232: //org.enhydra.oyster.smime.BaseSignedSMIMEObject
233: case 1045:
234: errMsg = errMsg
235: + "This group of capabilities has been already set for desired signer!";
236: break;
237: //org.enhydra.oyster.smime.SignedAndEnvelopedSMIME
238: case 1046:
239: errMsg = errMsg
240: + "Parameters for message protection order must be SIGN_FIRST or ENCRYPT_FIRST";
241: break;
242: //org.enhydra.oyster.smime.BaseSignedSMIMEObject
243: case 1047:
244: errMsg = errMsg
245: + "The DEFAULT capabilitiess has been already set for desired signer!";
246: break;
247: //org.enhydra.oyster.smime.BaseSMIMEObject
248: case 1048:
249: errMsg = errMsg
250: + "Content type must be \"text/plain\" or \"text/html\"!";
251: break;
252: case 1049:
253: errMsg = errMsg
254: + "Content of message couldn't be added twice!";
255: break;
256:
257: case 1999:
258: errMsg = errMsg + "Caused by non SMIMEException!";
259: break;
260: default:
261: errMsg = errMsg + "Unknown Error type: " + errNumber0 + "!";
262: }
263: return errMsg;
264: }
265: }
|