public boolean isUserInGroup(UserEntity userEntity, GroupEntity groupEntity) {
    for (MemberEntity memberEntity : userEntity.getMemberEntities()) {
      if (memberEntity.getGroup().equals(groupEntity)) {
        return true;
      }
    }
    return false;
  }
Performs a check if given user belongs to given group.

@param userEntity  user entity
@param groupEntity group entity
@return true if user presents in group
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/Users.java