static X509KeyManager createKeyManager(String keyStoreLocation, char[] keyStorePassword,
    String keyStoreType) throws KeyManagerException {

    if (keyStorePassword == null) {
      keyStorePassword = EMPTY_CHAR_ARRAY;
    }

    try {
      KeyStoreFileType storeFileType =
        KeyStoreFileType.fromPropertyValueOrFileName(keyStoreType, keyStoreLocation);
      KeyStore ks = FileKeyStoreLoaderBuilderProvider.getBuilderForKeyStoreFileType(storeFileType)
        .setKeyStorePath(keyStoreLocation).setKeyStorePassword(keyStorePassword).build()
        .loadKeyStore();

      KeyManagerFactory kmf = KeyManagerFactory.getInstance("PKIX");
      kmf.init(ks, keyStorePassword);

      for (KeyManager km : kmf.getKeyManagers()) {
        if (km instanceof X509KeyManager) {
          return (X509KeyManager) km;
        }
      }
      throw new KeyManagerException("Couldn't find X509KeyManager");
    } catch (IOException | GeneralSecurityException | IllegalArgumentException e) {
      throw new KeyManagerException(e);
    }
  }
Creates a key manager by loading the key store from the given file of the given type,
optionally decrypting it using the given password.
@param keyStoreLocation the location of the key store file.
@param keyStorePassword optional password to decrypt the key store. If empty, assumes the key
                        store is not encrypted.
@param keyStoreType     must be JKS, PEM, PKCS12, BCFKS or null. If null, attempts to
                        autodetect the key store type from the file extension (e.g. .jks /
                        .pem).
@return the key manager.
@throws KeyManagerException if something goes wrong.
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java