// Check if another account is authorized to import from us.
763250
func (a *Account) checkStreamImportAuthorized(account *Account, subject string, imClaim *jwt.Import) bool {
	// Find the subject in the exports list.
	a.mu.RLock()
	defer a.mu.RUnlock()
	return a.checkStreamImportAuthorizedNoLock(account, subject, imClaim)
}
832663
func (c *Client) AccountInfo() (*Account, error) {
	var account Account
	return &account, c.Get(&account, "/account")
}
419530
func (i *ImportRestriction) isAllowed(packageToCheck string) bool {
	// if its not under our root, then its a built-in.  Everything else is under
	// github.com/openshift/origin or github.com/openshift/origin/vendor
	if !strings.HasPrefix(packageToCheck, rootPackage) {
		return true
	}
	if i.isIncludedInRestrictedPackages(packageToCheck) {
		return true
	}

	for _, forbiddenPackageRoot := range i.ForbiddenImportPackageRoots {
		if strings.HasPrefix(forbiddenPackageRoot, "vendor") {
			forbiddenPackageRoot = rootPackage + "/" + forbiddenPackageRoot
		}
		if strings.HasPrefix(packageToCheck, forbiddenPackageRoot) {
			return false
		}
	}
	for _, allowedPackage := range i.AllowedImportPackages {
		if strings.HasPrefix(allowedPackage, "vendor") {
			allowedPackage = rootPackage + "/" + allowedPackage
		}
		if packageToCheck == allowedPackage {
			return true
		}
	}
	for _, allowedPackageRoot := range i.AllowedImportPackageRoots {
		if strings.HasPrefix(allowedPackageRoot, "vendor") {
			allowedPackageRoot = rootPackage + "/" + allowedPackageRoot
		}
		if strings.HasPrefix(packageToCheck, allowedPackageRoot) {
			return true
		}
	}

	return false
}
210623
func (api *Client) GetAccount() (*Account, error) {
	result, _, err := api.makeRequest(http.MethodGet, api.concatUserPath(accountPath), &Account{})
	if err != nil {
		return nil, err
	}
	return result.(*Account), nil
}
941133
func (c *Client) GetAccountInfo() (info AccountInfo, err error) {
	if err := c.get(`account/info`, &info); err != nil {
		return AccountInfo{}, err
	}
	return
}
909563
func (s *Server) reloadAuthorization() {
	s.mu.Lock()

	// We need to drain the old accounts here since we have something
	// new configured. We do not want s.accounts to change since that would
	// mean adding a lock to lookupAccount which is what we are trying to
	// optimize for with the change from a map to a sync.Map.
	oldAccounts := make(map[string]*Account)
	s.accounts.Range(func(k, v interface{}) bool {
		acc := v.(*Account)
		acc.mu.RLock()
		oldAccounts[acc.Name] = acc
		acc.mu.RUnlock()
		s.accounts.Delete(k)
		return true
	})
	s.gacc = nil
	s.configureAccounts()

	s.configureAuthorization()

	// This map will contain the names of accounts that have their streams
	// import configuration changed.
	awcsti := make(map[string]struct{})

	s.accounts.Range(func(k, v interface{}) bool {
		newAcc := v.(*Account)
		if acc, ok := oldAccounts[newAcc.Name]; ok {
			// If account exist in latest config, "transfer" the account's
			// sublist and client map to the new account.
			acc.mu.RLock()
			if len(acc.clients) > 0 {
				newAcc.clients = make(map[*client]*client, len(acc.clients))
				for _, c := range acc.clients {
					newAcc.clients[c] = c
				}
			}
			newAcc.sl = acc.sl
			acc.mu.RUnlock()

			// Check if current and new config of this account are same
			// in term of stream imports.
			if !acc.checkStreamImportsEqual(newAcc) {
				awcsti[newAcc.Name] = struct{}{}
			}
		}
		return true
	})

	// Gather clients that changed accounts. We will close them and they
	// will reconnect, doing the right thing.
	var (
		cclientsa [64]*client
		cclients  = cclientsa[:0]
		clientsa  [64]*client
		clients   = clientsa[:0]
		routesa   [64]*client
		routes    = routesa[:0]
	)
	for _, client := range s.clients {
		if s.clientHasMovedToDifferentAccount(client) {
			cclients = append(cclients, client)
		} else {
			clients = append(clients, client)
		}
	}
	for _, route := range s.routes {
		routes = append(routes, route)
	}
	s.mu.Unlock()

	// Close clients that have moved accounts
	for _, client := range cclients {
		client.closeConnection(ClientClosed)
	}

	for _, client := range clients {
		// Disconnect any unauthorized clients.
		if !s.isClientAuthorized(client) {
			client.authViolation()
			continue
		}
		// Remove any unauthorized subscriptions and check for account imports.
		client.processSubsOnConfigReload(awcsti)
	}

	for _, route := range routes {
		// Disconnect any unauthorized routes.
		// Do this only for route that were accepted, not initiated
		// because in the later case, we don't have the user name/password
		// of the remote server.
		if !route.isSolicitedRoute() && !s.isRouterAuthorized(route) {
			route.setNoReconnect()
			route.authViolation()
		}
	}
}
712410
func (r Account_ProofOfConcept) GetTotalRequestsPendingIntegratedOfferingTeamReview(accessToken *string) (resp int, err error) {
	params := []interface{}{
		accessToken,
	}
	err = r.Session.DoRequest("SoftLayer_Account_ProofOfConcept", "getTotalRequestsPendingIntegratedOfferingTeamReview", params, &r.Options, &resp)
	return
}
1070029
func (a *Account) AuthorizedClients() ([]*OAuthClient, error) {
	var clients []*OAuthClient
	err := a.get(a.auth, "/api/v2/users/me/authorized-clients", &clients)
	if err != nil {
		return nil, err
	}

	return clients, nil
}
296511
func (c *Client) IsAuthenticated() bool {
	authHeader, ok := c.Headers["Authorization"]

	if !ok || (ok && authHeader == "token ") {
		return false
	}

	return true
}
1122507
func (ks *KeyStore) ImportPreSaleKey(keyJSON []byte, passphrase string) (accounts.Account, error) {
	a, _, err := importPreSaleKey(ks.storage, keyJSON, passphrase)
	if err != nil {
		return a, err
	}
	ks.cache.add(a)
	ks.refreshWallets()
	return a, nil
}
1273625
func IsAllowed(ctx context.Context, p influxdb.Permission) error {
	a, err := influxdbcontext.GetAuthorizer(ctx)
	if err != nil {
		return err
	}

	if !a.Allowed(p) {
		return &influxdb.Error{
			Code: influxdb.EUnauthorized,
			Msg:  fmt.Sprintf("%s is unauthorized", p),
		}
	}

	return nil
}
860671
func (a *Account) hasIssuer(issuer string) bool {
	a.mu.RLock()
	defer a.mu.RUnlock()
	// same issuer
	if a.Issuer == issuer {
		return true
	}
	for i := 0; i < len(a.signingKeys); i++ {
		if a.signingKeys[i] == issuer {
			return true
		}
	}
	return false
}
628527
func (c *Client) AccountInfo() (AccInfo, error) {
	data, err := c.apiCall("account.info", nil)
	if err != nil {
		return AccInfo{}, err
	}

	var info AccInfo
	err = json.Unmarshal(data, &info)
	if err != nil {
		return AccInfo{}, err
	}

	return info, nil
}
986073
func (s *Server) LookupOrRegisterAccount(name string) (account *Account, isNew bool) {
	if v, ok := s.accounts.Load(name); ok {
		return v.(*Account), false
	}
	s.mu.Lock()
	acc := NewAccount(name)
	s.registerAccount(acc)
	s.mu.Unlock()
	return acc, true
}
145888
func (a *Authenticator) checkInitialized() (bool, error) {
	if a.err != nil || a.baseToken != nil {
		return true, a.err
	}
	return false, nil
}
899925
func NewAccount(AccountId string, Name *Name, Email string, EmailVerified bool, Disabled bool) *Account {
	s := new(Account)
	s.AccountId = AccountId
	s.Name = Name
	s.Email = Email
	s.EmailVerified = EmailVerified
	s.Disabled = Disabled
	return s
}
436771
func NewBasicAccount(AccountId string, Name *Name, Email string, EmailVerified bool, Disabled bool, IsTeammate bool) *BasicAccount {
	s := new(BasicAccount)
	s.AccountId = AccountId
	s.Name = Name
	s.Email = Email
	s.EmailVerified = EmailVerified
	s.Disabled = Disabled
	s.IsTeammate = IsTeammate
	return s
}