Read and process all the specialSubject elements

@param configAdmin
@param roleName
@param roleProps
@param pids TODO
9226
private void processSpecialSubjects(ConfigurationAdmin configAdmin,
                                        String roleName,
                                        Dictionary<String, Object> roleProps, Set<String> pids) {

        String[] specialSubjectPids = (String[]) roleProps.get(CFG_KEY_SPECIAL_SUBJECT);
        if (specialSubjectPids == null || specialSubjectPids.length == 0) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "No special subjects in role " + roleName);
            }
        } else {
            Set<String> badSpecialSubjects = new HashSet<String>();
            for (int i = 0; i < specialSubjectPids.length; i++) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "special subject pid " + i + ": " + specialSubjectPids[i]);
                }
                pids.add(specialSubjectPids[i]);
                Configuration specialSubjectConfig = null;
                try {
                    specialSubjectConfig = configAdmin.getConfiguration(specialSubjectPids[i], bundleLocation);
                } catch (IOException ioe) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Invalid special subject entry " + specialSubjectPids[i]);
                    }
                    continue;
                }
                if (specialSubjectConfig == null || specialSubjectConfig.getProperties() == null) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Null special subject element", specialSubjectPids[i]);
                    }
                    continue;
                }

                Dictionary<String, Object> specialSubjectProps = specialSubjectConfig.getProperties();
                final String type = (String) specialSubjectProps.get("type");
                if (type == null || type.trim().isEmpty()) {
                    continue;
                }
                if (badSpecialSubjects.contains(type)) {
                    // This special subject is already flagged as a duplicate
                    continue;
                }
                // TODO: check for invalid type
                if (type.trim().isEmpty()) {
                    // Empty entry, ignoring
                    continue;
                }
                if (!specialSubjects.add(type)) {
                    Tr.error(tc, "AUTHZ_TABLE_DUPLICATE_ROLE_MEMBER", getRoleName(), CFG_KEY_SPECIAL_SUBJECT, type);
                    badSpecialSubjects.add(type);
                    specialSubjects.remove(type);
                }
            }
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Role " + roleName + " has special subjects:", specialSubjects);
            }
        }
    }
1191943
private function prepareRoleCollection (array $roleConfiguration)
    {
        /** @var Role[] $preparedRoles */
        $preparedRoles = [];

        foreach ($roleConfiguration as $roleKey => $configuration)
        {
            $preparedRoles[$roleKey] = Role::createFromConfiguration($roleKey, $configuration);
        }

        // Transform the Actions to Roles
        foreach ($roleConfiguration as $roleKey => $configuration)
        {
            if (!isset($configuration["actions"]) || !is_array($configuration["actions"]))
            {
                continue;
            }

            foreach ($configuration["actions"] as $action)
            {
                if (!isset($preparedRoles[$action]))
                {
                    $preparedRoles[$action] = new BaseRole($action);
                }
            }

            $includedActions = array_map(
                function ($role) use ($preparedRoles)
                {
                    return $preparedRoles[$role];
                },
                $configuration["actions"]
            );

            $preparedRoles[$roleKey]->setIncludedActions($includedActions);
        }

        foreach ($roleConfiguration as $roleKey => $configuration)
        {
            if (!isset($configuration["included_roles"]) || !is_array($configuration["included_roles"]))
            {
                continue;
            }

            $includedRoles = array_map(
                function ($role) use ($preparedRoles)
                {
                    return $preparedRoles[$role];
                },
                $configuration["included_roles"]
            );

            $preparedRoles[$roleKey]->setIncludedRoles($includedRoles);
        }

        return $preparedRoles;
    }
279642
public void setAuthorizingRoles(String roles) {
        // The ConfigAttributeEditor is named incorrectly, so you can't use it
        // to automatically convert the string to a ConfigAttributeDefinition.
        // So, we do it manually :-(

        ConfigAttributeEditor editor = new ConfigAttributeEditor();
        editor.setAsText( roles );
        this.roles = (List<ConfigAttribute>) editor.getValue();
        rolesString = roles;
    }
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);
        }
    }
