// RemoveIdentity  removes identity
// key: registrar private key
// cert: registrar enrollment certificate
6522
func (c *fabricCAAdapter) RemoveIdentity(key core.Key, cert []byte, request *api.RemoveIdentityRequest) (*api.IdentityResponse, error) {

	logger.Debugf("Removing identity [%s]", request.ID)

	// Create remove request
	req := caapi.RemoveIdentityRequest{
		CAName: request.CAName,
		Force:  request.Force,
		ID:     request.ID,
	}

	registrar, err := c.newIdentity(key, cert)
	if err != nil {
		return nil, errors.Wrap(err, "failed to create CA signing identity")
	}

	response, err := registrar.RemoveIdentity(&req)
	if err != nil {
		return nil, errors.Wrap(err, "failed to remove identity")
	}

	return getIdentityResponse(response), nil
}
928772
func (i *winIdentity) Delete() error {
	// duplicate cert context, since CertDeleteCertificateFromStore will free it.
	deleteCtx := C.CertDuplicateCertificateContext(i.chain[0])

	// try deleting cert
	if ok := C.CertDeleteCertificateFromStore(deleteCtx); ok == winFalse {
		return lastError("failed to delete certificate from store")
	}

	// try deleting private key
	wpk, err := i.getPrivateKey()
	if err != nil {
		return errors.Wrap(err, "failed to get identity private key")
	}

	if err := wpk.Delete(); err != nil {
		return errors.Wrap(err, "failed to delete identity private key")
	}

	return nil
}
959553
func (c *Client) GetIdentity(ID string, options ...RequestOption) (*IdentityResponse, error) {

	// Read request options
	opts, err := c.prepareOptsFromOptions(c.ctx, options...)
	if err != nil {
		return nil, err
	}

	ca, err := newCAClient(c.ctx, c.orgName)
	if err != nil {
		return nil, err
	}

	response, err := ca.GetIdentity(ID, opts.CA)
	if err != nil {
		return nil, err
	}

	return getIdentityResponse(response), nil

}
210100
func (c *client) Remove(ctx context.Context, entity DomainObject) error {
	if !c.initialized {
		return &ErrNotInitialized{}
	}

	// lookup registered entity, the registrar will return error if it is not found
	re, err := c.registrar.Find(entity)
	if err != nil {
		return err
	}

	// translate entity field values to a map of primary key name/values pairs
	keyFieldValues := re.KeyFieldValues(entity)

	err = c.connector.Remove(ctx, re.EntityInfo(), keyFieldValues)
	return err
}
88390
func (d *Daemon) UpdateIdentities(added, deleted cache.IdentityCache) {
	policy.UpdateIdentities(added, deleted)
	d.TriggerPolicyUpdates(true, "one or more identities created or deleted")
}
466648
func (s *ListRecordsInput) SetIdentityId(v string) *ListRecordsInput {
	s.IdentityId = &v
	return s
}
1246412
func (c *CAClientImpl) GetIdentity(id, caname string) (*api.IdentityResponse, error) {

	if c.adapter == nil {
		return nil, fmt.Errorf("no CAs configured for organization: %s", c.orgName)
	}

	// Checke required parameters (ID and affiliation)
	if id == "" {
		return nil, errors.New("id is required")
	}

	registrar, err := c.getRegistrar(c.registrar.EnrollID, c.registrar.EnrollSecret)
	if err != nil {
		return nil, err
	}

	return c.adapter.GetIdentity(registrar.PrivateKey(), registrar.EnrollmentCertificate(), id, caname)
}
244563
func (s *DescribeIdentityInput) SetIdentityId(v string) *DescribeIdentityInput {
	s.IdentityId = &v
	return s
}
765978
func (_m *IdentityDeserializer) DeserializeIdentity(serializedIdentity []byte) (msp.Identity, error) {
	ret := _m.Called(serializedIdentity)

	var r0 msp.Identity
	if rf, ok := ret.Get(0).(func([]byte) msp.Identity); ok {
		r0 = rf(serializedIdentity)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(msp.Identity)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func([]byte) error); ok {
		r1 = rf(serializedIdentity)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
700338
func SetIdentity(r *http.Request, v string) *http.Request {
	return r.WithContext(context.WithValue(r.Context(), identity, v))
}
945398
func (s *MergeDeveloperIdentitiesOutput) SetIdentityId(v string) *MergeDeveloperIdentitiesOutput {
	s.IdentityId = &v
	return s
}
774209
func (s *GetOpenIdTokenOutput) SetIdentityId(v string) *GetOpenIdTokenOutput {
	s.IdentityId = &v
	return s
}
79800
func (s *GetIdOutput) SetIdentityId(v string) *GetIdOutput {
	s.IdentityId = &v
	return s
}
286373
func (a *awsNodeVerifier) VerifyIdentity(ctx context.Context) ([]byte, error) {
	errs := make(chan error, 0)
	doneCh := make(chan []byte, 0)

	go func() {
		encoded, err := func() ([]byte, error) {
			// @step: create a metadata client
			client := ec2metadata.New(session.New())

			// @step: get the pkcs7 signature from the metadata service
			signature, err := client.GetDynamicData("/instance-identity/pkcs7")
			if err != nil {
				return []byte{}, err
			}

			// @step: construct request for the request
			request := &Request{
				Document: []byte(signature),
			}

			return json.Marshal(request)
		}()
		if err != nil {
			errs <- err
			return
		}

		doneCh <- encoded
	}()

	select {
	case <-ctx.Done():
		return nil, ctx.Err()
	case err := <-errs:
		return nil, err
	case req := <-doneCh:
		return req, nil
	}
}
617564
func (c *ACLCaches) PutIdentity(id string, ident ACLIdentity) {
	if c == nil || c.identities == nil {
		return
	}

	c.identities.Add(id, &IdentityCacheEntry{Identity: ident, CacheTime: time.Now()})
}
674717
func (s *CA) DeleteCertAuthority(id services.CertAuthID) error {
	if err := id.Check(); err != nil {
		return trace.Wrap(err)
	}
	// when removing a services.CertAuthority also remove any deactivated
	// services.CertAuthority as well if they exist.
	err := s.Delete(context.TODO(), backend.Key(authoritiesPrefix, deactivatedPrefix, string(id.Type), id.DomainName))
	if err != nil {
		if !trace.IsNotFound(err) {
			return trace.Wrap(err)
		}
	}
	err = s.Delete(context.TODO(), backend.Key(authoritiesPrefix, string(id.Type), id.DomainName))
	if err != nil {
		return trace.Wrap(err)
	}
	return nil
}
256596
func (m *SyncIdentityMap) Remove(key interface{}) {
	m.Lock()
	keyPtr := genKey(key)
	delete(m.m, keyPtr)
	m.Unlock()
}