Adds a new role to the list of defined roles.

@param roleName - The name of the role being added.
172898
public synchronized void addRoleMapping(final String roleName) {
        HashMap<String, RoleMappingImpl> newRoles = new HashMap<String, RoleMappingImpl>(roleMappings);
        if (newRoles.containsKey(roleName) == false) {
            newRoles.put(roleName, new RoleMappingImpl(roleName));
            roleMappings = Collections.unmodifiableMap(newRoles);
        }
    }
1189632
def add_role role
      raise ArgumentError, '#add_role takes a single role String or Symbol as the argument' if !role || role.kind_of?(Array)
      add_roles role
    end
447037
def add_role(role, reason = nil)
      role_ids = role_id_array(role)

      if role_ids.count == 1
        API::Server.add_member_role(@bot.token, @server.id, @user.id, role_ids[0], reason)
      else
        old_role_ids = @roles.map(&:id)
        new_role_ids = (old_role_ids + role_ids).uniq
        API::Server.update_member(@bot.token, @server.id, @user.id, roles: new_role_ids, reason: reason)
      end
    end
986421
def assign(self, role):
        ''''''
        if role.owner_id != self.id:
            return self.roles.add(role)
323916
public function addRole($name)
    {
        $namespaceUri = $this->dom->lookupNamespaceUri($this->dom->namespaceURI);

        $roleNode = $this->dom->createElementNS($namespaceUri, 'Role');
        $roleNode->setAttribute('name', $name);

        $instancesNode = $this->dom->createElementNS($namespaceUri, 'Instances');
        $instancesNode->setAttribute('count', '2');

        $configurationSettings = $this->dom->createElementNS($namespaceUri, 'ConfigurationSettings');

        $roleNode->appendChild($instancesNode);
        $roleNode->appendChild($configurationSettings);

        $this->dom->documentElement->appendChild($roleNode);

        $this->save();
    }
717137
public synchronized void addUserToRole(String userName, String roleName)
    {
        HashSet userSet = (HashSet)_roles.get(roleName);
        if (userSet==null)
        {
            userSet=new HashSet(11);
            _roles.put(roleName,userSet);
        }
        userSet.add(userName);
    }
477696
public void grant(String granteeName, String roleName, Grantee grantor) {

        Grantee grantee = get(granteeName);

        if (grantee == null) {
            throw Error.error(ErrorCode.X_28501, granteeName);
        }

        if (isImmutable(granteeName)) {
            throw Error.error(ErrorCode.X_28502, granteeName);
        }

        Grantee role = getRole(roleName);

        if (role == null) {
            throw Error.error(ErrorCode.X_0P000, roleName);
        }

        if (role == grantee) {
            throw Error.error(ErrorCode.X_0P501, granteeName);
        }

        // boucherb@users 20050515
        // SQL 2003 Foundation, 4.34.3
        // No cycles of role grants are allowed.
        if (role.hasRole(grantee)) {

            // boucherb@users

            /** @todo: Correct reporting of actual grant path */
            throw Error.error(ErrorCode.X_0P501, roleName);
        }

        if (!grantor.isGrantable(role)) {
            throw Error.error(ErrorCode.X_0L000, grantor.getNameString());
        }

        grantee.grant(role);
        grantee.updateAllRights();

        if (grantee.isRole) {
            updateAllRights(grantee);
        }
    }
530674
public static boolean hasRole(String roleName) {
        return getSubject() != null && roleName != null
                && roleName.length() > 0 && getSubject().hasRole(roleName);
    }
419674
@Override
    public void addRole(final String role) {
        CommonHelper.assertNotBlank("role", role);
        this.roles.add(role);
    }
588770
@Override
	public void renameRole(String oldrole, String newrole) throws RolesException {
		if (role_list.containsKey(oldrole)) {
			List<String> users_with_role = role_list.get(oldrole);
			for (String user : users_with_role) {
				// Remove the role from this user
				List<String> roles_of_user = user_list.get(user);
				roles_of_user.remove(oldrole);
				roles_of_user.add(newrole);
				user_list.put(user, roles_of_user);

				// Update our file_store
				String roles = StringUtils.join(roles_of_user.toArray(new String[0]), ",");
				file_store.setProperty(user, roles);
			}
			// Replace the role entry
			role_list.remove(oldrole);
			role_list.put(newrole, users_with_role);

			// And commit the file_store to disk
			try {
				saveRoles();
			} catch (IOException e) {
				throw new RolesException(e);
			}
		} else {
			throw new RolesException("Cannot find role '" + oldrole + "'!");
		}
	}
211377
def create_role(self, **kwargs):
        """"""

        role = self.role_model(**kwargs)
        return self.put(role)
398970
private void appendRoles(final StringBuilder builder, final User user) {
        for (final UserRoleName role : user.getRoles()) {
            append(builder, ",", role.name());
        }
    }
618904
def role_add(user, role):
    '''
    
    '''
    ret = {}

    ## validate roles
    roles = role.split(',')
    known_roles = role_list().keys()
    valid_roles = [r for r in roles if r in known_roles]
    log.debug(
        'rbac.role_add - roles=%s, known_roles=%s, valid_roles=%s',
        roles,
        known_roles,
        valid_roles,
    )

    ## update user roles
    if valid_roles:
        res = __salt__['cmd.run_all']('usermod -R "{roles}" {login}'.format(
            login=user,
            roles=','.join(set(role_get(user) + valid_roles)),
        ))
        if res['retcode'] > 0:
            ret['Error'] = {
                'retcode': res['retcode'],
                'message': res['stderr'] if 'stderr' in res else res['stdout']
            }
            return ret

    ## update return value
    active_roles = role_get(user)
    for r in roles:
        if r not in valid_roles:
            ret[r] = 'Unknown'
        elif r in active_roles:
            ret[r] = 'Added'
        else:
            ret[r] = 'Failed'

    return ret
819534
public Authorizations addRoles(Collection<Role> roles) {
        this.roles.addAll(roles);
        this.aggregatePermissions = null;

        return this;
    }
1366208
public function inheritRole($roleName)
    {
        if (empty($roleName)) {
            throw new PropertyNotValid('Role name cannot be empty.');
        }

        if ($roleName === $this->getName()) {
            throw new PropertyNotValid('Role cannot be added to itself.');
        }

        if ($this->hasRole($roleName)) {
            return;
        }

        $this->roles[] = $roleName;
    }
1343204
protected function addRole()
    {
        if (!$this->isError()) {
            $id = $this->role->add($this->getSubmitted());
            if (empty($id)) {
                $this->errorAndExit($this->text('Unexpected result'));
            }
            $this->line($id);
        }
    }
250985
public void addPermission(String roleName, String capability) {
    Permission permission = new Permission();
    permission.setRoleName(roleName);
    permission.setCapability(capability);
    this.permissions.add(permission);
  }