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(String ksType, String file, String ksPassword)
get Key Store
String type = ksType != null ? ksType : KeyStore.getDefaultType();
char[] password = ksPassword != null ? ksPassword.toCharArray() : null;
KeyStore keyStore = KeyStore.getInstance(type);
keyStore.load(new FileInputStream(file), password);
return keyStore;
KeyStoregetKeyStore(String path, String passwd, String storeType)
get Key Store
try {
    InputStream fis = new FileInputStream(path);
    KeyStore store = KeyStore.getInstance(storeType);
    store.load(fis, passwd.toCharArray());
    return store;
} catch (Exception e) {
    throw new RuntimeException(e);
KeyStoregetKeyStoreFromFile(String filePath, char[] password)
get Key Store From File
KeyStore store = KeyStore.getInstance("JKS");
store.load(new FileInputStream(filePath), password);
return store;
KeyStoregetKeyStoreFromFile(String keystoreName, String password, String home)
Read Keystore from the file identified by given keystorename, password
Path tenantKeystorePath = Paths.get(home, "repository", "resources", "security", keystoreName);
FileInputStream file = new FileInputStream(tenantKeystorePath.toString());
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(file, password.toCharArray());
return keystore;
SortedSetgetKeyStores()
Returns array of supported KeyStores
final Set<String> tmpKeyStores = java.security.Security.getAlgorithms("KeyStore");
return new TreeSet<String>(tmpKeyStores);
StringgetKeyString(Key key)
get Key String
byte[] keyBytes = key.getEncoded();
String s = (new BASE64Encoder()).encode(keyBytes);
return s;
StringgetKeyString(Key key)
get Key String
byte[] keyBytes = key.getEncoded();
return (new BASE64Encoder()).encode(keyBytes);