Class KeyStoreUtil


  • public final class KeyStoreUtil
    extends Object
    Utility class to retrieve private keys from KeyStore.
    • Method Detail

      • getPublicKey

        public static Key getPublicKey​(KeyStore keyStore,
                                       String alias,
                                       String password)
        Retrieve the public key from the keystore: it could be a certificate or a symmetric key.
        Parameters:
        keyStore - The keystore where to find the key.
        alias - The alias associated with the key.
        password - The keystore password, could be null if the key is not symmetric. (Only symmetric key, SecretKey will require a password).
        Returns:
        The public key: certificate for asymmetric keys or SecretKey for symmetric keys, stored in the keystore.
      • storeTypeFromKeyStore

        public static String storeTypeFromKeyStore​(String filename)
        Get default keystore type based on the keystore filename.
        Parameters:
        filename - name of the keystore file with extension
        Returns:
        default store type for the given filename or "PKCS12" if no default available.