⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 installer.java

📁 用于移动设备上的java虚拟机源代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        }        state.jadProps = new JadProperties();        try {            state.jadProps.load(new ByteArrayInputStream(state.jad),                state.jadEncoding);        } catch (InvalidJadException ije) {            postInstallMsgBackToProvider(INVALID_JAD_MSG);            throw ije;        }        state.suiteName = state.jadProps.getProperty(SUITE_NAME_PROP);        if (state.suiteName == null || state.suiteName.length() == 0) {            postInstallMsgBackToProvider(INVALID_JAD_MSG);            throw new                InvalidJadException(InvalidJadException.MISSING_SUITE_NAME);        }        state.vendor = state.jadProps.getProperty(VENDOR_PROP);        if (state.vendor == null || state.vendor.length() == 0) {            postInstallMsgBackToProvider(INVALID_JAD_MSG);            throw new                InvalidJadException(InvalidJadException.MISSING_VENDOR);        }        state.version = state.jadProps.getProperty(VERSION_PROP);        if (state.version == null || state.version.length() == 0) {            postInstallMsgBackToProvider(INVALID_JAD_MSG);            throw new                InvalidJadException(InvalidJadException.MISSING_VERSION);        }        state.storageName = makeStorageName(state.vendor, state.suiteName);        checkPreviousVersion();        state.nextStep++;    }    /**     * If the JAD belongs to an installed suite, check the URL against the     * installed one.     */    private void installStep2() {        state.nextStep++;        if (state.isPreviousVersion) {            checkForDifferentDomains(state.jadUrl);        }    }    /**     * Makes sure the suite can fit in storage and confirm installation     * with the user.     *     * @exception IOException is thrown, if an I/O error occurs during     * descriptor or jar file download     * @exception InvalidJadException is thrown, if the descriptor file is not      * properly formatted or does not contain the required      */    private void installStep3()            throws IOException, InvalidJadException {        String sizeString;        int dataSize;        int suiteSize;        sizeString = state.jadProps.getProperty(JAR_SIZE_PROP);        if (sizeString == null) {            postInstallMsgBackToProvider(INVALID_JAD_MSG);            throw new                InvalidJadException(InvalidJadException.MISSING_JAR_SIZE);        }                try {            state.expectedJarSize = Integer.parseInt(sizeString);        } catch (NumberFormatException e) {            postInstallMsgBackToProvider(INVALID_JAD_MSG);            throw new                InvalidJadException(InvalidJadException.INVALID_VALUE);        }        sizeString = state.jadProps.getProperty(DATA_SIZE_PROP);        if (sizeString == null) {            dataSize = 0;        } else {            try {                dataSize = Integer.parseInt(sizeString);            } catch (NumberFormatException e) {                postInstallMsgBackToProvider(INVALID_JAD_MSG);                throw new                    InvalidJadException(InvalidJadException.INVALID_VALUE);            }        }        /*         * A suite is a jad + jar + manifest + url + data size.         * lets say the manifest is the same size as the jad         * since we do know at this point. the size is in bytes,         * UTF-8 chars can be upto 3 bytes         */        suiteSize = state.expectedJarSize + (state.jad.length * 2) +                    (state.jadUrl.length() * 3) + dataSize;                state.file = new File(classSecurityToken);        if (suiteSize > state.file.getBytesAvailableForFiles()) {            postInstallMsgBackToProvider(INSUFFICIENT_MEM_MSG);            // the size reported to the user should be in K and rounded up            throw new                InvalidJadException(InvalidJadException.INSUFFICIENT_STORAGE,                    Integer.toString((suiteSize + 1023)/ 1024));        }        state.jarUrl = state.jadProps.getProperty(JAR_URL_PROP);        if (state.jarUrl == null || state.jarUrl.length() == 0) {            postInstallMsgBackToProvider(INVALID_JAD_MSG);            throw new                InvalidJadException(InvalidJadException.MISSING_JAR_URL);        }        if (state.listener != null &&                !state.listener.confirmJarDownload(state)) {            state.stopInstallation = true;            postInstallMsgBackToProvider(USER_CANCELLED_MSG);            throw new IOException("stopped");        }        state.nextStep++;    }    /**     * Downloads the JAR, make sure it is the correct size, make sure     * the required attributes match the JAD's. Then store the     * application.     *     * @exception IOException is thrown, if an I/O error occurs during     * descriptor or jar file download     * @exception InvalidJadException is thrown, if the descriptor file is not      * properly formatted or does not contain the required      */    private void installStep4()            throws IOException, InvalidJadException {        int bytesDownloaded;        MIDletInfo midletInfo;        String midlet;        String classfilename;        // Save jar file to temp name; we need to do this to read the        // manifest entry, but, don't want to overwrite an exisiting        // application in case there are problems with the manifest        state.storageRoot = File.getStorageRoot();        state.tempFilename = state.storageRoot + TMP_FILENAME;        bytesDownloaded = downloadJAR(state.tempFilename);        if (state.exception != null) {            return;        }        if (state.listener != null) {            state.listener.updateStatus(VERIFYING_SUITE, state);        }        try {            state.storage = new RandomAccessStream(classSecurityToken);            verifyJar(state.storage, state.tempFilename);            // Create JAR Properties (From .jar file's MANIFEST            try {                state.manifest = JarReader.readJarEntry(classSecurityToken,                                     state.tempFilename, JAR_MANIFEST);                if (state.manifest == null) {                    postInstallMsgBackToProvider(INVALID_JAR_MSG);                    throw new                        InvalidJadException(InvalidJadException.CORRUPT_JAR,                                            JAR_MANIFEST);                }            } catch (IOException ioe) {                postInstallMsgBackToProvider(INVALID_JAR_MSG);                throw new                    InvalidJadException(InvalidJadException.CORRUPT_JAR,                                        JAR_MANIFEST);            }            state.jarProps = new ManifestProperties();            try {                state.jarProps.load(new ByteArrayInputStream(state.manifest));            } catch (InvalidJadException ije) {                postInstallMsgBackToProvider(INVALID_JAR_MSG);                throw ije;            }            for (int i = 1; ; i++) {                midlet = state.getAppProperty("MIDlet-" + i);                if (midlet == null) {                    break;                }		                    midletInfo = new MIDletInfo(midlet);                classfilename = midletInfo.classname.replace('.', '/') +                                ".class";                try {		    /* Attempt to read the MIDlet from the JAR file. */		    if (JarReader.readJarEntry(classSecurityToken,                            state.tempFilename, classfilename) == null) {                        postInstallMsgBackToProvider(INVALID_JAR_MSG);                        throw new InvalidJadException(                            InvalidJadException.CORRUPT_JAR, classfilename);                    }                } catch (IOException ioe) {                    postInstallMsgBackToProvider(INVALID_JAR_MSG);                    throw new                        InvalidJadException(InvalidJadException.CORRUPT_JAR,                                            classfilename);                }            }            // move on to the next step after a warning            state.nextStep++;            // Check Manifest entries against .jad file            if (state.jadUrl != null) {                if (bytesDownloaded != state.expectedJarSize) {                    postInstallMsgBackToProvider(JAR_SIZE_MISMATCH_MSG);                    throw new  InvalidJadException(                        InvalidJadException.JAR_SIZE_MISMATCH);                }                if (!state.suiteName.equals(                        state.jarProps.getProperty(SUITE_NAME_PROP))) {                    postInstallMsgBackToProvider(ATTRIBUTE_MISMATCH_MSG);                    throw new InvalidJadException(                        InvalidJadException.SUITE_NAME_MISMATCH);                }                if (!state.version.equals(                        state.jarProps.getProperty(VERSION_PROP))) {                    postInstallMsgBackToProvider(ATTRIBUTE_MISMATCH_MSG);                    throw new InvalidJadException(                         InvalidJadException.VERSION_MISMATCH);                }                if (!state.vendor.equals(                        state.jarProps.getProperty(VENDOR_PROP))) {                    postInstallMsgBackToProvider(ATTRIBUTE_MISMATCH_MSG);                    throw new InvalidJadException(                         InvalidJadException.VENDOR_MISMATCH);                }            } else {                state.file = new File(classSecurityToken);                state.suiteName = state.jarProps.getProperty(SUITE_NAME_PROP);                if (state.suiteName == null ||                        state.suiteName.length() == 0) {                    postInstallMsgBackToProvider(INVALID_JAR_MSG);                    throw new InvalidJadException(                         InvalidJadException.MISSING_SUITE_NAME);                }                state.vendor = state.jarProps.getProperty(VENDOR_PROP);                if (state.vendor == null || state.vendor.length() == 0) {                    postInstallMsgBackToProvider(INVALID_JAR_MSG);                    throw new InvalidJadException(                         InvalidJadException.MISSING_VENDOR);                }                state.version = state.jarProps.getProperty(VERSION_PROP);                if (state.version == null || state.version.length() == 0) {                    postInstallMsgBackToProvider(INVALID_JAR_MSG);                    throw new InvalidJadException(                         InvalidJadException.MISSING_VERSION);                }                                try {                    checkVersionFormat(state.version);                } catch (NumberFormatException nfe) {                    postInstallMsgBackToProvider(INVALID_JAR_MSG);                    throw new InvalidJadException(                         InvalidJadException.INVALID_VERSION);                }                // NYI if already installed, check the domain of the JAR URL                state.storageName = makeStorageName(state.vendor,                                                    state.suiteName);                checkPreviousVersion();            }        } catch (Exception e) {            state.file.delete(state.tempFilename);            if (e instanceof IOException) {                throw (IOException)e;            }            throw (RuntimeException)e;        }    }    /**     * If the JAR belongs to an installed suite if there was     * no JAD, check the URL against the installed one.     */    private void installStep5() {        state.nextStep++;        if (state.jadUrl == null && state.isPreviousVersion) {            checkForDifferentDomains(state.jarUrl);        }    }    /**     * Checks the permissions and store the suite.     *     * @exception IOException is thrown, if an I/O error occurs during     * storing the suite     * @exception InvalidJadException is thrown, if the there is     * permission problem     */    private void installStep6() throws IOException, InvalidJadException {        String suiteStorageRoot;        DataOutputStream storageStream;        String securityDomain;        try {                        if (state.ca != null) {                // suite was signed                securityDomain = getSecurityDomainName(state.storageRoot,                                                       state.ca);            } else {                securityDomain = unsignedSecurityDomain;            }            /*             * untrusted and test domains do not check for requested             * permissions             */            if (Permissions.UNTRUSTED_DOMAIN_NAME.equals(securityDomain)) {                if (state.isPreviousVersion &&                        state.previousSuite.isTrusted()) {                    // Do not overwrite trusted suites with untrusted ones                    postInstallMsgBackToProvider(AUTHORIZATION_FAILURE_MSG);                    throw new InvalidJadException(                        InvalidJadException.TRUSTED_OVERWRITE_FAILURE,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -