Hide a user key by turning it into a system key of type HIDDEN_USER_KEY
514278
final public static Key makeSystem(String s) {
    byte[] kb= decodeKeyName(s);
    byte[] kb2 = new byte[kb.length+1];
    System.arraycopy(kb,0,kb2,1,kb.length);
    kb2[0] = Key.BUILT_IN_KEY;
    return Key.make(kb2);
  }
1153086
def default_key_map
      tp = source
      source.bind_key(?\M-n.getbyte(0), 'goto_end'){ tp.goto_end } 
      source.bind_key(?\M-p.getbyte(0), 'goto_start'){ tp.goto_start } 
    end
144316
def _list_keys(user=None, gnupghome=None, secret=False):
    '''
    
    '''
    gpg = _create_gpg(user, gnupghome)
    _keys = gpg.list_keys(secret)
    return _keys
1157490
def disable_key(key_id, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    r = {}
    try:
        key = conn.disable_key(key_id)
        r['result'] = True
    except boto.exception.BotoServerError as e:
        r['result'] = False
        r['error'] = __utils__['boto.get_error'](e)
    return r
172471
def _replace_auth_key(
        user,
        key,
        enc='ssh-rsa',
        comment='',
        options=None,
        config='.ssh/authorized_keys'):
    '''
    
    '''

    auth_line = _format_auth_line(key, enc, comment, options or [])

    lines = []
    full = _get_config_file(user, config)

    try:
        # open the file for both reading AND writing
        with salt.utils.files.fopen(full, 'r') as _fh:
            for line in _fh:
                # We don't need any whitespace-only containing lines or arbitrary doubled newlines
                line = salt.utils.stringutils.to_unicode(line.strip())
                if line == '':
                    continue
                line += '\n'

                if line.startswith('#'):
                    # Commented Line
                    lines.append(line)
                    continue
                comps = re.findall(r'((.*)\s)?(ssh-[a-z0-9-]+|ecdsa-[a-z0-9-]+)\s([a-zA-Z0-9+/]+={0,2})(\s(.*))?', line)
                if comps and len(comps[0]) > 3 and comps[0][3] == key:
                    # Found our key, replace it
                    lines.append(auth_line)
                else:
                    lines.append(line)
            _fh.close()
            # Re-open the file writable after properly closing it
            with salt.utils.files.fopen(full, 'wb') as _fh:
                # Write out any changes
                _fh.writelines(salt.utils.data.encode(lines))
    except (IOError, OSError) as exc:
        raise CommandExecutionError(
            'Problem reading or writing to key file: {0}'.format(exc)
        )
847372
def part_key(exp, alt, date_hour=nil)
      parts = [ "participants", exp.name, alt ]
      parts += [ date_hour.date, date_hour.hour ] unless date_hour.nil?
      make_key parts
    end
545004
def getSecurityHkey(self, s):
        '''
        
        '''
        try:
            return self.hkeys_security[s]
        except KeyError:
            raise CommandExecutionError((
                'No HKEY named "{0}".  It should be one of the following:  {1}'
                ).format(s, ', '.join(self.hkeys_security)))
199032
private void removeOldSignedPreKeys(OmemoDevice userDevice) {
        if (OmemoConfiguration.getMaxNumberOfStoredSignedPreKeys() <= 0) {
            return;
        }

        TreeMap<Integer, T_SigPreKey> signedPreKeys = loadOmemoSignedPreKeys(userDevice);

        for (int i = 0; i < signedPreKeys.keySet().size() - OmemoConfiguration.getMaxNumberOfStoredSignedPreKeys(); i++) {
            int keyId = signedPreKeys.firstKey();
            LOGGER.log(Level.INFO, "Remove signedPreKey " + keyId + ".");
            removeOmemoSignedPreKey(userDevice, i);
            signedPreKeys = loadOmemoSignedPreKeys(userDevice);
        }
    }
1086360
private RSAPublicKey getKeyForUser(String userName) throws KeyNotFoundException {
    RSAPublicKey key = null;
    for (final KeyProvider keyProvider : keyProviders) {
      try {
        key = keyProvider.getKey(userName);
        break;
      } catch (KeyNotFoundException e) {
        // that's fine, try the next provider
      }
    }

    if (key == null) {
      throw new KeyNotFoundException();
    }

    return key;
  }
492701
def keypair_delete(name, profile=None, **kwargs):
    '''
    
    '''
    conn = _auth(profile, **kwargs)
    return conn.keypair_delete(name)
607816
def _private(self, command, **params):
        """"""
        if not self._apikey or not self._secret:
            raise PoloniexCredentialsException('missing apikey/secret')

        with self.nonce_lock:
            params.update({'command': command, 'nonce': next(self.nonce_iter)})
            response = self.session.post(
                self._private_url, data=params,
                auth=Poloniex._PoloniexAuth(self._apikey, self._secret))
            return response
317349
def _RemoveAuthorizedKeys(self, user):
    
    pw_entry = self._GetUser(user)
    if not pw_entry:
      return

    home_dir = pw_entry.pw_dir
    authorized_keys_file = os.path.join(home_dir, '.ssh', 'authorized_keys')
    if os.path.exists(authorized_keys_file):
      try:
        os.remove(authorized_keys_file)
      except OSError as e:
        message = 'Could not remove authorized keys for user %s. %s.'
        self.logger.warning(message, user, str(e))
465421
def remove_user_setting(self, section, name, save=False):
    '''
    '''
    configfile = get_configfile_user()
    return _remove_setting(section, name, configfile, save)
814474
def make_key(self, key, version=None):
        """"""
        return '{}:{}:{}'.format(
            self.prefix,
            version or self.version,
            key,
        )
388520
def keypairs(ctx, user_id, is_active):
    '''
    
    '''
    if ctx.invoked_subcommand is not None:
        return
    fields = [
        ('User ID', 'user_id'),
        ('Access Key', 'access_key'),
        ('Secret Key', 'secret_key'),
        ('Active?', 'is_active'),
        ('Admin?', 'is_admin'),
        ('Created At', 'created_at'),
        ('Last Used', 'last_used'),
        ('Res.Policy', 'resource_policy'),
        ('Rate Limit', 'rate_limit'),
        ('Concur.Limit', 'concurrency_limit'),
        ('Concur.Used', 'concurrency_used'),
    ]
    try:
        user_id = int(user_id)
    except (TypeError, ValueError):
        pass  # string-based user ID for Backend.AI v1.4+
    with Session() as session:
        try:
            items = session.KeyPair.list(user_id, is_active,
                                         fields=(item[1] for item in fields))
        except Exception as e:
            print_error(e)
            sys.exit(1)
        if len(items) == 0:
            print('There are no matching keypairs associated '
                  'with the user ID {0}'.format(user_id))
            return
        print(tabulate((item.values() for item in items),
                       headers=(item[0] for item in fields)))
432391
def reset_api_key(self, user=None):
        
        if user is None:
            user_id = utils.get_id(self)
        else:
            user_id = utils.get_id(user)
        uri = "users/%s/OS-KSADM/credentials/" % user_id
        uri += "RAX-KSKEY:apiKeyCredentials/RAX-AUTH/reset"
        resp, resp_body = self.method_post(uri)
        return resp_body.get("RAX-KSKEY:apiKeyCredentials", {}).get("apiKey")
1151699
def chain_user_names(users, exclude_user, truncate=35):
    """"""
    if not users or not isinstance(exclude_user, get_user_model()):
        return ''
    return truncatechars(
        ', '.join(u'{}'.format(u) for u in users.exclude(pk=exclude_user.pk)),
        truncate)