// getRole returns the role name to be used when creating tokens
321072
func (v *vaultClient) getRole() string {
	if v.config.Role != "" {
		return v.config.Role
	}

	return v.tokenData.Role
}
1029651
func (e *SyncedEnforcer) GetRolesForUser(name string) []string {
	e.m.Lock()
	defer e.m.Unlock()
	return e.Enforcer.GetRolesForUser(name)
}
1371136
func (e *Enforcer) GetRolesForUserInDomain(name string, domain string) []string {
	res, _ := e.model["g"]["g"].RM.GetRoles(name, domain)
	return res
}
1284817
func (a AuthorizerAdapter) GetRole(namespace, name string) (*rbacv1.Role, error) {
	return a.Registry.GetRole(genericapirequest.WithNamespace(genericapirequest.NewContext(), namespace), name, &metav1.GetOptions{})
}
1230658
func (s *ListedUser) SetRole(v string) *ListedUser {
	s.Role = &v
	return s
}
315494
func (c *ResourceRolesController) AssignRole(ctx *app.AssignRoleResourceRolesContext) error {
	currentIdentity, err := manager.ContextIdentity(ctx)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"resource_id": ctx.ResourceID,
		}, "error getting identity information from token")
		return jsonapi.JSONErrorResponse(ctx, errors.NewUnauthorizedError(err.Error()))
	}

	roleAssignments := make(map[string][]uuid.UUID)
	for _, assignment := range ctx.Payload.Data {
		for _, id := range assignment.Ids {

			identityIDAsUUID, err := uuid.FromString(id)
			if err != nil {
				log.Error(ctx, map[string]interface{}{
					"resource_id": ctx.ResourceID,
					"identity_id": id,
					"role":        assignment.Role,
				}, "invalid identity ID")
				return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("ids", id).Expected("uuid"))
			}
			if ids, found := roleAssignments[assignment.Role]; found {
				roleAssignments[assignment.Role] = append(ids, identityIDAsUUID)
			} else {
				roleAssignments[assignment.Role] = []uuid.UUID{identityIDAsUUID}
			}
		}
	}
	err = c.app.RoleManagementService().Assign(ctx, *currentIdentity, roleAssignments, ctx.ResourceID, false)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	return ctx.NoContent()
}
1348794
func (r *repository) GetDelegationRoles() ([]data.Role, error) {
	if err := r.updateTUF(false); err != nil {
		return nil, err
	}
	return NewReadOnly(r.tufRepo).GetDelegationRoles()
}
569934
func LoadRole(filename string, section string) (string, error) {
	config, err := ini.Load(filename)
	if err != nil {
		return "", err
	}

	ini, err := config.GetSection(section)
	if err != nil {
		return "", err
	}

	return ini.Key("role_uuid").String(), nil
}
577995
func (c *CreateOrgInvitationOptions) GetRole() string {
	if c == nil || c.Role == nil {
		return ""
	}
	return *c.Role
}
898025
func getKeyRole(s Storage, keyID string) (data.RoleName, error) {
	name := strings.TrimSpace(strings.TrimSuffix(filepath.Base(keyID), filepath.Ext(keyID)))

	for _, file := range s.ListFiles() {
		filename := filepath.Base(file)
		if strings.HasPrefix(filename, name) {
			d, err := s.Get(file)
			if err != nil {
				return "", err
			}

			role, _, err := utils.ExtractPrivateKeyAttributes(d)
			if err != nil {
				return "", err
			}
			return role, nil
		}
	}
	return "", ErrKeyNotFound{KeyID: keyID}
}
1184675
func (tr *Repo) GetDelegationRole(name data.RoleName) (data.DelegationRole, error) {
	if !data.IsDelegation(name) {
		return data.DelegationRole{}, data.ErrInvalidRole{Role: name, Reason: "invalid delegation name"}
	}
	if tr.Root == nil {
		return data.DelegationRole{}, ErrNotLoaded{data.CanonicalRootRole}
	}
	_, ok := tr.Root.Signed.Roles[data.CanonicalTargetsRole]
	if !ok {
		return data.DelegationRole{}, ErrNotLoaded{data.CanonicalTargetsRole}
	}
	// Traverse target metadata, down to delegation itself
	// Get all public keys for the base role from TUF metadata
	_, ok = tr.Targets[data.CanonicalTargetsRole]
	if !ok {
		return data.DelegationRole{}, ErrNotLoaded{data.CanonicalTargetsRole}
	}

	// Start with top level roles in targets. Walk the chain of ancestors
	// until finding the desired role, or we run out of targets files to search.
	var foundRole *data.DelegationRole
	buildDelegationRoleVisitor := func(tgt *data.SignedTargets, validRole data.DelegationRole) interface{} {
		// Try to find the delegation and build a DelegationRole structure
		for _, role := range tgt.Signed.Delegations.Roles {
			if role.Name == name {
				delgRole, err := tgt.BuildDelegationRole(name)
				if err != nil {
					return err
				}
				// Check all public key certificates in the role for expiry
				// Currently we do not reject expired delegation keys but warn if they might expire soon or have already
				for _, pubKey := range delgRole.Keys {
					certFromKey, err := utils.LoadCertFromPEM(pubKey.Public())
					if err != nil {
						continue
					}
					//Don't check the delegation certificate expiry once added, use the TUF role expiry instead
					if err := utils.ValidateCertificate(certFromKey, false); err != nil {
						return err
					}
				}
				foundRole = &delgRole
				return StopWalk{}
			}
		}
		return nil
	}

	// Walk to the parent of this delegation, since that is where its role metadata exists
	err := tr.WalkTargets("", name.Parent(), buildDelegationRoleVisitor)
	if err != nil {
		return data.DelegationRole{}, err
	}

	// We never found the delegation. In the context of this repo it is considered
	// invalid. N.B. it may be that it existed at one point but an ancestor has since
	// been modified/removed.
	if foundRole == nil {
		return data.DelegationRole{}, data.ErrInvalidRole{Role: name, Reason: "delegation does not exist"}
	}

	return *foundRole, nil
}
435363
func (e *Enforcer) GetRolesForUser(name string) []string {
	res, _ := e.model["g"]["g"].RM.GetRoles(name)
	return res
}
816548
func checkRole(bitmask int, role Role) bool {
	return (bitmask & role.getValue()) == role.getValue()
}
369589
func (sp *SignedSnapshot) GetMeta(role RoleName) (*FileMeta, error) {
	if meta, ok := sp.Signed.Meta[role.String()]; ok {
		if _, ok := meta.Hashes["sha256"]; ok {
			return &meta, nil
		}
	}
	return nil, ErrMissingMeta{Role: role.String()}
}
416532
func (e *SyncedEnforcer) GetAllRoles() []string {
	e.m.RLock()
	defer e.m.RUnlock()
	return e.Enforcer.GetAllRoles()
}
1149083
func (api *API) AccountRoles(accountID string) ([]AccountRole, error) {
	uri := "/accounts/" + accountID + "/roles"

	res, err := api.makeRequest("GET", uri, nil)
	if err != nil {
		return []AccountRole{}, errors.Wrap(err, errMakeRequestError)
	}

	var accountRolesListResponse AccountRolesListResponse
	err = json.Unmarshal(res, &accountRolesListResponse)
	if err != nil {
		return []AccountRole{}, errors.Wrap(err, errUnmarshalError)
	}

	return accountRolesListResponse.Result, nil
}
787861
func (p *MySQLPrivilege) FindRole(user string, host string, role *auth.RoleIdentity) bool {
	rec := p.matchUser(user, host)
	r := p.matchUser(role.Username, role.Hostname)
	if rec != nil && r != nil {
		key := rec.User + "@" + rec.Host
		return p.RoleGraph[key].Find(role.Username, role.Hostname)
	}
	return false
}