Java Utililty Methods Key Create

List of utility methods to do Key Create

Description

The list of methods to do Key Create are organized into topic(s).

Method

KeyStoregetKeyStore(File keystore)
get Key Store
KeyStore keystore_client = KeyStore.getInstance("JKS");
keystore_client.load(keystore != null ? new FileInputStream(keystore) : null, null);
return keystore_client;
KeyStoregetKeyStore(File keyStore)
get Key Store
KeyStore ks;
try (InputStream is = new FileInputStream(keyStore)) {
    ks = KeyStore.getInstance("PKCS12");
    ks.load(is, "ballerina".toCharArray());
return ks;
KeyStoregetKeyStore(final URL url, final String password)
Return the KeyStore by given URL and password
if (url == null) {
    throw new IllegalArgumentException("Keystore url may not be null");
KeyStore keystore = KeyStore.getInstance("jks");
InputStream is = null;
try {
    is = url.openStream();
    keystore.load(is, password != null ? password.toCharArray() : null);
...
KeyStoregetKeyStore(InputStream ksStream, char[] storePass)
Get the Key Store Note: This method wants the InputStream to be not null.
if (ksStream == null)
    throw new IllegalArgumentException("InputStream for the KeyStore is null");
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(ksStream, storePass);
return ks;
KeyStoregetKeyStore(String file_name, char[] storepass)
get Key Store
FileInputStream in = new FileInputStream(file_name);
KeyStore ks;
try {
    ks = KeyStore.getInstance("IAIKKeyStore", "IAIK");
} catch (java.security.NoSuchProviderException ex) {
    System.err.println(ex.toString());
    ks = KeyStore.getInstance("jks");
ks.load(in, storepass);
in.close();
return ks;
KeyStoregetKeyStore(String filename, char[] password)
get Key Store
try {
    KeyStore result = KeyStore.getInstance(KeyStore.getDefaultType());
    FileInputStream in = new FileInputStream(filename);
    result.load(in, password);
    in.close();
    return result;
} catch (IOException ex) {
    throw new GeneralSecurityException(ex.getMessage(), ex);
...
KeyStoregetKeyStore(String filename, String password)
Get a KeyStore object given the keystore filename and password.
KeyStore result = KeyStore.getInstance(KeyStore.getDefaultType());
try {
    FileInputStream in = new FileInputStream(filename);
    result.load(in, password.toCharArray());
    in.close();
} catch (Exception ex) {
    System.out.println("Failed to read keystore:");
    ex.printStackTrace();
...
KeyStoregetKeyStore(String keyStoreName, String password)
get Key Store
KeyStore ks = null;
FileInputStream fis = null;
try {
    ks = KeyStore.getInstance("JKS");
    char[] passwordArray = password.toCharArray();
    fis = new java.io.FileInputStream(keyStoreName);
    ks.load(fis, passwordArray);
    fis.close();
...
KeyStoregetKeyStore(String keystorePath, String keystorePassword)
get Key Store
try {
    KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
    keystore.load(new FileInputStream(keystorePath), keystorePassword.toCharArray());
    return keystore;
} catch (KeyStoreException | CertificateException | NoSuchAlgorithmException | IOException e) {
    e.printStackTrace();
return null;
...
KeyStoregetKeyStore(String keyStorePath, String password)
get Key Store
FileInputStream is = new FileInputStream(keyStorePath);
KeyStore ks = KeyStore.getInstance(KEY_STORE);
ks.load(is, password.toCharArray());
is.close();
return ks;