Пример #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;
  }
Пример #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);
 }