modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/CertImporter.java [62:95]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    static void importCert(KeytoolParameters param)
            throws FileNotFoundException, CertificateException,
            NoSuchAlgorithmException, UnrecoverableKeyException,
            CertPathBuilderException, IOException, KeytoolException,
            NoSuchProviderException, KeyStoreException {

        String alias = param.getAlias();
        KeyStore keyStore = param.getKeyStore();
        boolean contains = keyStore.containsAlias(alias);
        String certProvider = (param.getCertProvider() != null) ? param
                .getCertProvider() : param.getProvider();

        // if the alias already exists, try to import the certificate as
        // a cert reply
        if (contains
                && keyStore.entryInstanceOf(alias,
                        KeyStore.PrivateKeyEntry.class)) {
            // read the certificates
            Collection<X509Certificate> certCollection = CertReader.readCerts(
                    param.getFileName(), false, certProvider);

            importReply(param, certCollection);
        } else if (!contains) { // import a trusted certificate
            // read the certificate
            Collection<X509Certificate> trustedCert = CertReader.readCerts(
                    param.getFileName(), true, certProvider);

            importTrusted(param, trustedCert.iterator().next());
        } else {// if the existing entry is not a private key entry
            throw new KeytoolException(
                    "Failed to import the certificate. \nAlias <" + alias
                            + "> already exists and is not a private key entry");
        }
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



modules/jdktools/src/main/java/org/apache/harmony/tools/keytool/CertImporter.java [62:95]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    static void importCert(KeytoolParameters param)
            throws FileNotFoundException, CertificateException,
            NoSuchAlgorithmException, UnrecoverableKeyException,
            CertPathBuilderException, IOException, KeytoolException,
            NoSuchProviderException, KeyStoreException {

        String alias = param.getAlias();
        KeyStore keyStore = param.getKeyStore();
        boolean contains = keyStore.containsAlias(alias);
        String certProvider = (param.getCertProvider() != null) ? param
                .getCertProvider() : param.getProvider();

        // if the alias already exists, try to import the certificate as
        // a cert reply
        if (contains
                && keyStore.entryInstanceOf(alias,
                        KeyStore.PrivateKeyEntry.class)) {
            // read the certificates
            Collection<X509Certificate> certCollection = CertReader.readCerts(
                    param.getFileName(), false, certProvider);

            importReply(param, certCollection);
        } else if (!contains) { // import a trusted certificate
            // read the certificate
            Collection<X509Certificate> trustedCert = CertReader.readCerts(
                    param.getFileName(), true, certProvider);

            importTrusted(param, trustedCert.iterator().next());
        } else {// if the existing entry is not a private key entry
            throw new KeytoolException(
                    "Failed to import the certificate. \nAlias <" + alias
                            + "> already exists and is not a private key entry");
        }
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



