https://developer.zendesk.com/rest_api/docs/core/user_identities#make-identity-primary
971880
def user_identity_make_primary(self, user_id, id, data, **kwargs):
        ""
        api_path = "/api/v2/users/{user_id}/identities/{id}/make_primary"
        api_path = api_path.format(user_id=user_id, id=id)
        return self.call(api_path, method="PUT", data=data, **kwargs)
133412
def identity
      SingletonRelationProxy.new(self, Layer::Identity) do
        def from_response(response, client)
          response['url'] ||= "#{base.url}#{resource_type.url}"
          super
        end

        def create(attributes, client = self.client)
          client.post(url, attributes)
          fetch
        end

        def delete(client = self.client)
          client.delete(url)
        end
      end
    end
891605
def user_create(name, password, email, tenant_id=None,
                enabled=True, profile=None, project_id=None, description=None, **connection_args):
    '''
    
    '''
    kstone = auth(profile, **connection_args)

    if _OS_IDENTITY_API_VERSION > 2:
        if tenant_id and not project_id:
            project_id = tenant_id
        item = kstone.users.create(name=name,
                                   password=password,
                                   email=email,
                                   project_id=project_id,
                                   enabled=enabled,
                                   description=description)
    else:
        item = kstone.users.create(name=name,
                                   password=password,
                                   email=email,
                                   tenant_id=tenant_id,
                                   enabled=enabled)
    return user_get(item.id, profile=profile, **connection_args)
