public Collection<UserAuthenticationEntity> getUserAuthenticationEntities(UserEntity userEntity, UserAuthenticationType authenticationType) {
    if (userEntity == null) {
      if (authenticationType == null) {
        // Get all
        return userAuthenticationDAO.findAll();
      } else {
        // Get for the specified type
        return userAuthenticationDAO.findByType(authenticationType);
      }
    } else {
      List<UserAuthenticationEntity> authenticationEntities = userAuthenticationDAO.findByUser(userEntity);

      if (authenticationType == null) {
        // Get all for the specified user
        return authenticationEntities;
      } else {
        // Get for the specified user and type
        List<UserAuthenticationEntity> pruned = new ArrayList<>();
        for (UserAuthenticationEntity authenticationEntity : authenticationEntities) {
          if (authenticationEntity.getAuthenticationType() == authenticationType) {
            pruned.add(authenticationEntity);
          }
        }

        return pruned;
      }
    }
  }
Gets the collection of {@link UserAuthenticationEntity}s for a given user.

@param userEntity         the user; if null assumes all users
@param authenticationType the authentication type, if null assumes all
@return a collection of the requested {@link UserAuthenticationEntity}s
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/Users.java