public ActiveConnection getActiveConnection() throws GuacamoleException {

        // Pull the UUID of the current tunnel
        UUID uuid = getUUID();

        // Get the directory of active connections
        Directory<ActiveConnection> activeConnectionDirectory = userContext.getActiveConnectionDirectory();
        Collection<String> activeConnectionIdentifiers = activeConnectionDirectory.getIdentifiers();

        // Search all connections for a tunnel which matches this tunnel
        for (ActiveConnection activeConnection : activeConnectionDirectory.getAll(activeConnectionIdentifiers)) {

            // If we lack access, continue with next tunnel
            GuacamoleTunnel tunnel = activeConnection.getTunnel();
            if (tunnel == null)
                continue;

            // Tunnels are equivalent if they have the same UUID
            if (uuid.equals(tunnel.getUUID()))
                return activeConnection;

        }

        // No active connection associated with this tunnel
        return null;

    }
Returns the ActiveConnection object associated with this tunnel within
the AuthenticationProvider and UserContext which created the tunnel. If
the AuthenticationProvider is not tracking active connections, or this
tunnel is no longer active, this will be null.

@return
    The ActiveConnection object associated with this tunnel, or null if
    this tunnel is no longer active or the AuthenticationProvider which
    created the tunnel is not tracking active connections.

@throws GuacamoleException
    If an error occurs which prevents retrieval of the user's current
    active connections.
guacamole/src/main/java/org/apache/guacamole/tunnel/UserTunnel.java