Exemplo n.º 1
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;
  }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
 public static boolean isMember(String identity, GroupI group) throws SubjectNotFoundException {
   Subject subject = SubjectUtils.getSubject(identity);
   return group.hasMember(subject);
 }
Exemplo n.º 4
0
 public static void removeGroupMember(GroupI group, String identity)
     throws SubjectNotFoundException, InsufficientPrivilegeException, MemberDeleteException {
   Subject subject = SubjectUtils.getSubject(identity);
   group.deleteMember(subject);
 }