// ConvertUsernamesToIdentifiers converts a list of usernames to a list of user identifiers
972327
func ConvertUsernamesToIdentifiers(usernames []string, valMgr *validation.Manager) ([]string, error) {
	identifiers := []string{}
	checkedUsers := map[string]bool{}
	for _, u := range usernames {
		checkedUsers[u] = false
	}
	emails, err := valMgr.GetValidatedEmailAddressesByUsernames(usernames)
	if err != nil {
		return identifiers, err
	}
	for _, validatedEmail := range emails {
		if !checkedUsers[validatedEmail.Username] {
			identifiers = append(identifiers, validatedEmail.EmailAddress)
			checkedUsers[validatedEmail.Username] = true
		}
	}
	checkPhoneUsernames := []string{}
	for username, checked := range checkedUsers {
		if !checked {
			checkPhoneUsernames = append(checkPhoneUsernames, username)
		}
	}
	validatedPhoneNumbers, err := valMgr.GetValidatedPhoneNumbersByUsernames(checkPhoneUsernames)
	if err != nil {
		return identifiers, err
	}
	for _, validatedPhone := range validatedPhoneNumbers {
		if !checkedUsers[validatedPhone.Username] {
			identifiers = append(identifiers, validatedPhone.Phonenumber)
			checkedUsers[validatedPhone.Username] = true
		}
	}
	return identifiers, nil
}
269988
func SingularizeIdentifier(s string) string {
	if i := reverseIndexRune(s, '_'); i != -1 {
		s = s[:i] + "_" + inflector.Singularize(s[i+1:])
	} else {
		s = inflector.Singularize(s)
	}

	return snaker.SnakeToCamelIdentifier(s)
}
477815
func extractUsername(authToken string) string {
	split := strings.SplitN(authToken, ":", 2)
	if len(split) == 2 {
		return split[0]
	}
	return ""
}
1360405
func stripUserPrefix(s []string) []string {
	for i, a := range s {
		if strings.HasPrefix(a, userPrefix) {
			s[i] = a[5:]
		}
	}
	return s
}
585855
func (m *Manager) UpsertIdentifier(username, azp, iyoid string) error {
	// Count the amount of iyoids we already have first
	idObj, err := m.GetByUsernameAndAZP(username, azp)
	if err != nil && !db.IsNotFound(err) {
		return err
	}
	if db.IsNotFound(err) {
		idObj = &Identifier{}
	}
	if len(idObj.IyoIDs) >= maxIdentifiers {
		return ErrIDLimitReached
	}

	_, err = m.getIdentifierCollection().Upsert(bson.M{"username": username, "azp": azp}, bson.M{"$push": bson.M{"iyoids": iyoid}})
	return err
}
541496
func Convert_config_GoogleIdentityProvider_To_v1_GoogleIdentityProvider(in *config.GoogleIdentityProvider, out *v1.GoogleIdentityProvider, s conversion.Scope) error {
	return autoConvert_config_GoogleIdentityProvider_To_v1_GoogleIdentityProvider(in, out, s)
}
683281
func ConvertRegisters(in []proc.Register) (out []Register) {
	out = make([]Register, len(in))
	for i := range in {
		out[i] = Register{in[i].Name, in[i].Value}
	}
	return
}
1076184
func IdentityFilterByUsername(username string) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		return db.Where("username = ?", username).Limit(1)
	}
}
1352470
func Convert_config_KeystonePasswordIdentityProvider_To_v1_KeystonePasswordIdentityProvider(in *config.KeystonePasswordIdentityProvider, out *v1.KeystonePasswordIdentityProvider, s conversion.Scope) error {
	return autoConvert_config_KeystonePasswordIdentityProvider_To_v1_KeystonePasswordIdentityProvider(in, out, s)
}
783675
func safeIdentifier(s string) string {
	s = strings.Map(coerceToIdentifierRune, s)
	if unicode.IsNumber([]rune(s)[0]) {
		s = fmt.Sprint("_", s)
	}
	return s
}
842522
func (psbc principalSetsByCollectionName) toIdentityFilter(channel string, evaluator principalEvaluator, cc *ChaincodeCall) (identityFilter, error) {
	var principalSets policies.PrincipalSets
	for _, col := range cc.CollectionNames {
		// Each collection we're interested in should exist in the principalSetsByCollectionName mapping.
		// Otherwise, we have no way of computing a filter because we can't locate the principals the peer identities
		// need to satisfy.
		principalSet, exists := psbc[col]
		if !exists {
			return nil, errors.Errorf("collection %s doesn't exist in collection config for chaincode %s", col, cc.Name)
		}
		principalSets = append(principalSets, principalSet)
	}
	return filterForPrincipalSets(channel, evaluator, principalSets), nil
}
1180626
func (s *BatchGetAggregateResourceConfigInput) SetResourceIdentifiers(v []*AggregateResourceIdentifier) *BatchGetAggregateResourceConfigInput {
	s.ResourceIdentifiers = v
	return s
}
780901
func Convert_v1_UserIdentityMapping_To_user_UserIdentityMapping(in *v1.UserIdentityMapping, out *user.UserIdentityMapping, s conversion.Scope) error {
	return autoConvert_v1_UserIdentityMapping_To_user_UserIdentityMapping(in, out, s)
}
331820
func (s *IdentityService) GetUsers() ([]services.User, error) {
	startKey := backend.Key(webPrefix, usersPrefix)
	result, err := s.GetRange(context.TODO(), startKey, backend.RangeEnd(startKey), backend.NoLimit)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	var out []services.User
	for _, item := range result.Items {
		if !bytes.HasSuffix(item.Key, []byte(paramsPrefix)) {
			continue
		}
		u, err := services.GetUserMarshaler().UnmarshalUser(
			item.Value, services.WithResourceID(item.ID), services.WithExpires(item.Expires))
		if err != nil {
			return nil, trace.Wrap(err)
		}
		out = append(out, u)
	}
	return out, nil
}
543250
func (a *APIDefinition) IterateUserTypes(it UserTypeIterator) error {
	names := make([]string, len(a.Types))
	i := 0
	for n := range a.Types {
		names[i] = n
		i++
	}
	sort.Strings(names)
	for _, n := range names {
		if err := it(a.Types[n]); err != nil {
			return err
		}
	}
	return nil
}
1085936
func addIdentityToUser(identity *userapi.Identity, user *userapi.User) bool {
	identities := sets.NewString(user.Identities...)
	if identities.Has(identity.Name) {
		return false
	}
	identities.Insert(identity.Name)
	user.Identities = identities.List()
	return true
}
148761
func Convert_v1_HTPasswdPasswordIdentityProvider_To_config_HTPasswdPasswordIdentityProvider(in *v1.HTPasswdPasswordIdentityProvider, out *config.HTPasswdPasswordIdentityProvider, s conversion.Scope) error {
	return autoConvert_v1_HTPasswdPasswordIdentityProvider_To_config_HTPasswdPasswordIdentityProvider(in, out, s)
}