392927
public void importUserRole(String roleName) {

        if ((m_throwable != null) || (m_user == null)) {
            return;
        }
        try {
            CmsRole role = CmsRole.valueOfRoleName(roleName);
            try {
                // check if the organizational unit exists
                OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), role.getOuFqn());
                // set the user role
                OpenCms.getRoleManager().addUserToRole(getCms(), role, m_user.getName());
                return;
            } catch (CmsDbEntryNotFoundException e) {
                // organizational unit does not exist
            }
            // remember the user and role for later
            Map<String, Map<String, String>> membership = m_membership.get(role.getOuFqn());
            if (membership == null) {
                membership = new HashMap<String, Map<String, String>>();
                m_membership.put(role.getOuFqn(), membership);
            }
            Map<String, String> roles = membership.get(I_CmsPrincipal.PRINCIPAL_USER);
            if (roles == null) {
                roles = new HashMap<String, String>();
                membership.put(I_CmsPrincipal.PRINCIPAL_USER, roles);
            }
            roles.put(m_user.getName(), role.getFqn());
        } catch (Throwable e) {
            getReport().println(
                Messages.get().container(Messages.RPT_USER_COULDNT_BE_ADDED_TO_ROLE_2, m_user.getName(), roleName),
                I_CmsReport.FORMAT_WARNING);
            if (LOG.isDebugEnabled()) {
                LOG.debug(e.getLocalizedMessage(), e);
            }
        }
    }
1370319
def configure_roles_on_host(api, host):
  
  for role_ref in host.roleRefs:
    # Mgmt service/role has no cluster name. Skip over those.
    if role_ref.get('clusterName') is None:
      continue

    # Get the role and inspect the role type
    role = api.get_cluster(role_ref['clusterName'])\
              .get_service(role_ref['serviceName'])\
              .get_role(role_ref['roleName'])
    LOG.debug("Evaluating %s (%s)" % (role.name, host.hostname))

    config = None
    if role.type == 'DATANODE':
      config = DATANODE_CONF
    elif role.type == 'TASKTRACKER':
      config = TASKTRACKER_CONF
    elif role.type == 'REGIONSERVER':
      config = REGIONSERVER_CONF
    else:
      continue

    # Set the config
    LOG.info("Configuring %s (%s)" % (role.name, host.hostname))
    role.update_config(config)
684301
public final void setItsRole(final RoleJetty pRole) {
    this.itsRole = pRole;
    if (this.itsId == null) {
      this.itsId = new IdUserRoleJetty();
    }
    this.itsId.setItsRole(this.itsRole);
  }
999426
protected void parseProcessEnginePlugins(Element element, List<ProcessEnginePluginXml> plugins) {
    for (Element chidElement : element.elements()) {
      if(PLUGIN.equals(chidElement.getTagName())) {
        parseProcessEnginePlugin(chidElement, plugins);
      }
    }
  }
759348
async function findRoleUsers (roleId, roleMembershipModel, rbac) {
  const userIds = [ ]
  for (const inheritedRoleId of rbac.inheritedBy[roleId]) {
    userIds.push(...await findUserIds(inheritedRoleId, roleMembershipModel))
  } // for ...

  return uniqify(userIds)
}
1024022
protected void processIncludes(Map<String, String> mergeProps, URL rootURL, String includeProps) {
        if (includeProps == null)
            return;

        String props[] = includeProps.trim().split("\\s*,\\s*");
        for (String pname : props) {
            mergeProperties(mergeProps, rootURL, pname);
        }
    }
