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: package com.sun.midp.midletsuite;
027:
028: import java.io.DataInputStream;
029: import java.io.IOException;
030:
031: import javax.microedition.io.Connector;
032:
033: import com.sun.midp.io.j2me.storage.RandomAccessStream;
034:
035: /**
036: * Information about a MIDlet that is to be installed.
037: */
038: public class InstallInfo {
039:
040: /** What ID the installed suite is stored by. */
041: public int id;
042:
043: /** URL of the JAD. */
044: public String jadUrl;
045:
046: /** URL of the JAR. */
047: public String jarUrl;
048:
049: /** Name of the downloaded MIDlet suite jar file. */
050: public String jarFilename;
051:
052: /** How big the JAD says the JAR is. */
053: public int expectedJarSize;
054:
055: /** Name of the suite. */
056: public String suiteName;
057:
058: /** Vendor of the suite. */
059: public String suiteVendor;
060:
061: /** Version of the suite. */
062: public String suiteVersion;
063:
064: /** Description of the suite. */
065: public String description;
066:
067: /**
068: * Authorization path, staring with the most trusted CA authorizing
069: * the suite, for secure installing.
070: */
071: public String[] authPath;
072:
073: /** Security domain of the suite, for secure installing. */
074: public String domain;
075:
076: /** Flag for trusted suites. If true the system trust icon is displayed. */
077: public boolean trusted;
078:
079: /** Hash value of the suite with preverified classes */
080: public byte[] verifyHash;
081:
082: /**
083: * Constructor for InstallInfo to be called when storing a new suite.
084: */
085: public InstallInfo(int theId) {
086: id = theId;
087: }
088:
089: /**
090: * Gets the JAD URL of the suite. This is only for the installer.
091: *
092: * @return URL of the JAD can be null
093: */
094: public String getJadUrl() {
095: return jadUrl;
096: }
097:
098: /**
099: * Gets the JAR URL of the suite. This is only for the installer.
100: *
101: * @return URL of the JAR, never null, even in development environments
102: */
103: public String getJarUrl() {
104: return jarUrl;
105: }
106:
107: /**
108: * Gets the name of CA that authorized this suite.
109: *
110: * @return name of a CA or null if the suite was not signed
111: */
112: public String getCA() {
113: if (authPath == null || authPath.length == 0) {
114: return null;
115: }
116:
117: return authPath[0];
118: }
119:
120: /**
121: * Gets the authoriztion path of this suite. The path starts with
122: * the most trusted CA that authorized this suite.
123: *
124: * @return array of CA names or null if the suite was not signed
125: */
126: public String[] getAuthPath() {
127: if (authPath == null) {
128: return authPath;
129: }
130:
131: String[] result = new String[authPath.length];
132:
133: System.arraycopy(authPath, 0, result, 0, authPath.length);
134:
135: return result;
136: }
137:
138: /**
139: * Gets the security domain of this suite.
140: *
141: * @return name of a security domain
142: */
143: public String getSecurityDomain() {
144: return domain;
145: }
146:
147: /**
148: * Indicates if this suite is trusted.
149: * (not to be confused with a domain named "trusted",
150: * this is used to determine if a trusted symbol should be displayed
151: * to the user and not used for permissions)
152: *
153: * @return true if the suite is trusted false if not
154: */
155: public boolean isTrusted() {
156: return trusted;
157: }
158:
159: /**
160: * Gets hash value for the suite with all classes successfully
161: * verified during the suite installation, otherwise null value
162: * will be returned
163: *
164: * @return suite hash value
165: */
166: public final byte[] getVerifyHash() {
167: return verifyHash;
168: }
169:
170: /**
171: * Gets the URL that the suite was downloaded from.
172: *
173: * @return URL of the JAD, or JAR for a JAR only suite, never null,
174: * even in development environments
175: */
176: public String getDownloadUrl() {
177: String url = getJadUrl();
178:
179: if (url != null) {
180: return url;
181: }
182:
183: return getJarUrl();
184: }
185:
186: /**
187: * Gets the unique ID of the suite.
188: *
189: * @return suite ID
190: */
191: public int getID() {
192: return id;
193: }
194:
195: /**
196: * Populates this InstallInfo instance from persistent store.
197: *
198: * @throws IOException if the information cannot be read
199: */
200: native void load() throws IOException;
201:
202: /**
203: * Saves the Suite Install Info from persistent store
204: */
205: // native void save();
206: }
|