Search in sources :

Example 6 with ApplicationPrivilege

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

the class ApplicationPrivilegeCLITest method createApplicationPrivilege.

@Test
public void createApplicationPrivilege() throws Exception {
    String[] args = new String[17];
    args[0] = "add-app-priv";
    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_ACTIONS;
    args[8] = ApplicationPrivilegeBase.PARAM_ACTION_ALL;
    args[9] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_SUBJECT_TYPE;
    args[10] = ApplicationPrivilegeBase.PARAM_SUBJECT_USER;
    args[11] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_SUBJECTS;
    args[12] = user1.getUniversalId();
    args[13] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_DESCRIPTION;
    args[14] = "desc";
    args[15] = CLIConstants.PREFIX_ARGUMENT_LONG + ApplicationPrivilegeBase.PARAM_RESOURCES;
    args[16] = "http://www.example.com";
    CLIRequest req = new CLIRequest(null, args, adminToken);
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance("/", adminSubject);
    ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
    if (!ap.getDescription().equals("desc")) {
        throw new Exception("ApplicationPrivilegeCLITest.createApplicationPrivilege: " + "description is incorrect.");
    }
    if (!ap.getActionValues().equals(ApplicationPrivilege.PossibleAction.READ_MODIFY_DELEGATE)) {
        throw new Exception("ApplicationPrivilegeCLITest.createApplicationPrivilege: " + "actions is incorrect.");
    }
    Set<String> resources = new HashSet<String>();
    resources.add("http://www.example.com");
    validateResources(ap, resources, "createApplicationPrivilege");
    Set<AMIdentity> users = new HashSet<AMIdentity>();
    users.add(user1);
    validateSubjects(ap, users, "createApplicationPrivilege");
}
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) IdRepoException(com.sun.identity.idm.IdRepoException) EntitlementException(com.sun.identity.entitlement.EntitlementException) SSOException(com.iplanet.sso.SSOException) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 7 with ApplicationPrivilege

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

the class ApplicationPrivilegeCLITest method removeResources.

@Test(dependsOnMethods = "addResources")
public void removeResources() throws Exception {
    String[] args = new String[9];
    args[0] = "remove-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";
    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");
    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 8 with ApplicationPrivilege

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

the class ApplicationPrivilegeCLITest method changeAction.

@Test(dependsOnMethods = "changeDescription")
public void changeAction() throws Exception {
    String[] args = new String[7];
    args[0] = "update-app-priv";
    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_ACTIONS;
    args[6] = ApplicationPrivilegeBase.PARAM_ACTION_DELEGATE;
    CLIRequest req = new CLIRequest(null, args, adminToken);
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance("/", adminSubject);
    ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
    if (!ap.getActionValues().equals(ApplicationPrivilege.PossibleAction.READ_DELEGATE)) {
        throw new Exception("ApplicationPrivilegeCLITest.changeAction: " + "action is incorrect.");
    }
}
Also used : ApplicationPrivilege(com.sun.identity.entitlement.ApplicationPrivilege) CLIRequest(com.sun.identity.cli.CLIRequest) ApplicationPrivilegeManager(com.sun.identity.entitlement.ApplicationPrivilegeManager) IdRepoException(com.sun.identity.idm.IdRepoException) EntitlementException(com.sun.identity.entitlement.EntitlementException) SSOException(com.iplanet.sso.SSOException) Test(org.testng.annotations.Test)

Example 9 with ApplicationPrivilege

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

the class ApplicationPrivilegeCLITest method changeDescription.

@Test(dependsOnMethods = "listApplicationPrivileges")
public void changeDescription() throws Exception {
    String[] args = new String[7];
    args[0] = "update-app-priv";
    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_DESCRIPTION;
    args[6] = "descChanged";
    CLIRequest req = new CLIRequest(null, args, adminToken);
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance("/", adminSubject);
    ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
    if (!ap.getDescription().equals("descChanged")) {
        throw new Exception("ApplicationPrivilegeCLITest.changeDescription: " + "description is incorrect.");
    }
}
Also used : ApplicationPrivilege(com.sun.identity.entitlement.ApplicationPrivilege) CLIRequest(com.sun.identity.cli.CLIRequest) ApplicationPrivilegeManager(com.sun.identity.entitlement.ApplicationPrivilegeManager) IdRepoException(com.sun.identity.idm.IdRepoException) EntitlementException(com.sun.identity.entitlement.EntitlementException) SSOException(com.iplanet.sso.SSOException) Test(org.testng.annotations.Test)

Example 10 with ApplicationPrivilege

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

the class ApplicationPrivilegeCLITest method setResources.

@Test(dependsOnMethods = "removeSubjects")
public void setResources() 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.example1.com";
    args[9] = "http://www.example2.com";
    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");
    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)

Aggregations

ApplicationPrivilege (com.sun.identity.entitlement.ApplicationPrivilege)21 ApplicationPrivilegeManager (com.sun.identity.entitlement.ApplicationPrivilegeManager)19 EntitlementException (com.sun.identity.entitlement.EntitlementException)12 HashSet (java.util.HashSet)10 CLIRequest (com.sun.identity.cli.CLIRequest)9 Test (org.testng.annotations.Test)9 CLIException (com.sun.identity.cli.CLIException)7 Subject (javax.security.auth.Subject)7 SubjectImplementation (com.sun.identity.entitlement.SubjectImplementation)6 Set (java.util.Set)5 AMIdentity (com.sun.identity.idm.AMIdentity)4 SSOException (com.iplanet.sso.SSOException)3 IPrivilege (com.sun.identity.entitlement.IPrivilege)3 Privilege (com.sun.identity.entitlement.Privilege)3 ReferralPrivilege (com.sun.identity.entitlement.ReferralPrivilege)3 IdRepoException (com.sun.identity.idm.IdRepoException)3 Entitlement (com.sun.identity.entitlement.Entitlement)2 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)2 OrSubject (com.sun.identity.entitlement.OrSubject)2 PrivilegeManager (com.sun.identity.entitlement.PrivilegeManager)2