private KeyStore getKeyStore(final File keyStoreFile, String keyStoreType) throws AmbariException {
    KeyStore keyStore;
    FileInputStream inputStream;

    if (keyStoreFile.exists()) {
      if (keyStoreFile.length() > 0) {
        LOG.debug("Reading key store from {}", keyStoreFile.getAbsolutePath());
        try {
          inputStream = new FileInputStream(keyStoreFile);
        } catch (FileNotFoundException e) {
          throw new AmbariException(String.format("Failed to open the key store file: %s", e.getLocalizedMessage()), e);
        }
      } else {
        LOG.debug("The key store file found in {} is empty. Returning new (non-persisted) KeyStore", keyStoreFile.getAbsolutePath());
        inputStream = null;
      }
    } else {
      LOG.debug("Key store file not found in {}. Returning new (non-persisted) KeyStore", keyStoreFile.getAbsolutePath());
      inputStream = null;
    }

    try {
      keyStore = loadKeyStore(inputStream, keyStoreType);
    } finally {
      IOUtils.closeQuietly(inputStream);
    }

    return keyStore;
  }
Reads the key store data from the specified file. If the file does not exist, a new KeyStore
will be created.

@param keyStoreFile a File pointing to the key store file
@param keyStoreType the type of key store data to read (or create)
@return the loaded KeyStore
@throws AmbariException if the Master Key Service is not set
@see AbstractCredentialStore#loadCredentialStore()
ambari-server/src/main/java/org/apache/ambari/server/security/encryption/FileBasedCredentialStore.java