sun.security.pkcs12.PKCS12KeyStore Java Examples

The following examples show how to use sun.security.pkcs12.PKCS12KeyStore. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaKeyStore.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public DualFormatJKS() {
    super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
}
 
Example #2
Source File: JavaKeyStore.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public DualFormatJKS() {
    super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
}
 
Example #3
Source File: JavaKeyStore.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public DualFormatJKS() {
    super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
}
 
Example #4
Source File: JavaKeyStore.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public DualFormatJKS() {
    super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
}
 
Example #5
Source File: JavaKeyStore.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public DualFormatJKS() {
    super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
}
 
Example #6
Source File: JavaKeyStore.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public DualFormatJKS() {
    super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
}
 
Example #7
Source File: Main.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Load the srckeystore from a stream, used in -importkeystore
 * @return the src KeyStore
 */
KeyStore loadSourceKeyStore() throws Exception {

    InputStream is = null;
    File srcksfile = null;
    boolean srcIsPasswordless = false;

    if (P11KEYSTORE.equalsIgnoreCase(srcstoretype) ||
            KeyStoreUtil.isWindowsKeyStore(srcstoretype)) {
        if (!NONE.equals(srcksfname)) {
            System.err.println(MessageFormat.format(rb.getString
                (".keystore.must.be.NONE.if.storetype.is.{0}"), srcstoretype));
            System.err.println();
            tinyHelp();
        }
    } else {
        srcksfile = new File(srcksfname);
        is = new FileInputStream(srcksfile);
    }

    KeyStore store;
    try {
        // Probe for keystore type when filename is available
        if (srcksfile != null && is != null && srcProviderName == null &&
                srcstoretype == null) {
            store = KeyStore.getInstance(srcksfile, srcstorePass);
            srcstoretype = store.getType();
            if (srcstoretype.equalsIgnoreCase("pkcs12")) {
                srcIsPasswordless = PKCS12KeyStore.isPasswordless(srcksfile);
            }
        } else {
            if (srcstoretype == null) {
                srcstoretype = KeyStore.getDefaultType();
            }
            if (srcProviderName == null) {
                store = KeyStore.getInstance(srcstoretype);
            } else {
                store = KeyStore.getInstance(srcstoretype, srcProviderName);
            }
        }

        if (srcstorePass == null
                && !srcprotectedPath
                && !KeyStoreUtil.isWindowsKeyStore(srcstoretype)
                && !srcIsPasswordless) {
            System.err.print(rb.getString("Enter.source.keystore.password."));
            System.err.flush();
            srcstorePass = Password.readPassword(System.in);
            passwords.add(srcstorePass);
        }

        // always let keypass be storepass when using pkcs12
        if (P12KEYSTORE.equalsIgnoreCase(srcstoretype)) {
            if (srckeyPass != null && srcstorePass != null &&
                    !Arrays.equals(srcstorePass, srckeyPass)) {
                MessageFormat form = new MessageFormat(rb.getString(
                    "Warning.Different.store.and.key.passwords.not.supported.for.PKCS12.KeyStores.Ignoring.user.specified.command.value."));
                Object[] source = {"-srckeypass"};
                System.err.println(form.format(source));
                srckeyPass = srcstorePass;
            }
        }

        store.load(is, srcstorePass);   // "is" already null in PKCS11
    } finally {
        if (is != null) {
            is.close();
        }
    }

    if (srcstorePass == null
            && !srcIsPasswordless
            && !KeyStoreUtil.isWindowsKeyStore(srcstoretype)) {
        // anti refactoring, copied from printNoIntegrityWarning(),
        // but change 2 lines
        System.err.println();
        System.err.println(rb.getString
            (".WARNING.WARNING.WARNING."));
        System.err.println(rb.getString
            (".The.integrity.of.the.information.stored.in.the.srckeystore."));
        System.err.println(rb.getString
            (".WARNING.WARNING.WARNING."));
        System.err.println();
    }

    return store;
}
 
Example #8
Source File: JavaKeyStore.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public DualFormatJKS() {
    super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
}
 
Example #9
Source File: JavaKeyStore.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public DualFormatJKS() {
    super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
}
 
Example #10
Source File: JavaKeyStore.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public DualFormatJKS() {
    super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
}
 
Example #11
Source File: JavaKeyStore.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public DualFormatJKS() {
    super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
}