Authorize device synchronization.
189045
def auth(**kwargs):
  '''  '''

  """
    kodrive auth <path> <device_id (client)>

    1. make sure path has been added to config.xml, server
    2. make sure path is not shared by someone
    3. add device_id to folder in config.xml, server
    4. add device to devices in config.xml, server

  """

  option = 'add'
  path = kwargs['path'] 
  key = kwargs['key']

  if kwargs['remove']:
    option = 'remove'

  if kwargs['yes']:
    output, err = cli_syncthing_adapter.auth(option, key, path)
    click.echo("%s" % output, err=err)
  else:
    verb = 'authorize' if not kwargs['remove'] else 'de-authorize'
    if click.confirm("Are you sure you want to %s this device to access %s?" % (verb, path)):
      output, err = cli_syncthing_adapter.auth(option, key, path)

      if output:
        click.echo("%s" % output, err=err)
632271
def async_new_device_callback(self, device):
        """"""
        _LOGGING.info(
            'New Device: %s cat: 0x%02x subcat: 0x%02x desc: %s, model: %s',
            device.id, device.cat, device.subcat,
            device.description, device.model)
        for state in device.states:
            device.states[state].register_updates(
                self.async_state_change_callback)
874221
def activate(self):
        
        response = self.api_interface.set_device_state(self, None)
        self._update_state_from_response(response)
1041774
def sync(self):
        """"""
        if self.writeback and self.cache:
            super(_TimeoutMixin, self).__delitem__(self._INDEX)
            super(_TimeoutMixin, self).sync()
            self.writeback = False
            super(_TimeoutMixin, self).__setitem__(self._INDEX, self._index)
            self.writeback = True
        if hasattr(self.dict, 'sync'):
            self.dict.sync()
1181804
def sync_connect(self):
        """"""
        loop = asyncio.get_event_loop()
        task = loop.create_task(self.connect())
        loop.run_until_complete(task)
79815
def _dedicate_device(self, userid, vaddr, raddr, mode):
        """"""
        action = 'dedicate'
        rd = ('changevm %(uid)s %(act)s %(va)s %(ra)s %(mod)i' %
              {'uid': userid, 'act': action,
               'va': vaddr, 'ra': raddr, 'mod': mode})
        action = "dedicate device to userid '%s'" % userid
        with zvmutils.log_and_reraise_smt_request_failed(action):
            self._request(rd)
1109062
def enable(self, enable_password):
        """"""
        if self.device.prompt[-1] == '#':
            self.log("Device is already in privileged mode")
            return

        events = [self.password_re, self.device.prompt_re, pexpect.TIMEOUT, pexpect.EOF]
        transitions = [
            (self.password_re, [0], 1, partial(a_send_password, enable_password), 10),
            (self.password_re, [1], -1, ConnectionAuthenticationError("Incorrect enable password",
                                                                      self.device.hostname), 0),
            (self.device.prompt_re, [0, 1, 2, 3], -1, a_expected_prompt, 0),
            (pexpect.TIMEOUT, [0, 1, 2], -1, ConnectionAuthenticationError("Unable to get privileged mode",
                                                                           self.device.hostname), 0),
            (pexpect.EOF, [0, 1, 2], -1, ConnectionError("Device disconnected"), 0)
        ]
        self.device.ctrl.send_command(self.enable_cmd)
        fsm = FSM("IOS-ENABLE", self.device, events, transitions, timeout=10, max_transitions=5)
        fsm.run()
        if self.device.prompt[-1] != '#':
            raise ConnectionAuthenticationError("Privileged mode not set", self.device.hostname)
884004
async def start_authentication(self):
        
        _, code = await self.http.post_data(
            'pair-pin-start', headers=_AIRPLAY_HEADERS)
        if code != 200:
            raise DeviceAuthenticationError('pair start failed')
1328238
def sync_in(self, release):
        """"""
        tree = release['canonical_dir']
        if os.path.exists(tree) and release.get('rsync_in_objs'):
            out = release['output_dir']
            if not os.path.isdir(out):
                self.log.info('Creating %s', out)
                os.makedirs(out)
            self.call(release['rsync_in_objs'])
            self.call(release['rsync_in_rest'])
1092139
def connect(self, addr):
        """"""
        if _debug: DeviceToDeviceClientService._debug("connect %r", addr)

        # make a connection
        conn = ConnectionState(addr)
        self.multiplexer.connections[addr] = conn

        # associate with this service, but it is not connected until the ack comes back
        conn.service = self

        # keep a list of pending NPDU objects until the ack comes back
        conn.pendingNPDU = []

        # build a service request
        request = ServiceRequest(DEVICE_TO_DEVICE_SERVICE_ID)
        request.pduDestination = addr

        # send it
        self.service_request(request)

        # return the connection object
        return conn
995551
def _on_device_update(self, devid):
        """"""
        if isinstance(devid, (tuple, list)):
            devid = devid[0]

        if devid is None:
            _LOGGER.warning("Device update with no device id.")
            return

        _LOGGER.debug("Device update event for device ID: %s", devid)

        device = self._abode.get_device(devid, True)

        if not device:
            _LOGGER.debug("Got device update for unknown device: %s", devid)
            return

        for callback in self._device_callbacks.get(device.device_id, ()):
            _execute_callback(callback, device)
961034
def lock(self):
        """"""
        endpoint = API_SESAME_CONTROL_ENDPOINT.format(self.device_id)
        payload = {'type': 'lock'}
        response = self.account.request('POST', endpoint, payload=payload)
        if response is None:
            return False
        if response.status_code == 200 or response.status_code == 204:
            return True
        return False
610445
def _sync_to_group(self, device):
        '''
        '''

        config_sync_cmd = 'config-sync to-group %s' % self.name
        device.tm.cm.exec_cmd('run', utilCmdArgs=config_sync_cmd)
929392
def sync_auth(self, vault_client, resources):
        """"""
        for auth in self.auths():
            auth.sync(vault_client)

        auth_resources = [x for x in resources
                          if isinstance(x, (LDAP, UserPass))]
        for resource in auth_resources:
            resource.sync(vault_client)

        return [x for x in resources
                if not isinstance(x, (LDAP, UserPass, AuditLog))]
550922
private synchronized void synchronize() {
		personEmail = conversation.getPerson().getEmail();
		personName = conversation.getPerson().getName();
		messageCenterPendingMessage = conversation.getMessageCenterPendingMessage();
		messageCenterPendingAttachments = conversation.getMessageCenterPendingAttachments();
		hasActiveState = conversation.hasActiveState();
		messageCenterWhoCardPreviouslyDisplayed = conversation.isMessageCenterWhoCardPreviouslyDisplayed();
		unreadMessageCount = conversation.getMessageManager().getUnreadMessageCount();
	}
651244
def deactivate_mfa_device(self, user_name, serial_number):
        """"""
        user = self.get_user(user_name)
        if serial_number not in user.mfa_devices:
            raise IAMNotFoundException(
                "Device {0} not found".format(serial_number)
            )

        user.deactivate_mfa_device(serial_number)
591052
def authenticate(self, driver):
        """"""
        #                      0                      1                    2                    3
        events = [driver.username_re, driver.password_re, self.device.prompt_re, driver.rommon_re,
                  #       4             5                   6                       7                8
                  driver.unable_to_connect_re, driver.authentication_error_re, pexpect.TIMEOUT, pexpect.EOF]

        transitions = [
            (driver.username_re, [0], 1, partial(a_send_username, self.username), 10),
            (driver.username_re, [1], 1, None, 10),
            (driver.password_re, [0, 1], 2, partial(a_send_password, self._acquire_password()),
             _C['first_prompt_timeout']),
            (driver.username_re, [2], -1, a_authentication_error, 0),
            (driver.password_re, [2], -1, a_authentication_error, 0),
            (driver.authentication_error_re, [1, 2], -1, a_authentication_error, 0),
            (self.device.prompt_re, [0, 1, 2], -1, None, 0),
            (driver.rommon_re, [0], -1, partial(a_send, "\r\n"), 0),
            (pexpect.TIMEOUT, [0], 1, partial(a_send, "\r\n"), 10),
            (pexpect.TIMEOUT, [2], -1, None, 0),
            (pexpect.TIMEOUT, [3, 7], -1, ConnectionTimeoutError("Connection Timeout", self.hostname), 0),
            (driver.unable_to_connect_re, [0, 1, 2], -1, a_unable_to_connect, 0),
        ]
        self.log("EXPECTED_PROMPT={}".format(pattern_to_str(self.device.prompt_re)))
        fsm = FSM("CONSOLE-SERVER-AUTH", self.device, events, transitions, timeout=_C['connect_timeout'],
                  init_pattern=self.last_pattern)
        return fsm.run()