protected GuacamoleTunnel createConnectedTunnel(UserContext context,
            final TunnelRequestType type, String id,
            GuacamoleClientInformation info, Map<String, String> tokens)
            throws GuacamoleException {

        // Retrieve requested destination object
        Connectable connectable = type.getConnectable(context, id);
        if (connectable == null)
            throw new GuacamoleResourceNotFoundException("Requested tunnel "
                    + "destination does not exist.");

        // Connect tunnel to destination
        GuacamoleTunnel tunnel = connectable.connect(info, tokens);
        logger.info("User \"{}\" connected to {} \"{}\".",
                context.self().getIdentifier(), type.NAME, id);
        return tunnel;

    }
Creates a new tunnel using which is connected to the connection or
connection group identifier by the given ID. Client information
is specified in the {@code info} parameter.

@param context
    The UserContext associated with the user for whom the tunnel is
    being created.

@param type
    The type of object being connected to (connection or group).

@param id
    The id of the connection or group being connected to.

@param info
    Information describing the connected Guacamole client.

@param tokens
    A Map containing the token names and corresponding values to be
    applied as parameter tokens when establishing the connection.

@return
    A new tunnel, connected as required by the request.

@throws GuacamoleException
    If an error occurs while creating the tunnel.
guacamole/src/main/java/org/apache/guacamole/tunnel/TunnelRequestService.java