001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.midp.installer;
028:
029: /**
030: * Thrown when a downloaded JAD is discovered to be invalid. This includes
031: * this signed JAD's also. Since some of the conditions that cause this
032: * exception may be recovered from, this exception contains a specific
033: * RC (reason code) that so corrective action can be performed.
034: */
035: public class InvalidJadException extends java.io.IOException {
036:
037: /** (1) The server for the JAD was not found. */
038: public static final int JAD_SERVER_NOT_FOUND = 1;
039:
040: /** (2) The JAD was not found. */
041: public static final int JAD_NOT_FOUND = 2;
042:
043: /** (4) The content provider certificate is missing. */
044: public static final int MISSING_PROVIDER_CERT = 4;
045:
046: /** (5) The content provider certificate cannot be decoded. */
047: public static final int CORRUPT_PROVIDER_CERT = 5;
048:
049: /**
050: * (6) The CA that issued the content provider certificate is unknown.
051: * The extra data will be the CA's name as a String.
052: */
053: public static final int UNKNOWN_CA = 6;
054:
055: /**
056: * (7) The signature of the content provider certificate is invalid.
057: * The extra data will be the subject's name as a String.
058: */
059: public static final int INVALID_PROVIDER_CERT = 7;
060:
061: /** (8) The JAR signature cannot be decoded. */
062: public static final int CORRUPT_SIGNATURE = 8;
063:
064: /** (9) The signature of the JAR is invalid. */
065: public static final int INVALID_SIGNATURE = 9;
066:
067: /** (10) The content provider certificate is a supported version. */
068: public static final int UNSUPPORTED_CERT = 10;
069:
070: /**
071: * (11) The content provider certificate is expired.
072: * The extra data will be the subject's name as a String.
073: */
074: public static final int EXPIRED_PROVIDER_CERT = 11;
075:
076: /**
077: * (12) The CA's public key has expired.
078: * The extra data will be the CA's name as a String.
079: */
080: public static final int EXPIRED_CA_KEY = 12;
081:
082: /** (13) The name of MIDlet suite is missing. */
083: public static final int MISSING_SUITE_NAME = 13;
084:
085: /** (14) The vendor is missing. */
086: public static final int MISSING_VENDOR = 14;
087:
088: /** (15) The version is missing. */
089: public static final int MISSING_VERSION = 15;
090:
091: /** (16) The format of the version is invalid. */
092: public static final int INVALID_VERSION = 16;
093:
094: /**
095: * (17) This suite is older that the one currently installed.
096: * The extra data is the installed version.
097: */
098: public static final int OLD_VERSION = 17;
099:
100: /** (18) The URL for the JAR is missing. */
101: public static final int MISSING_JAR_URL = 18;
102:
103: /**
104: * (19) The server for the JAR was not found at the URL given in
105: * the JAD. The extra data is the JAR URL.
106: */
107: public static final int JAR_SERVER_NOT_FOUND = 19;
108:
109: /**
110: * (20) The JAR was not found at the URL given in the JAD.
111: * The extra data is the JAR URL.
112: */
113: public static final int JAR_NOT_FOUND = 20;
114:
115: /** (21) The JAR size is missing. */
116: public static final int MISSING_JAR_SIZE = 21;
117:
118: /**
119: * (25) The MIDlet suite name does not match the one in the JAR
120: * manifest.
121: */
122: public static final int SUITE_NAME_MISMATCH = 25;
123:
124: /** (26) The version does not match the one in the JAR manifest. */
125: public static final int VERSION_MISMATCH = 26;
126:
127: /** (27) The vendor does not match the one in the JAR manifest. */
128: public static final int VENDOR_MISMATCH = 27;
129:
130: /**
131: * (28) A key for an attribute is not formatted correctly.
132: * The extra data is the key or the line of the attribute.
133: */
134: public static final int INVALID_KEY = 28;
135:
136: /**
137: * (29) A value for an attribute is not formatted correctly.
138: * The extra data is the key of the attribute.
139: */
140: public static final int INVALID_VALUE = 29;
141:
142: /**
143: * (30) Not enough storage for this suite to be installed
144: * The extra data will be storage needed for the suite in K bytes
145: * rounded up.
146: */
147: public static final int INSUFFICIENT_STORAGE = 30;
148:
149: /** (31) The JAR downloaded was not size in the JAD. */
150: public static final int JAR_SIZE_MISMATCH = 31;
151:
152: /**
153: * (32) This suite is newer that the one currently installed.
154: * The extra data is the installed version.
155: */
156: public static final int NEW_VERSION = 32;
157:
158: /** (33) Webserver authentication required or failed. */
159: public static final int UNAUTHORIZED = 33;
160:
161: /**
162: * (34) The JAD URL is for an installed suite but different than the
163: * original JAD URL.
164: * The extra data will be previous JAD URL.
165: */
166: public static final int JAD_MOVED = 34;
167:
168: /** (35) Server does not support basic authentication. */
169: public static final int CANNOT_AUTH = 35;
170:
171: /**
172: * (36) An entry could not be read from the JAR. The extra data is the
173: * entry name.
174: */
175: public static final int CORRUPT_JAR = 36;
176:
177: /**
178: * (37) The server did not hava a resource with the correct type
179: * (code 406) or the JAD downloaded has the wrong media type. In the
180: * second case the extra data is the Media-Type from the response.
181: */
182: public static final int INVALID_JAD_TYPE = 37;
183:
184: /**
185: * (38) The server did not hava a resource with the correct type
186: * (code 406) or the JAR downloaded has the wrong media type. In the
187: * second case the extra data is the Media-Type from the response.
188: */
189: public static final int INVALID_JAR_TYPE = 38;
190:
191: /**
192: * (39) The JAD matches a version of a suite already installed.
193: * The extra data is the installed version.
194: */
195: public static final int ALREADY_INSTALLED = 39;
196:
197: /**
198: * (40) The device does not support either the configuration or
199: * profile in the JAD.
200: */
201: public static final int DEVICE_INCOMPATIBLE = 40;
202:
203: /** (41) The configuration is missing from the manifest. */
204: public static final int MISSING_CONFIGURATION = 41;
205:
206: /** (42) The profile is missing from the manifest. */
207: public static final int MISSING_PROFILE = 42;
208:
209: /** (43) The JAD URL is invalid. */
210: public static final int INVALID_JAD_URL = 43;
211:
212: /** (44) The JAR URL is invalid. The extra data is the JAR URL. */
213: public static final int INVALID_JAR_URL = 44;
214:
215: /**
216: * (45) The connection in a push entry is already taken.
217: * The extra data is the URL of the failed connection.
218: */
219: public static final int PUSH_DUP_FAILURE = 45;
220:
221: /**
222: * (46) The format of a push attribute has an invalid format.
223: * The extra data is the URL of the failed connection.
224: */
225: public static final int PUSH_FORMAT_FAILURE = 46;
226:
227: /**
228: * (47) The connection in a push attribute is not supported.
229: * The extra data is the URL of the failed connection.
230: */
231: public static final int PUSH_PROTO_FAILURE = 47;
232:
233: /**
234: * (48) The class in a push attribute is not in MIDlet-<n> attribute.
235: * The extra data is the URL of the failed connection.
236: */
237: public static final int PUSH_CLASS_FAILURE = 48;
238:
239: /**
240: * (49) Application authorization failure.
241: * The extra data is the name of the permission.
242: */
243: public static final int AUTHORIZATION_FAILURE = 49;
244:
245: /**
246: * (50) A attribute in both the JAD and JAR manifest does not match.
247: * For trusted suites only. The extra data is the name of the attribute.
248: */
249: public static final int ATTRIBUTE_MISMATCH = 50;
250:
251: /**
252: * (51) Indicates that the user must first authenticate with
253: * the proxy.
254: */
255: public static final int PROXY_AUTH = 51;
256:
257: /**
258: * (52) Indicates that the user tried to overwrite a trusted suite
259: * with an untrusted suite during an update.
260: * The extra data is the name of signer of the current version.
261: */
262: public static final int TRUSTED_OVERWRITE_FAILURE = 52;
263:
264: /**
265: * (53) Indicates that either the JAD or manifest has too many properties
266: * to fit into memory.
267: */
268: public static final int TOO_MANY_PROPS = 53;
269:
270: /**
271: * (54) The MicroEdition-Handler-<n> attribute has invalid
272: * values. The classname may be missing or there are too many fields
273: */
274: public static final int INVALID_CONTENT_HANDLER = 54;
275:
276: /**
277: * (55) The installation of a content handler would
278: * conflict with an already installed handler.
279: */
280: public static final int CONTENT_HANDLER_CONFLICT = 55;
281:
282: /**
283: * (56) Not all classes within JAR package can be successfully
284: * verified with class verifier.
285: */
286: public static final int JAR_CLASSES_VERIFICATION_FAILED = 56;
287:
288: /**
289: * (57) Indicates that the payment information provided with the MIDlet
290: * suite is incompatible with the current implementation.
291: */
292: public static final int UNSUPPORTED_PAYMENT_INFO = 57;
293:
294: /**
295: * (58) Indicates that the payment information provided with the MIDlet
296: * suite is incomplete or incorrect.
297: */
298: public static final int INVALID_PAYMENT_INFO = 58;
299:
300: /**
301: * (59) Indicates that the MIDlet suite has payment provisioning
302: * information but it is not trusted.
303: */
304: public static final int UNTRUSTED_PAYMENT_SUITE = 59;
305:
306: /**
307: * (60) Indicates that trusted CA for this suite has been disable for
308: * software authorization. The extra data contains the CA's name.
309: */
310: public static final int CA_DISABLED = 60;
311:
312: /**
313: * (61) Indicates that the character encoding specified in the MIME type
314: * is not supported.
315: */
316: public static final int UNSUPPORTED_CHAR_ENCODING = 61;
317:
318: /** The reason why this exception occurred. */
319: private int reason;
320:
321: /** Extra data need to correct the problem. */
322: private String extraData = null;
323:
324: /**
325: * Constructs a InvalidJadException with the specified reason.
326: * @param theReason specific RC (reason code)
327: */
328: public InvalidJadException(int theReason) {
329: super ("Reason = " + theReason);
330: reason = theReason;
331: }
332:
333: /**
334: * Constructs a InvalidJadException with the specified reason and
335: * extra data.
336: * @param theReason specific reason code
337: * @param theExtraData an object that contains data to solve the problem
338: */
339: public InvalidJadException(int theReason, String theExtraData) {
340: this (theReason);
341: extraData = theExtraData;
342: }
343:
344: /**
345: * Returns specific reason why the exception was thrown.
346: * @return the RC (reason code)
347: */
348: public int getReason() {
349: return reason;
350: }
351:
352: /**
353: * Returns an extra data String to help to resolve the problem.
354: * @return extra data string, may be null,
355: * type depends on the reason for the exception
356: */
357: public String getExtraData() {
358: return extraData;
359: }
360: }
|