public static void main(String args[]) {
    String masterKey = "ThisissomeSecretPassPhrasse";
    String masterKeyLocation = AmbariPath.getPath("/var/lib/ambari-server/keys/master");
    boolean persistMasterKey = false;
    if (args != null && args.length > 0) {
      masterKey = args[0];
      if (args.length > 1) {
        masterKeyLocation = args[1];
      }
      if (args.length > 2 && !args[2].isEmpty()) {
        persistMasterKey = args[2].equalsIgnoreCase("true");
      }
    }

    final MasterKeyServiceImpl masterKeyService = new MasterKeyServiceImpl(masterKey);
    if (persistMasterKey && !masterKeyService.initializeMasterKeyFile(new File(masterKeyLocation), masterKey)) {
      System.exit(1);
    } else {
      System.exit(0);
    }
  }
Constructs a new MasterKeyServiceImpl using prefered source according config.
masterKey > masterKeyLocation > environment
ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java