server/src/main/java/com/orientechnologies/orient/server/OClientConnectionManager.java
public OClientConnection connect(final ONetworkProtocol iProtocol, final OClientConnection connection, final byte[] tokenBytes,
      final OTokenHandler handler) {

    final OToken token;
    try {
      token = handler.parseBinaryToken(tokenBytes);
    } catch (Exception e) {
      throw OException.wrapException(new OTokenSecurityException("Error on token parsing"), e);
    }
    OClientSessions session;
    synchronized (sessions) {
      session = new OClientSessions(tokenBytes, token);
      sessions.put(new OHashToken(tokenBytes), session);
    }
    connection.setTokenBytes(tokenBytes);
    connection.setTokenBased(true);
    connection.setToken(token);
    session.addConnection(connection);
    OLogManager.instance().config(this, "Remote client connected from: " + connection);
    OServerPluginHelper.invokeHandlerCallbackOnClientConnection(iProtocol.getServer(), connection);
    return connection;
  }
public OClientConnection connect(final ONetworkProtocol iProtocol, final OClientConnection connection, final byte[] tokenBytes,
      final OTokenHandler handler) {

    final OToken token;
    try {
      token = handler.parseBinaryToken(tokenBytes);
    } catch (Exception e) {
      throw OException.wrapException(new OTokenSecurityException("Error on token parsing"), e);
    }
    OClientSessions session;
    synchronized (sessions) {
      session = new OClientSessions(tokenBytes, token);
      sessions.put(new OHashToken(tokenBytes), session);
    }
    connection.setTokenBytes(tokenBytes);
    connection.setTokenBased(true);
    connection.setToken(token);
    session.addConnection(connection);
    OLogManager.instance().config(this, "Remote client connected from: " + connection);
    OServerPluginHelper.invokeHandlerCallbackOnClientConnection(iProtocol.getServer(), connection);
    return connection;
  }
Create a connection.

@param iProtocol protocol which will be used by connection

@return new connection