Listing the Aliases in a Key Store: A key store is a collection of keys and certificates. : Keystore « Security « Java Tutorial






import java.io.FileInputStream;
import java.security.KeyStore;
import java.util.Enumeration;

public class Main {
  public static void main(String[] argv) throws Exception {
    FileInputStream is = new FileInputStream("yourfile"+".keystore");
    KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
    String password = "my-keystore-password";
    keystore.load(is, password.toCharArray());

    Enumeration e = keystore.aliases();
    for (; e.hasMoreElements();) {
      String alias = (String) e.nextElement();

      boolean b = keystore.isKeyEntry(alias);

      b = keystore.isCertificateEntry(alias);
    }
    is.close();
  }
}








36.23.Keystore
36.23.1.Retrieving a Key Pair from a Key Store
36.23.2.Adding a Certificate to a Key Store
36.23.3.Retrieving a Certificate from a Key Store
36.23.4.Listing the Aliases in a Key Store: A key store is a collection of keys and certificates.
36.23.5.Listing the Aliases in a Key Store using keytool:
36.23.6.Create a keystore with a self-signed certificate, using the keytool command
36.23.7.Specify the keystore of certificates using the javax.net.ssl.keyStore system property: