private void addUserToPrivilege() throws EntitlementException {
   ApplicationPrivilegeManager mgr =
       ApplicationPrivilegeManager.getInstance(SUB_REALM, PrivilegeManager.superAdminSubject);
   ApplicationPrivilege ap = mgr.getPrivilege(DELEGATE_PRIVILEGE_NAME);
   Set<SubjectImplementation> eSubjects = new HashSet<SubjectImplementation>();
   OpenSSOUserSubject sbj = new OpenSSOUserSubject();
   sbj.setID(delegatedUser.getUniversalId());
   eSubjects.add(sbj);
   OpenSSOUserSubject sbj1 = new OpenSSOUserSubject();
   sbj1.setID(delegatedUser1.getUniversalId());
   eSubjects.add(sbj1);
   ap.setSubject(eSubjects);
   mgr.replacePrivilege(ap);
 }
  private void addPrivilege() throws EntitlementException {
    ApplicationPrivilegeManager mgr =
        ApplicationPrivilegeManager.getInstance(SUB_REALM, PrivilegeManager.superAdminSubject);
    ApplicationPrivilege ap = new ApplicationPrivilege(DELEGATE_PRIVILEGE_NAME);
    OpenSSOUserSubject sbj = new OpenSSOUserSubject();
    sbj.setID(delegatedUser.getUniversalId());
    Set<SubjectImplementation> subjects = new HashSet<SubjectImplementation>();
    subjects.add(sbj);
    ap.setSubject(subjects);

    Map<String, Set<String>> appRes = new HashMap<String, Set<String>>();
    Set<String> res = new HashSet<String>();
    appRes.put(ApplicationTypeManager.URL_APPLICATION_TYPE_NAME, res);
    res.add(DELEGATED_RESOURCE);
    ap.setApplicationResources(appRes);
    ap.setActionValues(ApplicationPrivilege.PossibleAction.READ_MODIFY_DELEGATE);
    mgr.addPrivilege(ap);
  }