@Override
  protected String[] getKinitCommand(String executableKinit, PrincipalKeyCredential credentials, String credentialsCache, Map<String, String> kerberosConfiguration) throws KerberosOperationException {
    // kinit -c <path> -S kadmin/`hostname -f` <principal>
    String kadminPrincipalName = variableReplacementHelper.replaceVariables(kerberosConfiguration.get(KERBEROS_ENV_KADMIN_PRINCIPAL_NAME), buildReplacementsMap(kerberosConfiguration));
    if (kadminPrincipalName == null) {
      kadminPrincipalName = String.format("kadmin/%s", getAdminServerHost(false));
    }
    String [] command = new String[]{
        executableKinit,
        "-c",
        credentialsCache,
        "-S",
        kadminPrincipalName,
        credentials.getPrincipal()
    };
    if (Arrays.asList(command).contains(null)){
      throw new KerberosOperationException("Got a null value, can not create 'kinit' command");
    }
    return command;
  }
Invokes the kadmin shell command to issue queries

@param query a String containing the query to send to the kdamin command
@return a ShellCommandUtil.Result containing the result of the operation
@throws KerberosKDCConnectionException       if a connection to the KDC cannot be made
@throws KerberosAdminAuthenticationException if the administrator credentials fail to authenticate
@throws KerberosRealmException               if the realm does not map to a KDC
@throws KerberosOperationException           if an unexpected error occurred
ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandler.java