[START kms_get_keyring_policy]
557632
async function getKeyRingIamPolicy(
  projectId = 'your-project-id', // Your GCP projectId
  keyRingId = 'my-key-ring' // Name of the crypto key's key ring
) {
  // Import the library and create a client
  const kms = require('@google-cloud/kms');
  const client = new kms.KeyManagementServiceClient();

  // The location of the key ring, e.g. "global"
  const locationId = 'global';

  // Get the full path to the keyring
  const resource = client.keyRingPath(projectId, locationId, keyRingId);

  // Gets the IAM policy of a key ring
  const [policy] = await client.getIamPolicy({resource});
  if (policy.bindings && policy.bindings.length > 0) {
    policy.bindings.forEach(binding => {
      if (binding.members && binding.members.length) {
        console.log(`${binding.role}:`);
        binding.members.forEach(member => {
          console.log(`  ${member}`);
        });
      }
    });
  } else {
    console.log(`Policy for key ring ${keyRingId} is empty.`);
  }
}
1327964
def keyring_update(cid, **kwargs):
    
    ctx = Context(**kwargs)
    ctx.execute_action('keyring:update', **{
        'tvm': ctx.repo.create_secure_service('tvm'),
        'cid': cid,
    })
580386
def connection_key(self):
        
        return "{host}:{namespace}:{username}".format(host=self.host, namespace=self.namespace, username=self.username)
1265260
def keypair():
    '''
    
    '''
    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'),
    ]
    with Session() as session:
        try:
            kp = session.KeyPair(session.config.access_key)
            info = kp.info(fields=(item[1] for item in fields))
        except Exception as e:
            print_error(e)
            sys.exit(1)
        rows = []
        for name, key in fields:
            rows.append((name, info[key]))
        print(tabulate(rows, headers=('Field', 'Value')))
456322
def default_kms_key_name(self, value):
        
        encryption_config = self._properties.get("encryption", {})
        encryption_config["defaultKmsKeyName"] = value
        self._patch_property("encryption", encryption_config)
810689
def my_pick_non_system_keyspace(self):
        
        d = self.my_describe_keyspaces()

        def pick_non_system(klist):
            for k in klist:
                if k.name not in SYSTEM_KEYSPACES:
                    return k.name
            err = NoKeyspacesAvailable("Can't gather information about the "
                                       "Cassandra ring; no non-system "
                                       "keyspaces available")
            warn(err)
            raise err
        d.addCallback(pick_non_system)
        return d
1040537
def get_key(cls, k, default=None):
        
        k = cls.__name__ + "__" + k
        if k in session:
            return session[k]
        else:
            return default
595312
def get_kerberos_ticket(username, password):
        

        cache = "/tmp/ion-%s" % uuid.uuid4()

        logger.debug("Setting KRB5CCNAME to 'FILE:{}'".format(cache))
        os.environ["KRB5CCNAME"] = "FILE:" + cache

        try:
            realm = settings.CSL_REALM
            kinit = pexpect.spawnu("/usr/bin/kinit {}@{}".format(username, realm), timeout=settings.KINIT_TIMEOUT)
            kinit.expect(":")
            kinit.sendline(password)
            returned = kinit.expect([pexpect.EOF, "password:"])
            if returned == 1:
                logger.debug("Password for {}@{} expired, needs reset".format(username, realm))
                return "reset"
            kinit.close()
            exitstatus = kinit.exitstatus
        except pexpect.TIMEOUT:
            KerberosAuthenticationBackend.kinit_timeout_handle(username, realm)
            exitstatus = 1

        if exitstatus != 0:
            try:
                realm = settings.AD_REALM
                kinit = pexpect.spawnu("/usr/bin/kinit {}@{}".format(username, realm), timeout=settings.KINIT_TIMEOUT)
                kinit.expect(":")
                kinit.sendline(password)
                returned = kinit.expect([pexpect.EOF, "password:"])
                if returned == 1:
                    return False
                kinit.close()
                exitstatus = kinit.exitstatus
            except pexpect.TIMEOUT:
                KerberosAuthenticationBackend.kinit_timeout_handle(username, realm)
                exitstatus = 1

        if "KRB5CCNAME" in os.environ:
            subprocess.check_call(['kdestroy', '-c', os.environ["KRB5CCNAME"]])
            del os.environ["KRB5CCNAME"]

        if exitstatus == 0:
            logger.debug("Kerberos authorized {}@{}".format(username, realm))
            return True
        else:
            logger.debug("Kerberos failed to authorize {}".format(username))
            return False
1049252
def set_key_startswith(self, key_startswith):
        
        is_non_empty_string(key_startswith)

        self.policies.append(('starts-with', '$key', key_startswith))
        self.form_data['key'] = key_startswith
1261515
def get_key_rotation_status(key_id, region=None, key=None, keyid=None,
                            profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    r = {}
    try:
        key_rotation_status = conn.get_key_rotation_status(key_id)
        r['result'] = key_rotation_status['KeyRotationEnabled']
    except boto.exception.BotoServerError as e:
        r['error'] = __utils__['boto.get_error'](e)
    return r
166022
def _parse_kexgss_hostkey(self, m):
        
        # client mode
        host_key = m.get_string()
        self.transport.host_key = host_key
        sig = m.get_string()
        self.transport._verify_key(host_key, sig)
        self.transport._expect_packet(MSG_KEXGSS_CONTINUE, MSG_KEXGSS_COMPLETE)
911049
def _cfg(key, default=None):
    '''
    
    '''
    root_cfg = __salt__.get('config.get', __opts__.get)
    kms_cfg = root_cfg('aws_kms', {})
    return kms_cfg.get(key, default)
203027
def _load_password_from_keyring(self):
        
        try:
            keyring = __import__('keyring')
            return keyring.get_password(self.repository, self.username)
        except Exception:
            pass
1259873
def get_keypair_fn():
  """"""

  keypair_name = get_keypair_name()
  account = get_account_number()
  region = get_region()
  fn = f'{PRIVATE_KEY_LOCATION}/{keypair_name}-{account}-{region}.pem'
  return fn
833635
def get_human_key(self, key):
        """"""
        for human_key, k in self._identifier_map.items():
            if k == key:
                return human_key
        raise KeyError(key)
981993
def key_usage(self):
        """"""
        try:
            ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.KEY_USAGE)
        except x509.ExtensionNotFound:
            return None
        return KeyUsage(ext)
1016173
function getKeyStrokeString(ev) {
    var keys = [];

    if (ev.ctrlKey || ev.metaKey) {
        keys.push('ctrl');
    }
    if (ev.shiftKey) {
        keys.push('shift');
    }
    keys.push(keyNameMap[ev.keyCode]);

    return keys.join('-');
}