code: public void setCompanies(final JAASSystem _jaasSystem,
                               final Set<Company> _companies)
          throws EFapsException
      {
  
          if (_jaasSystem == null) {
              throw new EFapsException(getClass(), "setRoles.nojaasSystem", getName());
          }
          if (_companies == null) {
              throw new EFapsException(getClass(), "setRoles.noRoles", getName());
          }
          for (final Company company : _companies) {
              add(company);
          }
  
          // current roles
          final Set<Company> companiesInDb = getCompaniesFromDB(_jaasSystem);
  
          // compare new Companies with current Companies (add missing Companies)
          for (final Company company : _companies) {
              if (!companiesInDb.contains(company)) {
                  assignCompanyInDb(_jaasSystem, company);
              }
          }
  
          // compare current Companies with new Companies (remove Companies which are to much)
          for (final Company company : companiesInDb) {
              if (!_companies.contains(company)) {
                  unassignCompanyInDb(_jaasSystem, company);
              }
          }
      }
docs: The depending roles for the user are set for the given JAAS system. All
  roles are added to the loaded roles in the cache of this person.
  
  @param _jaasSystem JAAS system for which the roles are set
  @param _companies set of company to set for the JAAS system
  @throws EFapsException from calling methods