// DeserializeIdentity provides a mock function with given fields: serializedIdentity
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
}
260002
func (a *awsNodeAuthorizer) validateIdentityDocument(_ context.Context, signed []byte, document interface{}) (string, error) {
	// @step: decode the signed document
	decoded, err := base64.StdEncoding.DecodeString(string(signed))
	if err != nil {
		return "", err
	}

	// @step: get the digest
	for _, x := range publicCertificates {
		parsed, err := pkcs7.Parse(decoded)
		if err != nil {
			return "", err
		}

		parsed.Certificates = []*x509.Certificate{x}
		if err := parsed.Verify(); err != nil {
			utils.Logger.Warn("identity document not validated by certificates",
				zap.String("common-name", x.Subject.CommonName),
				zap.Error(err))
		} else {
			return "", json.NewDecoder(bytes.NewReader(parsed.Content)).Decode(document)
		}
	}

	return "invalid signature", nil
}
1368065
func (c *Client) GetAllIdentities(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
	}

	responses, err := ca.GetAllIdentities(opts.CA)
	if err != nil {
		return nil, err
	}

	return getIdentityResponses(responses), nil

}
1240218
func (s *SetIdentityMailFromDomainInput) SetIdentity(v string) *SetIdentityMailFromDomainInput {
	s.Identity = &v
	return s
}
556979
func (mgr *MockCAClient) GetAllIdentities(caname string) ([]*api.IdentityResponse, error) {
	return nil, errors.New("not implemented")
}
894725
func (s *EmailChannelRequest) SetIdentity(v string) *EmailChannelRequest {
	s.Identity = &v
	return s
}
148693
func (c *Client) RemoveIdentity(request *RemoveIdentityRequest) (*IdentityResponse, error) {

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

	req := &mspapi.RemoveIdentityRequest{
		ID:     request.ID,
		Force:  request.Force,
		CAName: request.CAName,
	}

	response, err := ca.RemoveIdentity(req)
	if err != nil {
		return nil, err
	}

	return getIdentityResponse(response), nil
}
473768
func (j JSONPBStateSerializer) Deserialize(serialized string, state interface{}) error {
	pm, ok := state.(proto.Message)
	if ok {
		return j.u.Unmarshal(strings.NewReader(serialized), pm)
	}
	return j.fbss.Deserialize(serialized, state)
}
291404
func (id *PolicyEvaluator) DeserializeIdentity(serializedIdentity []byte) (Identity, error) {
	mspIdentity, err := id.IdentityDeserializer.DeserializeIdentity(serializedIdentity)
	if err != nil {
		return nil, err
	}
	return &identity{Identity: mspIdentity}, nil
}
1324687
func (a *Client) GetNodesIdentifierObmIdentify(params *GetNodesIdentifierObmIdentifyParams, authInfo runtime.ClientAuthInfoWriter) (*GetNodesIdentifierObmIdentifyOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetNodesIdentifierObmIdentifyParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "GetNodesIdentifierObmIdentify",
		Method:             "GET",
		PathPattern:        "/nodes/{identifier}/obm/identify",
		ProducesMediaTypes: []string{"application/json", "application/x-gzip"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetNodesIdentifierObmIdentifyReader{formats: a.formats},
		AuthInfo:           authInfo,
	})
	if err != nil {
		return nil, err
	}
	return result.(*GetNodesIdentifierObmIdentifyOK), nil
}
895865
func (c *fabricCAAdapter) GetAllIdentities(key core.Key, cert []byte, caname string) ([]*api.IdentityResponse, error) {

	logger.Debug("Retrieving all identities")

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

	var identities []caapi.IdentityInfo

	err = registrar.GetAllIdentities(caname, func(decoder *json.Decoder) error {
		var identity caapi.IdentityInfo
		decodeErr := decoder.Decode(&identity)
		if decodeErr != nil {
			return decodeErr
		}

		identities = append(identities, identity)
		return nil
	})

	if err != nil {
		return nil, errors.Wrap(err, "failed to get identities")
	}

	return getIdentityResponses(c.caClient.Config.CAName, identities), nil
}
226456
func (p ProtobufStateSerializer) Deserialize(serialized string, state interface{}) error {
	bin, err := base64.StdEncoding.DecodeString(serialized)
	if err != nil {
		return err
	}
	err = proto.Unmarshal(bin, state.(proto.Message))

	return err
}
4827
func (c *fabricCAAdapter) CreateIdentity(key core.Key, cert []byte, request *api.IdentityRequest) (*api.IdentityResponse, error) {

	logger.Debugf("Creating identity [%s:%s]", request.ID, request.Affiliation)

	var attributes []caapi.Attribute
	for i := range request.Attributes {
		attributes = append(attributes, caapi.Attribute{Name: request.Attributes[i].Name, Value: request.Attributes[i].Value, ECert: request.Attributes[i].ECert})
	}

	// Create add identity request
	req := caapi.AddIdentityRequest{
		CAName:         request.CAName,
		ID:             request.ID,
		Affiliation:    request.Affiliation,
		Attributes:     attributes,
		Type:           request.Type,
		MaxEnrollments: request.MaxEnrollments,
		Secret:         request.Secret,
	}

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

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

	return getIdentityResponse(response), nil
}
191075
func (c *fabricCAAdapter) GetIdentity(key core.Key, cert []byte, id, caname string) (*api.IdentityResponse, error) {

	logger.Debugf("Retrieving identity [%s]", id)

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

	response, err := registrar.GetIdentity(id, caname)
	if err != nil {
		return nil, errors.Wrap(err, "failed to get identity")
	}

	var attributes []api.Attribute
	for i := range response.Attributes {
		attributes = append(attributes, api.Attribute{Name: response.Attributes[i].Name, Value: response.Attributes[i].Value, ECert: response.Attributes[i].ECert})
	}

	ret := &api.IdentityResponse{ID: response.ID,
		Affiliation:    response.Affiliation,
		Type:           response.Type,
		Attributes:     attributes,
		MaxEnrollments: response.MaxEnrollments,
		CAName:         response.CAName,
	}

	return ret, nil
}
239824
func collectIdentities(seqs ...interface{}) (map[interface{}]bool, error) {
	seen := make(map[interface{}]bool)
	for _, seq := range seqs {
		v := reflect.ValueOf(seq)
		switch v.Kind() {
		case reflect.Array, reflect.Slice:
			for i := 0; i < v.Len(); i++ {
				ev, _ := indirectInterface(v.Index(i))

				if !ev.Type().Comparable() {
					return nil, errors.New("elements must be comparable")
				}

				seen[normalize(ev)] = true
			}
		default:
			return nil, fmt.Errorf("arguments must be slices or arrays")
		}
	}

	return seen, nil
}
1099897
func LookupIdentity(lbls labels.Labels) *identity.Identity {
	if reservedIdentity := LookupReservedIdentityByLabels(lbls); reservedIdentity != nil {
		return reservedIdentity
	}

	if identity := localIdentities.lookup(lbls); identity != nil {
		return identity
	}

	if IdentityAllocator == nil {
		return nil
	}

	lblArray := lbls.LabelArray()
	id, err := IdentityAllocator.Get(context.TODO(), globalIdentity{lblArray})
	if err != nil {
		return nil
	}

	if id == idpool.NoID {
		return nil
	}

	return identity.NewIdentityFromLabelArray(identity.NumericIdentity(id), lblArray)
}
782544
func (c *Client) IdentityGet(id string) (*models.Identity, error) {
	params := policy.NewGetIdentityIDParams().WithID(id).WithTimeout(api.ClientTimeout)

	resp, err := c.Policy.GetIdentityID(params)
	if err != nil {
		return nil, Hint(err)
	}
	return resp.Payload, nil
}