private static boolean isMasterKeyFile(File file) {
    try (FileReader reader = new FileReader(file)) {
      char[] buffer = new char[MASTER_PERSISTENCE_TAG_PREFIX.length()];
      return (reader.read(buffer) == buffer.length) && Arrays.equals(buffer, MASTER_PERSISTENCE_TAG_PREFIX.toCharArray());
    } catch (Exception e) {
      // Ignore, assume the file is not a master key file...
    }

    return false;
  }
Determines if the specified file is a "master key" file by checking the file header to see if it
matches an expected value.
<p/>
The "master key" file is expected to have a header (or first line) that starts with "#1.0#". If it,
it is assumed to be a "master key" file, otherwise it is assumed to not be.

@param file the file to test
@return true if the file is identitified as "master key" file; otherwise false
ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java