Search in sources :

Example 1 with ApplicationServiceFactory

use of org.forgerock.openam.entitlement.service.ApplicationServiceFactory in project OpenAM by OpenRock.

the class TestAttributeEvaluator method setup.

@BeforeClass
public void setup() throws Exception {
    if (!migrated) {
        return;
    }
    resourceTypeService = Mockito.mock(ResourceTypeService.class);
    constraintValidator = Mockito.mock(ConstraintValidator.class);
    applicationServiceFactory = Mockito.mock(ApplicationServiceFactory.class);
    Application appl = new Application(APPL_NAME, ApplicationTypeManager.getAppplicationType(adminSubject, ApplicationTypeManager.URL_APPLICATION_TYPE_NAME));
    // Test disabled, unable to fix model change
    // Set<String> avaliableResources = new HashSet<String>();
    // avaliableResources.add("http://www.testevaluator.com:80/*");
    // appl.addResources(avaliableResources);
    appl.setEntitlementCombiner(DenyOverride.class);
    ApplicationManager.saveApplication(adminSubject, "/", appl);
    PrivilegeManager pm = new PolicyPrivilegeManager(applicationServiceFactory, resourceTypeService, constraintValidator);
    pm.initialize("/", adminSubject);
    Map<String, Boolean> actions = new HashMap<String, Boolean>();
    actions.put("GET", Boolean.TRUE);
    Entitlement ent = new Entitlement(APPL_NAME, URL1, actions);
    Map<String, Set<String>> attrValues = new HashMap<String, Set<String>>();
    Set<String> set = new HashSet<String>();
    set.add(attrValue);
    attrValues.put(attrName, set);
    user1 = IdRepoUtils.createUser("/", USER1_NAME, attrValues);
    AttributeSubject as = new AttributeSubject(attrName, attrValue);
    EntitlementSubject es1 = as;
    Privilege privilege = Privilege.getNewInstance();
    privilege.setName(PRIVILEGE1_NAME);
    privilege.setEntitlement(ent);
    privilege.setSubject(es1);
    pm.add(privilege);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) PolicyPrivilegeManager(com.sun.identity.entitlement.opensso.PolicyPrivilegeManager) ApplicationServiceFactory(org.forgerock.openam.entitlement.service.ApplicationServiceFactory) ResourceTypeService(org.forgerock.openam.entitlement.service.ResourceTypeService) ConstraintValidator(org.forgerock.openam.entitlement.constraints.ConstraintValidator) PolicyPrivilegeManager(com.sun.identity.entitlement.opensso.PolicyPrivilegeManager) HashSet(java.util.HashSet) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with ApplicationServiceFactory

use of org.forgerock.openam.entitlement.service.ApplicationServiceFactory in project OpenAM by OpenRock.

the class TestGroupEvaluator method setup.

@BeforeClass
public void setup() throws Exception {
    if (!migrated) {
        return;
    }
    resourceTypeService = Mockito.mock(ResourceTypeService.class);
    constraintValidator = Mockito.mock(ConstraintValidator.class);
    applicationServiceFactory = Mockito.mock(ApplicationServiceFactory.class);
    Application appl = new Application(APPL_NAME, ApplicationTypeManager.getAppplicationType(adminSubject, ApplicationTypeManager.URL_APPLICATION_TYPE_NAME));
    // Test disabled, unable to fix model change
    // Set<String> avaliableResources = new HashSet<String>();
    // avaliableResources.add("http://www.testevaluator.com:80/*");
    // appl.addResources(avaliableResources);
    appl.setEntitlementCombiner(DenyOverride.class);
    ApplicationManager.saveApplication(adminSubject, "/", appl);
    PrivilegeManager pm = new PolicyPrivilegeManager(applicationServiceFactory, resourceTypeService, constraintValidator);
    pm.initialize("/", adminSubject);
    Map<String, Boolean> actions = new HashMap<String, Boolean>();
    actions.put("GET", Boolean.TRUE);
    Entitlement ent = new Entitlement(APPL_NAME, URL1, actions);
    user1 = IdRepoUtils.createUser("/", USER1_NAME);
    group1 = IdRepoUtils.createGroup("/", GROUP1_NAME);
    group1.addMember(user1);
    EntitlementSubject es1 = new OpenSSOGroupSubject(group1.getUniversalId());
    Privilege privilege = Privilege.getNewInstance();
    privilege.setName(PRIVILEGE1_NAME);
    privilege.setEntitlement(ent);
    privilege.setSubject(es1);
    pm.add(privilege);
}
Also used : HashMap(java.util.HashMap) PolicyPrivilegeManager(com.sun.identity.entitlement.opensso.PolicyPrivilegeManager) OpenSSOGroupSubject(com.sun.identity.entitlement.opensso.OpenSSOGroupSubject) ApplicationServiceFactory(org.forgerock.openam.entitlement.service.ApplicationServiceFactory) ResourceTypeService(org.forgerock.openam.entitlement.service.ResourceTypeService) ConstraintValidator(org.forgerock.openam.entitlement.constraints.ConstraintValidator) PolicyPrivilegeManager(com.sun.identity.entitlement.opensso.PolicyPrivilegeManager) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with ApplicationServiceFactory

use of org.forgerock.openam.entitlement.service.ApplicationServiceFactory in project OpenAM by OpenRock.

the class OpenProvisioning method setup.

@BeforeClass
public void setup() throws SSOException, IdRepoException, EntitlementException {
    resourceTypeService = Mockito.mock(ResourceTypeService.class);
    constraintValidator = Mockito.mock(ConstraintValidator.class);
    applicationServiceFactory = Mockito.mock(ApplicationServiceFactory.class);
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    AMIdentityRepository amir = new AMIdentityRepository(adminToken, "/");
    branchMgr = amir.createIdentity(IdType.GROUP, "openProvisionBranchMgr", Collections.EMPTY_MAP);
    johnDoe = createUser(amir, "openProvisionJohnDoe");
    jSmith = createUser(amir, "openProvisionJSmith");
    branchMgr.addMember(jSmith);
    createPolicy(adminToken);
}
Also used : ConstraintValidator(org.forgerock.openam.entitlement.constraints.ConstraintValidator) SSOToken(com.iplanet.sso.SSOToken) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) ApplicationServiceFactory(org.forgerock.openam.entitlement.service.ApplicationServiceFactory) ResourceTypeService(org.forgerock.openam.entitlement.service.ResourceTypeService) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

ConstraintValidator (org.forgerock.openam.entitlement.constraints.ConstraintValidator)3 ApplicationServiceFactory (org.forgerock.openam.entitlement.service.ApplicationServiceFactory)3 ResourceTypeService (org.forgerock.openam.entitlement.service.ResourceTypeService)3 BeforeClass (org.testng.annotations.BeforeClass)3 PolicyPrivilegeManager (com.sun.identity.entitlement.opensso.PolicyPrivilegeManager)2 HashMap (java.util.HashMap)2 SSOToken (com.iplanet.sso.SSOToken)1 OpenSSOGroupSubject (com.sun.identity.entitlement.opensso.OpenSSOGroupSubject)1 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1