Пример #1
0
 /**
  * Return a stem with matching display extension, or null if that stem doesn't exist
  *
  * @return
  */
 public static StemI findChildStem(StemI parentStem, String displayExtension) {
   Set<StemI> existingStems = parentStem.getChildStems();
   for (StemI stem : existingStems) {
     if (stem.getDisplayExtension().equals(displayExtension)) {
       return stem;
     }
   }
   return null;
 }
Пример #2
0
 /**
  * WARNING: this will remove all sub-groups and sub-stems recursively. The stem itself is left
  * unchanged.
  *
  * @param stem
  * @throws InsufficientPrivilegeException
  * @throws GroupDeleteException
  * @throws StemDeleteException
  */
 public static void deleteStemHierarchy(StemI curStem)
     throws GroupDeleteException, InsufficientPrivilegeException, StemDeleteException {
   Set<StemI> subStems = (Set<StemI>) curStem.getChildStems();
   for (StemI stem : subStems) {
     deleteStemHierarchy(stem);
     stem.delete();
   }
   Set<GroupI> groups = (Set<GroupI>) curStem.getChildGroups();
   for (GroupI group : groups) {
     deleteGroup(group);
   }
 }
Пример #3
0
 /**
  * Return a stem with matching group (sytem) extension, or null if that group doesn't exist
  *
  * @param groupExtension the extension of the group to find
  * @return
  */
 public static GroupI findChildGroup(StemI stem, String groupExtension) {
   Set<GroupI> groups = stem.getChildGroups();
   for (GroupI group : groups) {
     if (group.getExtension().equals(groupExtension)) {
       return group;
     }
   }
   return null;
 }
Пример #4
0
 public static boolean subgroupExists(StemI stem, String systemNameOfGroup) {
   Set<GroupI> existingGroups = stem.getChildGroups();
   for (GroupI group : existingGroups) {
     if (group.getExtension().equals(systemNameOfGroup)) {
       return true;
     }
   }
   return false;
 }
Пример #5
0
  private String addUpdatePrivilege(boolean wasSelected, boolean selectedNow, Privilege priv)
      throws Exception {
    String id = Utils.clean(getIdentity().getText());
    Subject subj = SubjectUtils.getSubject(id);
    if (update) {
      if (!wasSelected && selectedNow) {
        try {
          targetStem.grantPriv(subj, priv);
          return "GRANTED " + priv.getName() + " privilege.";
        } catch (Exception e) {
          FaultUtil.logFault(log, e);
          throw new Exception("ERROR granting " + priv.getName() + " privilege: " + e.getMessage());
        }

      } else if (wasSelected && !selectedNow) {
        try {
          targetStem.revokePriv(subj, priv);
          return "REVOKED " + priv.getName() + " privilege.";
        } catch (Exception e) {
          FaultUtil.logFault(log, e);
          throw new Exception("ERROR revoking " + priv.getName() + " privilege: " + e.getMessage());
        }
      }
    } else {
      if (selectedNow) {
        try {
          targetStem.grantPriv(subj, priv);
          return "GRANTED " + priv.getName() + " privilege.";
        } catch (Exception e) {
          FaultUtil.logFault(log, e);
          throw new Exception("ERROR granting " + priv.getName() + " privilege: " + e.getMessage());
        }
      }
    }
    return null;
  }
Пример #6
0
 public static GroupI createGroup(StemI parent, String systemName, String displayName)
     throws GroupAddException, InsufficientPrivilegeException {
   return parent.addChildGroup(systemName, displayName);
 }
Пример #7
0
 public static void addGroupPrivilege(String identity, StemI stem)
     throws GrantPrivilegeException, InsufficientPrivilegeException, SchemaException,
         SubjectNotFoundException {
   Subject subject = SubjectUtils.getSubject(identity);
   stem.grantPriv(subject, edu.internet2.middleware.grouper.NamingPrivilege.CREATE);
 }
Пример #8
0
 public static void deleteStem(StemI stem)
     throws InsufficientPrivilegeException, StemDeleteException {
   stem.delete();
 }
Пример #9
0
 public static void addStem(StemI parent, String systemName, String displayName)
     throws InsufficientPrivilegeException, StemAddException {
   parent.addChildStem(systemName, displayName);
 }