modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/CertImporter.java [205:256]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private static void importTrusted(KeytoolParameters param,
            X509Certificate newCert) throws NoSuchAlgorithmException,
            CertificateException, CertPathBuilderException, IOException,
            KeytoolException, KeyStoreException, NoSuchProviderException {
        String alias = param.getAlias();
        KeyStore keyStore = param.getKeyStore();

        // should the certificate be added to the store or not
        boolean addIt = false;

        // if "-noprompt" option has been specified, don't make
        // additional checks.
        if (param.isNoPrompt()) {
            addIt = true;
        } else {
            // search for an equal certificate in the keystore
            String equalCertName = keyStore.getCertificateAlias(newCert);

            if (equalCertName != null) {
                // if an equal certificate exists in the store
                System.out.println("The certificate already exists in the "
                        + "keystore under alias <" + equalCertName + ">");
                // ask if a duplicating certificate should be added to the
                // store
                addIt = ArgumentsParser.getConfirmation(
                        "Do you still want to add it? [no] ", false);
            } else {
                try {
                    if (CertChainVerifier.buildCertPath(param, newCert) != null) {
                        addIt = true;
                    }
                } catch (Exception e) {
                    // if the certificate chain cannot be built
                    // print it and ask if it should be trusted or not.
                    String mdProvider = (param.getMdProvider() != null) ? param
                            .getMdProvider() : param.getProvider();
                    KeyStoreCertPrinter.printX509CertDetailed(newCert,
                            mdProvider);
                    addIt = ArgumentsParser.getConfirmation(
                            "Trust this certificate? [no] ", false);
                }
            }
        }
        if (addIt) {
            keyStore.setCertificateEntry(alias, newCert);
            param.setNeedSaveKS(true);
            System.out.println("The certificate is added to the keystore\n");
        } else {
            System.out
                    .println("The certificate is not added to the keystore\n");
        }
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



modules/jdktools/src/main/java/org/apache/harmony/tools/keytool/CertImporter.java [205:256]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private static void importTrusted(KeytoolParameters param,
            X509Certificate newCert) throws NoSuchAlgorithmException,
            CertificateException, CertPathBuilderException, IOException,
            KeytoolException, KeyStoreException, NoSuchProviderException {
        String alias = param.getAlias();
        KeyStore keyStore = param.getKeyStore();

        // should the certificate be added to the store or not
        boolean addIt = false;

        // if "-noprompt" option has been specified, don't make
        // additional checks.
        if (param.isNoPrompt()) {
            addIt = true;
        } else {
            // search for an equal certificate in the keystore
            String equalCertName = keyStore.getCertificateAlias(newCert);

            if (equalCertName != null) {
                // if an equal certificate exists in the store
                System.out.println("The certificate already exists in the "
                        + "keystore under alias <" + equalCertName + ">");
                // ask if a duplicating certificate should be added to the
                // store
                addIt = ArgumentsParser.getConfirmation(
                        "Do you still want to add it? [no] ", false);
            } else {
                try {
                    if (CertChainVerifier.buildCertPath(param, newCert) != null) {
                        addIt = true;
                    }
                } catch (Exception e) {
                    // if the certificate chain cannot be built
                    // print it and ask if it should be trusted or not.
                    String mdProvider = (param.getMdProvider() != null) ? param
                            .getMdProvider() : param.getProvider();
                    KeyStoreCertPrinter.printX509CertDetailed(newCert,
                            mdProvider);
                    addIt = ArgumentsParser.getConfirmation(
                            "Trust this certificate? [no] ", false);
                }
            }
        }
        if (addIt) {
            keyStore.setCertificateEntry(alias, newCert);
            param.setNeedSaveKS(true);
            System.out.println("The certificate is added to the keystore\n");
        } else {
            System.out
                    .println("The certificate is not added to the keystore\n");
        }
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