430124
function createCainiaoEntity(id, json) {

    let section = json.data[0].section3 || json.data[0].section2;
    let msgs = section.detailList.map(m => {
        return {
            state: fixStateName(m.desc),
            date: moment.tz(m.time, "YYYY-MM-DD HH:mm:ss", zone).format()
        }
    })

    let destinyId = json.data[0].section2.mailNo || null

    return new CainiaoInfo(id, msgs, destinyId)
}
892042
def create_api_v4_as(self):
        """"""
        return ApiV4As(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
333003
function primaryTopic(store, uri) {
  var ret
  var pred

  var FOAF = $rdf.Namespace("http://xmlns.com/foaf/0.1/")

  var ret = store.any($rdf.sym(uri), FOAF('primaryTopic'), null, $rdf.sym(uri))

  if (!ret) {
    var sub = $rdf.sym(uri + '#this')
    pred = store.any(sub, null, null, $rdf.sym(uri))
    if (pred) {
      ret = sub.uri
    }
  } else {
    ret = ret.uri
  }

  return ret
}
572161
def _gen_identity(self, key, param=None):
        """"""
        if self.identity_generator and param is not None:
            if self.serializer:
                param = self.serializer.serialize(param)
            if self.compressor:
                param = self.compressor.compress(param)
            identity = self.identity_generator.generate(key, param)
        else:
            identity = key
        return identity
577666
def create_identity(self, user, sp_mapping, **extra_config):
        

        return {
            out_attr: getattr(user, user_attr)
            for user_attr, out_attr in sp_mapping.items()
            if hasattr(user, user_attr)
        }
158407
def create_authorizer(self, restapi, uri, authorizer):
        
        authorizer_type = authorizer.get("type", "TOKEN").upper()
        identity_validation_expression = authorizer.get('validation_expression', None)

        authorizer_resource = troposphere.apigateway.Authorizer("Authorizer")
        authorizer_resource.RestApiId = troposphere.Ref(restapi)
        authorizer_resource.Name = authorizer.get("name", "ZappaAuthorizer")
        authorizer_resource.Type = authorizer_type
        authorizer_resource.AuthorizerUri = uri
        authorizer_resource.IdentitySource = "method.request.header.%s" % authorizer.get('token_header', 'Authorization')
        if identity_validation_expression:
            authorizer_resource.IdentityValidationExpression = identity_validation_expression

        if authorizer_type == 'TOKEN':
            if not self.credentials_arn:
                self.get_credentials_arn()
            authorizer_resource.AuthorizerResultTtlInSeconds = authorizer.get('result_ttl', 300)
            authorizer_resource.AuthorizerCredentials = self.credentials_arn
        if authorizer_type == 'COGNITO_USER_POOLS':
            authorizer_resource.ProviderARNs = authorizer.get('provider_arns')

        self.cf_api_resources.append(authorizer_resource.title)
        self.cf_template.add_resource(authorizer_resource)

        return authorizer_resource
1356763
def show(self, user, identity):
        
        url = self._build_url(self.endpoint.show(user, identity))
        return self._get(url)
1048549
async def create_email_identity(self, 
            client_id, identity, passwd, *, 
            user_id=None # 如果设置用户ID，则创建该用户的新登录身份
        ) -> SessionIdentity :
        
        
        assert passwd

        value, _ = await self._client.get(f"/users/identity/{identity}")
        if value:
            raise ValueError(f' {identity} has already been registered')

        if user_id is None: # 新用户
            user_id = await self._user_id_generator.new()

        # 加密登录标识
        hashed = sha256_crypt.using(rounds=2000, salt_size=8).hash(passwd)

        profile = {
            "user_id": user_id,
            "identity": identity,
            "hashed": hashed
        }

        token = genword(length=32, charset="ascii_50")
        key = f"/users/verifying/{token}"

        await self._client.put(key, json.dumps(profile))

        return SessionIdentity(user_id=user_id, identity=identity)
1087009
function wrap(api) {

var libs = {};

// constants
var IDENTITY_CONTEXT_URL = 'https://w3id.org/identity/v1';
var IDENTITY_FRAME = {
  '@context': IDENTITY_CONTEXT_URL,
  type: 'Identity'
};

/**
 * Allows injectables to be set or retrieved.
 *
 * @param name the name of the injectable to use (
 *          eg: `jsonld`, `jsonld-signatures`).
 * @param [injectable] the api to set for the injectable, only present for setter,
 *          omit for getter.
 * @param [options] the options to use:
 *          [configure] by default, this library will auto-configure certain
 *            passed injectables (eg: jsonld) to enable features like DID-based
 *            URL resolution; to disable this feature, set `configure` to false.
 *
 * @return the API for `name` if not using this method as a setter, otherwise
 *   undefined.
 */
api.use = function(name, injectable, options) {
  options = options || {};

  // initialize lib entry
  if(!libs[name]) {
    libs[name] = {
      api: null,
      // if `options.configure` is false, set lib as already configured
      // otherwise set as unconfigured and configure on first use later
      configured: ('configure' in options ? !options.configure : false)
    };
  }

  // setter mode
  if(injectable) {
    libs[name].api = injectable;
    return;
  }

  // getter mode:

  // api not yet set, load default
  if(!libs[name].api) {
    libs[name].api = require(name);
    if(name === 'jsonld') {
      // locally configure jsonld
      // Note: this configuration is necessary as a basic setup of `jsonld`
      // in a secure mode, it is not the same as later configuration required
      // for use by this library
      libs[name].api = libs[name].api();
      libs[name].api.useDocumentLoader('node', {secure: true, strictSSL: true});
    }
  }

  // ensure api is configured before returning it
  if(!libs[name].configured) {
    // mark library as configured immediately to avoid circular dependency
    // issues
    libs[name].configured = true;
    if(name === 'did-io' || name === 'jsonld-signatures') {
      libs[name].api.use('jsonld', api.use('jsonld'));
      if(name === 'did-io') {
        libs[name].api.use('jsonld-signatures', api.use('jsonld-signatures'));
      }
    } else if(name === 'jsonld') {
      // wrap document loader w/DID-based loader
      libs[name].api.documentLoader = api.use('did-io').createDocumentLoader({
        wrap: libs[name].api.documentLoader
      });
    }
  }
  return libs[name].api;
};

/**
 * Verifies the digital signature on the given Identity object and any
 * credentials it contains. This call only checks authenticity, it does not
 * check a trust store for the identities used to sign.
 *
 * TODO: This call should accept a function for checking trusted identities,
 * domains, etc., so these things can be checked prior to normalization.
 *
 * The callback will be passed the following object:
 *
 * {
 *   verified: <true/false>,
 *   identity: <framed identity>,
 *   domain: <domain the signature was signed for>,
 *   publicKey: <public key object for the creator of the signature>,
 *   publicKeyOwner: <identity object for the creator of the signature>,
 *   // a map of verified objects for each credential (ID => verified)
 *   credentials: {}
 * }
 *
 * @param identity the identity to check.
 * @param options the options to use:
 *          [checkTimestamp]: check signature timestamp (default: true) on
 *            the main Identity credential.
 *          [maxTimestampDelta]: signature must be created within a window of
 *            this many seconds (default: 15 minutes).
 *          [documentLoader(url, callback(err, remoteDoc))] the document loader.
 * @param callback(err, result) called once the operation completes.
 */
api.verify = function(identity, options, callback) {
  if(typeof options === 'function') {
    callback = options;
    options = {};
  }
  options = options || {};

  var jsonld = api.use('jsonld');
  var jsigs = api.use('jsonld-signatures');

  // TODO: assume identity is already properly framed prior to consumption;
  // this is a temporary requirement until jsonld.js supports named graph
  // framing

  // TODO: move any of opencred-verifier code here?
  var result = {
    credentials: {}
  };

  async.auto({
    frame: function(callback) {
      return callback(null, identity);
      /*
      jsonld.frame(
        identity, IDENTITY_FRAME, function(err, framed) {
          if(err) {
            return callback(err);
          }
          var id = framed['@graph'][0];
          if(!id) {
            return callback(new Error('Unknown Identity format.'));
          }
          id['@context'] = framed['@context'];
          callback(null, id);
        });*/
    },
    verifyCredentials: ['frame', function(callback, results) {
      result.identity = results.frame;
      var credentials = jsonld.getValues(result.identity, 'credential');
      async.forEach(credentials, function(credential, callback) {
        credential = credential['@graph'];
        credential['@context'] = results.frame['@context'];
        // TODO: deal with case where `credential.id` is undefined or
        // a duplicate
        var res = result.credentials[credential.id] = {};
        var opts = _.assign(options, {
          id: credential.id,
          checkDomain: checkDomain(res),
          checkKeyOwner: checkKeyOwner(res)
        });
        jsigs.verify(credential, opts, function(err, verified) {
          res.verified = !err && verified;
          callback(err, res);
        });
      }, callback);
    }],
    getIdpSignedPublicKey: ['verifyCredentials', function(callback) {
      getIdpSignedPublicKey(result, callback);
    }],
    verifyIdentity: ['getIdpSignedPublicKey', function(callback, results) {
      var opts = _.assign({
        id: result.identity.id,
        checkTimestamp: true
      }, options, {
        checkDomain: checkDomain(result),
        checkKeyOwner: checkKeyOwner(result)
      });
      if(results.getIdpSignedPublicKey) {
        opts.publicKeyOwner = results.getIdpSignedPublicKey.publicKeyOwner;
        opts.publicKey = results.getIdpSignedPublicKey.publicKey;
      }
      jsigs.verify(result.identity, opts, function(err, verified) {
        result.verified = !err && verified;
        callback(err, result);
      });
    }]
  }, function(err) {
    callback(err, result);
  });
};

api.send = function(options, callback) {
  var url = options.url;
  var body = options.credential || options.query;
  var privateKeyPem = options.privateKeyPem;
  var publicKeyId = options.publicKeyId;
  var strictSSL = true;
  if('strictSSL' in options) {
    strictSSL = !!options.strictSSL;
  }

  var requestOptions = {
    url: url,
    body: body,
    json: true,
    httpSignature: {
      key: privateKeyPem,
      keyId: publicKeyId,
      headers: ['date', 'host', 'request-line']
    },
    strictSSL: strictSSL
  };

  request.post(requestOptions, callback);
};

// TODO: define a function for getting a public key via did-io

function checkDomain(result) {
  // TODO: check against some config value for the domain or similar
  return function(domain, options, callback) {
    result.domain = domain;
    return callback(null, true);
  };
}

function checkKeyOwner(result) {
  // TODO: check against a list of trusted owners, perhaps based on credential
  // type as well
  return function(owner, key, options, callback) {
    result.publicKey = key;
    result.publicKeyOwner = owner;
    return callback(null, true);
  };
}

function getIdpSignedPublicKey(result, callback) {
  var jsonld = api.use('jsonld');
  var identity = result.identity;
  async.auto({
    getIdentity: function(callback) {
      jsonld.documentLoader(identity.id, function(err, doc) {
        if(err) {
          err.status = err.httpStatusCode || 404;
          return callback(err);
        }
        doc = doc.document;
        if(typeof doc === 'string') {
          try {
            doc = JSON.parse(doc);
          } catch(e) {}
        }
        callback(null, doc);
      });
    },
    // TODO: frame identity
    getMatch: ['getIdentity', function(callback, results) {
      // scan list of credentials for a public key credential with a matching
      // ID that has been signed by the IdP for `identity.id`
      var creator = (identity.signature || {}).creator || '';
      var credentials = jsonld.getValues(identity, 'credential');
      for(var i = 0; i < credentials.length; ++i) {
        var credential = credentials[i]['@graph'];
        if(!jsonld.hasValue(credential, 'type', 'CryptographicKeyCredential')) {
          continue;
        }
        var publicKey = credential.claim.publicKey;
        // match found if public key ID matches creator of signature on
        // identity, credential is verified, and key owner ID is identity's IdP
        var res = result.credentials[credential.id];
        if(publicKey.id === creator && res.verified &&
          res.publicKeyOwner.id === results.getIdentity.idp) {
          jsonld.addValue(results.getIdentity, 'publicKey', publicKey.id);
          // ensure @context is passed on for key
          publicKey = _.assign({'@context': IDENTITY_CONTEXT_URL}, publicKey);
          return callback(null, publicKey);
        }
      }
      callback(null, null);
    }]
  }, function(err, results) {
    callback(err, results.getMatch ? {
      publicKeyOwner: results.getIdentity,
      publicKey: results.getMatch
    } : null);
  });
}

return api;

}
622131
def identity_to_string(identity_dict):
    """"""
    result = []
    if identity_dict.get('proto'):
        result.append(identity_dict['proto'] + '://')
    if identity_dict.get('user'):
        result.append(identity_dict['user'] + '@')
    result.append(identity_dict['host'])
    if identity_dict.get('port'):
        result.append(':' + identity_dict['port'])
    if identity_dict.get('path'):
        result.append(identity_dict['path'])
    log.debug('identity parts: %s', result)
    return ''.join(result)
636539
def create_with_role(name, options = {})
      headers = extract_headers!(options)
      json = client.post("/v1/auth/token/create/#{encode_path(name)}", JSON.fast_generate(options), headers)
      return Secret.decode(json)
    end
213011
async def create_identity(self, 
        identity: str, 
        passwd: str, 
    ) -> SessionIdentity :
        

        identity_path = f"{self._prefix_identity}/{identity}"

        profile, _ = await self._client.get(identity_path)
        if profile is not None:
            raise AlreadyExists(f"登陆身份'{identity}'已经注册")

        user_id = await self._user_id_generator.new()

        # 加密登录标识
        hashed = sha256_crypt.using(rounds=2000, salt_size=8).hash(passwd)

        profile = {
            "user_id": user_id,
            "identity": identity,
            "hashed": hashed
        }
    
        value = json.dumps(profile).encode("ascii")
        await self._client.put(identity_path, value)


        return SessionIdentity(user_id=user_id, identity=identity)
578918
private static String resolveIdentity(ResourceAddress address, Subject subject) {
        IdentityResolver resolver = address.getOption(IDENTITY_RESOLVER);
        ResourceAddress transport = address.getTransport();
        if (resolver != null) {
            return resolver.resolve(subject);
        }
        if (transport != null) {
            return resolveIdentity(transport, subject);
        }
        return null;
    }
1243988
def identityRequest():
    """"""
    a = TpPd(pd=0x5)
    b = MessageType(mesType=0x8)  # 00001000
    c = IdentityTypeAndSpareHalfOctets()
    packet = a / b / c
    return packet