// ActiveScopedKeyManagers returns a slice of all the active scoped key
// managers currently known by the root key manager.
6201
func (m *Manager) ActiveScopedKeyManagers() []*ScopedKeyManager {
	m.mtx.RLock()
	defer m.mtx.RUnlock()

	var scopedManagers []*ScopedKeyManager
	for _, smgr := range m.scopedManagers {
		scopedManagers = append(scopedManagers, smgr)
	}

	return scopedManagers
}
30609
func (m *Map) scopedLogger() *logrus.Entry {
	return log.WithFields(logrus.Fields{logfields.Path: m.path, "name": m.name})
}
167074
func WithAllowNoLeader(parent context.Context) context.Context {
	if parent == nil {
		parent = context.Background()
	}
	return context.WithValue(parent, keyAllowNoLeader, true)
}
498910
func ContextRequiredScopes(ctx context.Context) []string {
	if s := ctx.Value(securityScopesKey); s != nil {
		return s.([]string)
	}
	return nil
}
948296
func (s *KeyMetadata) SetKeyManager(v string) *KeyMetadata {
	s.KeyManager = &v
	return s
}
514505
func DefaultScopes(dataDir string) map[string]*ScopeCfg {
	if dataDir != "" {
		defaultScopes[LocalScope].Client.Address = dataDir + "/network/files/local-kv.db"
		return defaultScopes
	}

	defaultScopes[LocalScope].Client.Address = defaultPrefix + "/local-kv.db"
	return defaultScopes
}
297317
func KeyModifiers(modifiers ...input.Modifier) KeyOption {
	return func(p *input.DispatchKeyEventParams) *input.DispatchKeyEventParams {
		for _, m := range modifiers {
			p.Modifiers |= m
		}
		return p
	}
}
478523
func UnusedDelegationKeys(t data.SignedTargets) []string {
	// compare ids to all still active key ids in all active roles
	// with the targets file
	found := make(map[string]bool)
	for _, r := range t.Signed.Delegations.Roles {
		for _, id := range r.KeyIDs {
			found[id] = true
		}
	}
	var discard []string
	for id := range t.Signed.Delegations.Keys {
		if !found[id] {
			discard = append(discard, id)
		}
	}
	return discard
}
474936
func (s *ScanKeys) KeyOwner(keyID uint64) *libkb.User {
	s.Lock()
	defer s.Unlock()

	return s.keyOwners[keyID]
}
535813
func (scope *ArgScope) Keys() ([]string, error) {
	keys := make([]string, len(scope.data))
	i := 0
	for key := range scope.data {
		keys[i] = key
		i++
	}
	return keys, nil
}
766563
func (s *ScopedKeyManager) ForEachActiveAddress(ns walletdb.ReadBucket,
	fn func(addr btcutil.Address) error) error {

	s.mtx.Lock()
	defer s.mtx.Unlock()

	addrFn := func(rowInterface interface{}) error {
		managedAddr, err := s.rowInterfaceToManaged(ns, rowInterface)
		if err != nil {
			return err
		}
		return fn(managedAddr.Address())
	}

	err := forEachActiveAddress(ns, &s.scope, addrFn)
	if err != nil {
		return maybeConvertDbError(err)
	}

	return nil
}
319454
func (r *registry) loadHandlers(c Config) {
	for _, config := range c.AuthFilters {
		r.evaluateModeAndLoad(config, Auth)
	}
	for _, config := range c.Decorators {
		r.evaluateModeAndLoad(config, Decoration)
	}

	for chaincodeID, config := range c.Endorsers {
		r.evaluateModeAndLoad(config, Endorsement, chaincodeID)
	}

	for chaincodeID, config := range c.Validators {
		r.evaluateModeAndLoad(config, Validation, chaincodeID)
	}
}
1261234
func (ds *DataScope) Keys() ([]string, error) {
	keys := make([]string, len(ds.Data))
	i := 0
	for key := range ds.Data {
		keys[i] = key
		i++
	}
	return keys, nil
}
209255
func NewKeyManagerAPI(st *state.State, resources facade.Resources, authorizer facade.Authorizer) (*KeyManagerAPI, error) {
	// Only clients can access the key manager service.
	if !authorizer.AuthClient() {
		return nil, common.ErrPerm
	}
	m, err := st.Model()
	if err != nil {
		return nil, errors.Trace(err)
	}
	return &KeyManagerAPI{
		state:      st,
		model:      m,
		resources:  resources,
		authorizer: authorizer,
		apiUser:    authorizer.GetAuthTag().(names.UserTag),
		check:      common.NewBlockChecker(st),
	}, nil
}
232984
func AccessTokenWithManager(s string, manager tokens.Manager) Strategy {
	return &accessToken{
		accessToken: s,
		manager:     manager,
	}
}
327765
func UserHasAuthorizedScopes(r *http.Request, authorization *user.Authorization) (bool, error) {
	log.Debug("Checking if user still has all mapped scopes")
	user, err := user.NewManager(r).GetByName(authorization.Username)
	if err != nil {
		return false, err
	}

	found := false
	if authorization.Addresses != nil {
		for _, am := range authorization.Addresses {
			for _, a := range user.Addresses {
				if am.RealLabel == a.Label {
					found = true
					break
				}
			}
			if !found {
				log.Debug("Authorized real label not found for address")
				return false, nil
			}
		}
	}

	found = false
	if authorization.BankAccounts != nil {
		for _, ba := range authorization.BankAccounts {
			for _, b := range user.BankAccounts {
				if ba.RealLabel == b.Label {
					found = true
					break
				}
			}
			if !found {
				log.Debug("Authorized real label not found for bank account")
				return false, nil
			}
		}
	}

	found = false
	if authorization.DigitalWallet != nil {
		for _, dw := range authorization.DigitalWallet {
			for _, d := range user.DigitalWallet {
				if dw.RealLabel == d.Label {
					found = true
					break
				}
			}
			if !found {
				log.Debug("Authorized real label not found for digital wallet")
				return false, nil
			}
		}
	}

	found = false
	if authorization.EmailAddresses != nil {
		for _, ea := range authorization.EmailAddresses {
			for _, e := range user.EmailAddresses {
				if ea.RealLabel == e.Label {
					found = true
					break
				}
			}
			if !found {
				log.Debug("Authorized real label not found for email address")
				return false, nil
			}
		}
	}

	found = false
	if authorization.Phonenumbers != nil {
		for _, ep := range authorization.Phonenumbers {
			for _, p := range user.Phonenumbers {
				if ep.RealLabel == p.Label {
					found = true
					break
				}
			}
			if !found {
				log.Debug("Authorized real label not found for phone number")
				return false, nil
			}
		}
	}

	found = false
	if authorization.PublicKeys != nil {
		for _, pk := range authorization.PublicKeys {
			for _, p := range user.PublicKeys {
				if pk.RealLabel == p.Label {
					found = true
					break
				}
			}
			if !found {
				log.Debug("Authorized real label not found for public key")
				return false, nil
			}
		}
	}

	found = false
	valMgr := validation.NewManager(r)
	if authorization.ValidatedEmailAddresses != nil {
		for _, vea := range authorization.ValidatedEmailAddresses {
			for _, e := range user.EmailAddresses {
				if vea.RealLabel == e.Label {
					// Check that the email address is actually validated by the user in the authorization
					validatedEmail, err := valMgr.GetByEmailAddressValidatedEmailAddress(e.EmailAddress)
					if err != nil && !db.IsNotFound(err) {
						return false, err
					}
					if db.IsNotFound(err) {
						return false, nil
					}
					if validatedEmail.Username == authorization.Username {
						found = true
						break
					}
				}
			}
			if !found {
				log.Debug("Validated email address in authorization does not belong to the user")
				return false, nil
			}
		}
	}

	found = false
	if authorization.ValidatedPhonenumbers != nil {
		for _, vpn := range authorization.ValidatedPhonenumbers {
			for _, p := range user.Phonenumbers {
				if vpn.RealLabel == p.Label {
					// Check that the phone is actually validated by the user in the authorization
					validatedPhone, err := valMgr.GetByPhoneNumber(p.Phonenumber)
					if err != nil && !db.IsNotFound(err) {
						return false, err
					}
					if db.IsNotFound(err) {
						return false, nil
					}
					if validatedPhone.Username == authorization.Username {
						found = true
						break
					}
				}
			}
			if !found {
				log.Debug("Validated phone number in authorization does not belong to the user")
				return false, nil
			}
		}
	}
	return true, nil
}
1175867
func (ckf ComputedKeyFamily) GetActivePGPKeys(sibkey bool) (ret []*PGPKeyBundle) {
	for kid := range ckf.kf.PGPKeySets {
		role := ckf.GetKeyRole(kid)
		if (sibkey && role == DLGSibkey) || role != DLGNone {
			if key, err := ckf.FindKeyWithKIDUnsafe(kid); err == nil {
				ret = append(ret, key.(*PGPKeyBundle))
			} else {
				ckf.G().Log.Errorf("KID %s was in a KeyFamily's list of PGP keys, but the key doesn't exist: %s", kid, err)
			}
		}
	}
	return
}