private UserDetails createUserDetails(UserEntity userEntity) {
    String username = userEntity.getUserName();

    // Ensure the user account is allowed to log in
    try {
      users.validateLogin(userEntity, username);
    } catch (AccountDisabledException | TooManyLoginFailuresException e) {
      if (configuration.showLockedOutUserMessage()) {
        throw e;
      } else {
        // Do not give away information about the existence or status of a user
        throw new InvalidUsernamePasswordCombinationException(username, false, e);
      }
    }

    return new AmbariUserDetailsImpl(new User(userEntity), null, users.getUserAuthorities(userEntity));
  }
Given a username, finds an appropriate account in the Ambari database.

@param username  a username
@param principal the user's principal
@return the user details of the found user, or <code>null</code> if an appropriate user was not found
ambari-server/src/main/java/org/apache/ambari/server/security/authentication/kerberos/AmbariAuthToLocalUserDetailsService.java