Search in sources :

Example 21 with ApplicationPrivilegeManager

use of com.sun.identity.entitlement.ApplicationPrivilegeManager in project OpenAM by OpenRock.

the class RealmRemovedTest method createApplicationPrivilege.

private void createApplicationPrivilege() throws EntitlementException {
    ApplicationPrivilegeManager mgr = ApplicationPrivilegeManager.getInstance(SUB_REALM1, SubjectUtils.createSubject(adminToken));
    ApplicationPrivilege ap = new ApplicationPrivilege(APP_PRIVILEGE_NAME);
    OpenSSOUserSubject sbj = new OpenSSOUserSubject();
    sbj.setID("ou=dummy,ou=user,dc=openam,dc=forgerock,dc=org");
    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("http://www.RealmRemovedTest.com/*");
    ap.setApplicationResources(appRes);
    ap.setActionValues(ApplicationPrivilege.PossibleAction.READ_MODIFY_DELEGATE);
    mgr.addPrivilege(ap);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ApplicationPrivilege(com.sun.identity.entitlement.ApplicationPrivilege) ApplicationPrivilegeManager(com.sun.identity.entitlement.ApplicationPrivilegeManager) SubjectImplementation(com.sun.identity.entitlement.SubjectImplementation) HashSet(java.util.HashSet)

Example 22 with ApplicationPrivilegeManager

use of com.sun.identity.entitlement.ApplicationPrivilegeManager in project OpenAM by OpenRock.

the class RealmRemovedTest method test.

@Test
public void test() throws Exception {
    if (!migrated) {
        return;
    }
    OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, "/");
    String subRealm = SUB_REALM1.substring(1);
    ocm.deleteSubOrganization(subRealm, true);
    // application privilege should be removed.
    ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance("/", adminSubject);
    try {
        apm.getPrivilege(APP_PRIVILEGE_NAME);
    } catch (EntitlementException e) {
        if (e.getErrorCode() != 325) {
            throw e;
        }
    }
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) ApplicationPrivilegeManager(com.sun.identity.entitlement.ApplicationPrivilegeManager) Test(org.testng.annotations.Test)

Example 23 with ApplicationPrivilegeManager

use of com.sun.identity.entitlement.ApplicationPrivilegeManager in project OpenAM by OpenRock.

the class ApplicationPrivilegeCLITest method addSubjects.

@Test(dependsOnMethods = "setSubjects")
public void addSubjects() throws Exception {
    String[] args = new String[10];
    args[0] = "update-app-priv-subjects";
    args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME;
    args[2] = "/";
    args[3] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_NAME;
    args[4] = PRIVILEGE_NAME;
    args[5] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_SUBJECT_TYPE;
    args[6] = ApplicationPrivilegeBase.PARAM_SUBJECT_USER;
    args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_SUBJECTS;
    args[8] = user1.getUniversalId();
    args[9] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_ADD;
    CLIRequest req = new CLIRequest(null, args, adminToken);
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance("/", adminSubject);
    ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
    Set<AMIdentity> users = new HashSet<AMIdentity>();
    users.add(user1);
    users.add(user2);
    validateSubjects(ap, users, "setSubjects");
}
Also used : ApplicationPrivilege(com.sun.identity.entitlement.ApplicationPrivilege) AMIdentity(com.sun.identity.idm.AMIdentity) CLIRequest(com.sun.identity.cli.CLIRequest) ApplicationPrivilegeManager(com.sun.identity.entitlement.ApplicationPrivilegeManager) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 24 with ApplicationPrivilegeManager

use of com.sun.identity.entitlement.ApplicationPrivilegeManager in project OpenAM by OpenRock.

the class ApplicationPrivilegeCLITest method addResources.

@Test(dependsOnMethods = "setResources")
public void addResources() throws Exception {
    String[] args = new String[10];
    args[0] = "update-app-priv-resources";
    args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME;
    args[2] = "/";
    args[3] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_NAME;
    args[4] = PRIVILEGE_NAME;
    args[5] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_APPL_NAME;
    args[6] = ApplicationTypeManager.URL_APPLICATION_TYPE_NAME;
    args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_RESOURCES;
    args[8] = "http://www.example3.com";
    args[9] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_ADD;
    CLIRequest req = new CLIRequest(null, args, adminToken);
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance("/", adminSubject);
    ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
    Set<String> resources = new HashSet<String>();
    resources.add("http://www.example1.com");
    resources.add("http://www.example2.com");
    resources.add("http://www.example3.com");
    validateResources(ap, resources, "setResources");
}
Also used : ApplicationPrivilege(com.sun.identity.entitlement.ApplicationPrivilege) CLIRequest(com.sun.identity.cli.CLIRequest) ApplicationPrivilegeManager(com.sun.identity.entitlement.ApplicationPrivilegeManager) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 25 with ApplicationPrivilegeManager

use of com.sun.identity.entitlement.ApplicationPrivilegeManager in project OpenAM by OpenRock.

the class ApplicationPrivilegeCLITest method removeSubjects.

@Test(dependsOnMethods = "addSubjects")
public void removeSubjects() throws Exception {
    String[] args = new String[9];
    args[0] = "remove-app-priv-subjects";
    args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME;
    args[2] = "/";
    args[3] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_NAME;
    args[4] = PRIVILEGE_NAME;
    args[5] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_SUBJECT_TYPE;
    args[6] = ApplicationPrivilegeBase.PARAM_SUBJECT_USER;
    args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_SUBJECTS;
    args[8] = user2.getUniversalId();
    CLIRequest req = new CLIRequest(null, args, adminToken);
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance("/", adminSubject);
    ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
    Set<AMIdentity> users = new HashSet<AMIdentity>();
    users.add(user1);
    validateSubjects(ap, users, "setSubjects");
}
Also used : ApplicationPrivilege(com.sun.identity.entitlement.ApplicationPrivilege) AMIdentity(com.sun.identity.idm.AMIdentity) CLIRequest(com.sun.identity.cli.CLIRequest) ApplicationPrivilegeManager(com.sun.identity.entitlement.ApplicationPrivilegeManager) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

ApplicationPrivilegeManager (com.sun.identity.entitlement.ApplicationPrivilegeManager)26 ApplicationPrivilege (com.sun.identity.entitlement.ApplicationPrivilege)18 EntitlementException (com.sun.identity.entitlement.EntitlementException)18 Test (org.testng.annotations.Test)11 CLIRequest (com.sun.identity.cli.CLIRequest)10 HashSet (java.util.HashSet)10 Subject (javax.security.auth.Subject)9 SSOException (com.iplanet.sso.SSOException)8 CLIException (com.sun.identity.cli.CLIException)8 Set (java.util.Set)6 PrivilegeIndexStore (com.sun.identity.entitlement.PrivilegeIndexStore)5 SubjectImplementation (com.sun.identity.entitlement.SubjectImplementation)4 AMIdentity (com.sun.identity.idm.AMIdentity)4 SMSEntry (com.sun.identity.sm.SMSEntry)4 SMSException (com.sun.identity.sm.SMSException)4 SSOToken (com.iplanet.sso.SSOToken)3 IPrivilege (com.sun.identity.entitlement.IPrivilege)3 IdRepoException (com.sun.identity.idm.IdRepoException)3 Policy (com.sun.identity.policy.Policy)3 PolicyException (com.sun.identity.policy.PolicyException)3