code: public GuacamoleTunnel createTunnel(TunnelRequest request)
              throws GuacamoleException {
  
          // Parse request parameters
          String authToken                = request.getAuthenticationToken();
          String id                       = request.getIdentifier();
          TunnelRequest.Type type         = request.getType();
          String authProviderIdentifier   = request.getAuthenticationProviderIdentifier();
          GuacamoleClientInformation info = getClientInformation(request);
  
          GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
          AuthenticatedUser authenticatedUser = session.getAuthenticatedUser();
          UserContext userContext = session.getUserContext(authProviderIdentifier);
  
          try {
  
              // Create connected tunnel using provided connection ID and client information
              GuacamoleTunnel tunnel = createConnectedTunnel(userContext, type,
                      id, info, new StandardTokenMap(authenticatedUser));
  
              // Notify listeners to allow connection to be vetoed
              fireTunnelConnectEvent(authenticatedUser, authenticatedUser.getCredentials(), tunnel);
  
              // Associate tunnel with session
              return createAssociatedTunnel(tunnel, authToken, session, userContext, type, id);
  
          }
  
          // Ensure any associated session is invalidated if unauthorized
          catch (GuacamoleUnauthorizedException e) {
  
              // If there is an associated auth token, invalidate it
              if (authenticationService.destroyGuacamoleSession(authToken))
                  logger.debug("Implicitly invalidated session for token \"{}\".", authToken);
  
              // Continue with exception processing
              throw e;
  
          }
  
      }
docs: Creates a new tunnel using the parameters and credentials present in
  the given request.
  
  @param request
  The request describing the tunnel to create.
  
  @return
  The created tunnel, or null if the tunnel could not be created.
  
  @throws GuacamoleException
  If an error occurs while creating the tunnel.