425673
protected function initialize()
    {
        if ($this->initialized) {
            return;
        }

        $this->policyConfiguration = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_POLICY);
        $this->emitConfigurationLoaded($this->policyConfiguration);

        $this->initializePrivilegeTargets();

        $privilegeTargetsForEverybody = $this->privilegeTargets;

        $this->roles = [];
        $everybodyRole = new Role('Neos.Flow:Everybody');
        $everybodyRole->setAbstract(true);
        if (isset($this->policyConfiguration['roles'])) {
            foreach ($this->policyConfiguration['roles'] as $roleIdentifier => $roleConfiguration) {
                if ($roleIdentifier === 'Neos.Flow:Everybody') {
                    $role = $everybodyRole;
                } else {
                    $role = new Role($roleIdentifier);
                    if (isset($roleConfiguration['abstract'])) {
                        $role->setAbstract((boolean)$roleConfiguration['abstract']);
                    }
                }

                if (isset($roleConfiguration['privileges'])) {
                    foreach ($roleConfiguration['privileges'] as $privilegeConfiguration) {
                        $privilegeTargetIdentifier = $privilegeConfiguration['privilegeTarget'];
                        if (!isset($this->privilegeTargets[$privilegeTargetIdentifier])) {
                            throw new SecurityException(sprintf('privilege target "%s", referenced in role configuration "%s" is not defined!', $privilegeTargetIdentifier, $roleIdentifier), 1395869320);
                        }
                        $privilegeTarget = $this->privilegeTargets[$privilegeTargetIdentifier];
                        if (!isset($privilegeConfiguration['permission'])) {
                            throw new SecurityException(sprintf('No permission set for privilegeTarget "%s" in Role "%s"', $privilegeTargetIdentifier, $roleIdentifier), 1395869331);
                        }
                        $privilegeParameters = isset($privilegeConfiguration['parameters']) ? $privilegeConfiguration['parameters'] : [];
                        try {
                            $privilege = $privilegeTarget->createPrivilege($privilegeConfiguration['permission'], $privilegeParameters);
                        } catch (\Exception $exception) {
                            throw new SecurityException(sprintf('Error for privilegeTarget "%s" in Role "%s": %s', $privilegeTargetIdentifier, $roleIdentifier, $exception->getMessage()), 1401886654, $exception);
                        }
                        $role->addPrivilege($privilege);

                        if ($roleIdentifier === 'Neos.Flow:Everybody') {
                            unset($privilegeTargetsForEverybody[$privilegeTargetIdentifier]);
                        }
                    }
                }

                $this->roles[$roleIdentifier] = $role;
            }
        }

        // create ABSTAIN privilege for all uncovered privilegeTargets
        /** @var PrivilegeTarget $privilegeTarget */
        foreach ($privilegeTargetsForEverybody as $privilegeTarget) {
            if ($privilegeTarget->hasParameters()) {
                continue;
            }
            $everybodyRole->addPrivilege($privilegeTarget->createPrivilege(PrivilegeInterface::ABSTAIN));
        }
        $this->roles['Neos.Flow:Everybody'] = $everybodyRole;

        // Set parent roles
        /** @var Role $role */
        foreach ($this->roles as $role) {
            if (isset($this->policyConfiguration['roles'][$role->getIdentifier()]['parentRoles'])) {
                foreach ($this->policyConfiguration['roles'][$role->getIdentifier()]['parentRoles'] as $parentRoleIdentifier) {
                    $role->addParentRole($this->roles[$parentRoleIdentifier]);
                }
            }
        }

        $this->emitRolesInitialized($this->roles);

        $this->initialized = true;
    }
884733
function defineManyRoles(roleMap) {
    if (!angular.isObject(roleMap)) {
      throw new TypeError('Parameter "roleNames" name must be object');
    }

    angular.forEach(roleMap, function (validationFunction, roleName) {
      defineRole(roleName, validationFunction);
    });
  }
46795
protected Map<String, Role> parseDefinedRoles(Config config) {
        // Parse the defined Roles
        Map<String, Role> roleMap = new HashMap<>();
        if (!config.hasPath("roles")) {
            log.trace("'{}' has no roles", config);
        } else if (config.hasPath("roles")) {
            log.trace("Parsing Role definitions");
            Config roleConfig = config.getConfig("roles");
            for (Map.Entry<String, ConfigValue> entry : roleConfig.entrySet()) {
                String name = entry.getKey();
                List<String> permissions = roleConfig.getStringList(name);
                Role role = new Role(name, permissions.toArray(new String[permissions.size()]));
                roleMap.put(role.getName(), role);
            }
        }

        return Collections.unmodifiableMap(roleMap);
    }
473208
@Override
  public final void setItsId(final IdUserRoleJetty pId) {
    this.itsId = pId;
    if (this.itsId == null) {
      this.itsUser = null;
      this.itsRole = null;
    } else {
      this.itsUser = this.itsId.getItsUser();
      this.itsRole = this.itsId.getItsRole();
    }
  }
685254
public void doPostProcessing(ApplicationContext ctx) {
        checkInitialised();
        for (GrailsPlugin plugin : pluginList) {
            if(isPluginDisabledForProfile(plugin)) continue;
            if (plugin.supportsCurrentScopeAndEnvironment()) {
                plugin.doWithApplicationContext(ctx);
            }
        }
    }
858612
private void processNewEdge(int role, int b) {
        final RoleSet roleClosure = getRoleClosure(role);
        processRole(role, b);
        for (int s = roleClosure.first(); s >= 0; s = roleClosure.next(s + 1)) {
            if (s == role)
                continue;
            processRole(s, b);
        }
    }
728612
public static function load_roles_to_tempids($restoreid, $rolesfile) {

        if (!file_exists($rolesfile)) { // Shouldn't happen ever, but...
            throw new backup_helper_exception('missing_roles_xml_file', $rolesfile);
        }
        // Let's parse, custom processor will do its work, sending info to DB
        $xmlparser = new progressive_parser();
        $xmlparser->set_file($rolesfile);
        $xmlprocessor = new restore_roles_parser_processor($restoreid);
        $xmlparser->set_processor($xmlprocessor);
        $xmlparser->process();
    }