/** * 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; }
/** * 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); } }
/** * 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; }
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; }
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; }
public static GroupI createGroup(StemI parent, String systemName, String displayName) throws GroupAddException, InsufficientPrivilegeException { return parent.addChildGroup(systemName, displayName); }
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); }
public static void deleteStem(StemI stem) throws InsufficientPrivilegeException, StemDeleteException { stem.delete(); }
public static void addStem(StemI parent, String systemName, String displayName) throws InsufficientPrivilegeException, StemAddException { parent.addChildStem(systemName, displayName); }