STOMP connect command.

    username, password:
        These are the needed auth details to connect to the
        message server.

    After sending this we will receive a CONNECTED
    message which will contain our session id.
15290
def connect(username, password, host, heartbeats=(0,0)):
    
    if len(heartbeats) != 2:
        raise ValueError('Invalid heartbeat %r' % heartbeats)
    cx, cy = heartbeats
    return "CONNECT\naccept-version:1.1\nhost:%s\nheart-beat:%i,%i\nlogin:%s\npasscode:%s\n\n\x00\n" % (host, cx, cy, username, password)
1351909
def login(self, username, password):
        
        d = self.send_command('login', keys={'client_login_name': username, 'client_login_password': password})
        if d == 0:
            self._log.info('Login Successful')
            return True
        return False
625521
def get_connection(hostname, username, logger, threads=5, use_sudo=None, detect_sudo=True):
    
    if username:
        hostname = "%s@%s" % (username, hostname)
    try:
        conn = remoto.Connection(
            hostname,
            logger=logger,
            threads=threads,
            detect_sudo=detect_sudo,
        )

        # Set a timeout value in seconds to disconnect and move on
        # if no data is sent back.
        conn.global_timeout = 300
        logger.debug("connected to host: %s " % hostname)
        return conn

    except Exception as error:
        msg = "connecting to host: %s " % hostname
        errors = "resulted in errors: %s %s" % (error.__class__.__name__, error)
        raise RuntimeError(msg + errors)
1223067
function basicLogin(sock, data, cb) {
  if (data && _.isString(data.username) && !_.isEmpty(data.username)) {
    cb && cb(null, data.username);
  } else {
    cb && cb('invalid identifier ' + data);
  }
}
783929
def get_normal_connection(config):
    
    if config.username and config.password:
        log.debug("connecting with username and password")
        queue_manager = pymqi.connect(
            config.queue_manager_name, config.channel, config.host_and_port, config.username, config.password
        )
    else:
        log.debug("connecting without a username and password")
        queue_manager = pymqi.connect(config.queue_manager_name, config.channel, config.host_and_port)

    return queue_manager
116224
async def connect(self):
        
        await self._sender.connect(self._connection(
            self.session.server_address,
            self.session.port,
            self.session.dc_id,
            loop=self._loop,
            loggers=self._log,
            proxy=self._proxy
        ))
        self.session.auth_key = self._sender.auth_key
        self.session.save()

        await self._sender.send(self._init_with(
            functions.help.GetConfigRequest()))

        self._updates_handle = self._loop.create_task(self._update_loop())
969291
def _connect_mitogen_sudo(spec):
    
    return {
        'method': 'sudo',
        'kwargs': {
            'username': spec.remote_user(),
            'password': spec.password(),
            'python_path': spec.python_path(),
            'sudo_path': spec.become_exe(),
            'connect_timeout': spec.timeout(),
            'sudo_args': spec.sudo_args(),
            'remote_name': get_remote_name(spec),
        }
    }
408400
def connect(self, *args, auto_reconnect=False, **kwargs):
        
        connection_info = {
            'auto_reconnect': auto_reconnect,
            'args': args,
            'kwargs': kwargs,
        }
        self.connect_info['connection'] = connection_info

        # confirm we have user info set
        if 'user' not in self.connect_info:
            raise Exception('`set_user_info` must be called before connecting to server.')

        # create connection and run
        connection = loop.create_connection(lambda: self,
                                            *args, **kwargs)
        asyncio.Task(connection)
18470
def main():
    

    if len(sys.argv) < 6:
        print("Usage: %s server_url username password namespace' \
              ' classname" %  sys.argv[0])
        print('Using internal defaults')
        server_url = SERVER_URL
        namespace = TEST_NAMESPACE
        username = USERNAME
        password = PASSWORD
        classname = TEST_CLASS
    else:
        print('Get from input')
        server_url = sys.argv[1]
        namespace = sys.argv[2]
        username = sys.argv[3]
        password = sys.argv[4]
        classname = sys.argv[5]

    # create the credentials tuple for WBEMConnection
    creds = (username, password)

    # call the method to execute the request and display results
    execute_request(server_url, creds, namespace, classname)

    return 0
1163288
public void connect(String username, char[] password) {
        doConnect(() -> {
            return CommandContextFactory.getInstance().
                    newCommandContext(new CommandContextConfiguration.Builder()
                    .setUsername(username)
                    .setPassword(password)
                    .setErrorOnInteract(false)
                    .build());
        });
    }
