@Override
  public boolean removePrincipal(String principal, boolean service) throws KerberosOperationException {
    if (!isOpen()) {
      throw new KerberosOperationException("This operation handler has not been opened");
    }

    if (StringUtils.isEmpty(principal)) {
      throw new KerberosOperationException("Failed to remove principal - no principal specified");
    }

    ShellCommandUtil.Result result = invokeKAdmin(String.format("delete_principal -force %s", principal));

    // If there is data from STDOUT, see if the following string exists:
    //    Principal "<principal>" created
    String stdOut = result.getStdout();
    return (stdOut != null) && !stdOut.contains("Principal does not exist");
  }
Removes an existing principal in a previously configured KDC
<p/>
The implementation is specific to a particular type of KDC.

@param principal a String containing the principal to remove
@param service   a boolean value indicating whether the principal is for a service or not
@return true if the principal was successfully removed; otherwise false
@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