private int createCredential() throws Exception {
      int exitCode;
      List<String> args = new ArrayList<>();

      args.add("create");
      args.add(alias);
      if (value != null) {
        args.add("-value");
        args.add(value);
      }

      String[] toolArgs = args.toArray(new String[args.size()]);

      exitCode = ToolRunner.run(getConf(), new CredentialShell(), toolArgs);

      return exitCode;
    }
Creates the specified credential. A credential with the same alias
should not exist. It must be deleted before this method is called.

@return - 0 on success; 1 on failure.
@throws Exception - If the alias already exists.
ambari-server/src/main/java/org/apache/ambari/server/credentialapi/CredentialUtil.java