@Override
    public Collection<ActiveConnectionRecord> getActiveConnections(ModeledAuthenticatedUser user)
        throws GuacamoleException {

        // Privileged users (such as system administrators) can view all
        // connections; no need to filter
        Collection<ActiveConnectionRecord> records = activeTunnels.values();
        if (user.isPrivileged())
            return records;

        // Build set of all connection identifiers associated with active tunnels
        Set<String> identifiers = new HashSet<>(records.size());
        for (ActiveConnectionRecord record : records)
            identifiers.add(record.getConnection().getIdentifier());

        // Simply return empty list if there are no active tunnels (note that
        // this check cannot be performed prior to building the set of
        // identifiers, as activeTunnels may be non-empty at the beginning of
        // the call to getActiveConnections() yet become empty before the
        // set of identifiers is built, resulting in an error within
        // selectReadable()
        if (identifiers.isEmpty())
            return Collections.<ActiveConnectionRecord>emptyList();

        // Produce collection of readable connection identifiers
        Collection<ConnectionModel> connections =
                connectionMapper.selectReadable(user.getUser().getModel(),
                        identifiers, user.getEffectiveUserGroups(),
                        environment.getCaseSensitivity());

        // Ensure set contains only identifiers of readable connections
        identifiers.clear();
        for (ConnectionModel connection : connections)
            identifiers.add(connection.getIdentifier());

        // Produce readable subset of records
        Collection<ActiveConnectionRecord> visibleRecords = new ArrayList<>(records.size());
        for (ActiveConnectionRecord record : records) {
            if (identifiers.contains(record.getConnection().getIdentifier()))
                visibleRecords.add(record);
        }

        return visibleRecords;

    }
Returns a list of all balanced connections within a given connection
group. If the connection group is not balancing, or it contains no
connections, an empty list is returned.

@param user
    The user on whose behalf the balanced connections within the given
    connection group are being retrieved.

@param connectionGroup
    The connection group to retrieve the balanced connections of.

@return
    A list containing all balanced connections within the given group,
    or an empty list if there are no such connections.
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/AbstractGuacamoleTunnelService.java