1374754
public static void main(String[] args) {
		if (args.length < 2) {
			System.err.println("Two arguments needed as username and password");
			System.exit(-1);
		}
		User user = new User();
		user.name = args[0];
		user.password.setPassword(args[1].toCharArray());
		for (int i = 2; i<args.length; i++) {
			user.roles.add(new UserRole(args[i].trim()));
		}
		System.out.println(user.format());
	}
619781
def _determine_username(self, ip):
        """"""
        ssh = subprocess.Popen([
            "ssh",
            "-o", "UserKnownHostsFile=/dev/null",
            "-o", "StrictHostKeyChecking=no",
            "root@%s" % ip],
            stdin=subprocess.DEVNULL,
            stdout=subprocess.PIPE,
            stderr=subprocess.DEVNULL)
        first_line = ssh.stdout.readline()
        ssh.kill()
        ssh.wait()
        if first_line:
            match = re.search(
                r"Please login as the user \"(\w+)\" rather than "
                r"the user \"root\".", first_line.decode('utf-8'))
            if match:
                return match.groups()[0]
        else:
            return None
632787
def cmd_pass(param)
      send_response "202 User already logged in" and return unless @user.nil?
      send_param_required and return if param.nil?
      send_response "530 password with no username" and return if @requested_user.nil?

      # return an error message if:
      #  - the specified username isn't in our system
      #  - the password is wrong

      @driver.authenticate(@requested_user, param) do |result|
        if result
          @name_prefix = "/"
          @user = @requested_user
          @requested_user = nil
          send_response "230 OK, password correct"
        else
          @user = nil
          send_response "530 incorrect login. not logged in."
        end
      end
    end
695374
async def connect(self):
        
        request = stun.Message(message_method=stun.Method.ALLOCATE,
                               message_class=stun.Class.REQUEST)
        request.attributes['LIFETIME'] = self.lifetime
        request.attributes['REQUESTED-TRANSPORT'] = UDP_TRANSPORT

        try:
            response, _ = await self.request(request)
        except exceptions.TransactionFailed as e:
            response = e.response
            if response.attributes['ERROR-CODE'][0] == 401:
                # update long-term credentials
                self.nonce = response.attributes['NONCE']
                self.realm = response.attributes['REALM']
                self.integrity_key = make_integrity_key(self.username, self.realm, self.password)

                # retry request with authentication
                request.transaction_id = random_transaction_id()
                response, _ = await self.request(request)

        self.relayed_address = response.attributes['XOR-RELAYED-ADDRESS']
        logger.info('TURN allocation created %s', self.relayed_address)

        # periodically refresh allocation
        self.refresh_handle = asyncio.ensure_future(self.refresh())

        return self.relayed_address
863975
def _connect(self):
        
        self.conn = self._create_connection()
        spawn(self.conn.connect)
        self.set_nick(self.nick)
        self.cmd(u'USER', u'{0} 3 * {1}'.format(self.nick, self.realname))
743174
def connect(self):
        
        if self.r_session:
            self.session_logout()

        if self.admin_party:
            self._use_iam = False
            self.r_session = ClientSession(
                timeout=self._timeout
            )
        elif self._use_basic_auth:
            self._use_iam = False
            self.r_session = BasicSession(
                self._user,
                self._auth_token,
                self.server_url,
                timeout=self._timeout
            )
        elif self._use_iam:
            self.r_session = IAMSession(
                self._auth_token,
                self.server_url,
                auto_renew=self._auto_renew,
                client_id=self._iam_client_id,
                client_secret=self._iam_client_secret,
                timeout=self._timeout
            )
        else:
            self.r_session = CookieSession(
                self._user,
                self._auth_token,
                self.server_url,
                auto_renew=self._auto_renew,
                timeout=self._timeout
            )

        # If a Transport Adapter was supplied add it to the session
        if self.adapter is not None:
            self.r_session.mount(self.server_url, self.adapter)
        if self._client_user_header is not None:
            self.r_session.headers.update(self._client_user_header)

        self.session_login()

        # Utilize an event hook to append to the response message
        # using :func:`~cloudant.common_util.append_response_error_content`
        self.r_session.hooks['response'].append(append_response_error_content)
1238866
def _connect(self):
        

        self.first_data_sent_complete = False
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.socket.connect((self.host, self.port))

        msg = cr.Message()
        msg.type = cr.CONNECT
        msg.request_connect.auth_code = self.auth_code or 0
        msg.request_connect.send_playlist_songs = False
        msg.request_connect.downloader = False

        self.send_message(msg)