public void addKerberosAuthentication(UserEntity userEntity, String principalName, boolean persist) throws AmbariException {
    addAuthentication(userEntity,
        UserAuthenticationType.KERBEROS,
        principalName,
            (user, key) -> {
              // Ensure no other authentication entries exist for the same principal...
              if (!CollectionUtils.isEmpty(userAuthenticationDAO.findByTypeAndKey(UserAuthenticationType.KERBEROS, key))) {
                throw new AmbariException("The authentication type already exists for this principal");
              }
            },
        persist);
  }
Adds the ability for a user to authenticate using a Kerberos token.

@param userEntity    the user
@param principalName the user's principal name
@param persist       true, to persist the created entity; false, to not persist the created entity
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/Users.java