Search in sources :

Example 6 with ResourceTypeService

use of org.forgerock.openam.entitlement.service.ResourceTypeService 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 7 with ResourceTypeService

use of org.forgerock.openam.entitlement.service.ResourceTypeService 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)

Aggregations

ResourceTypeService (org.forgerock.openam.entitlement.service.ResourceTypeService)7 ConstraintValidator (org.forgerock.openam.entitlement.constraints.ConstraintValidator)3 ApplicationServiceFactory (org.forgerock.openam.entitlement.service.ApplicationServiceFactory)3 BeforeClass (org.testng.annotations.BeforeClass)3 PolicyPrivilegeManager (com.sun.identity.entitlement.opensso.PolicyPrivilegeManager)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 SSOToken (com.iplanet.sso.SSOToken)1 Application (com.sun.identity.entitlement.Application)1 ApplicationType (com.sun.identity.entitlement.ApplicationType)1 OpenSSOGroupSubject (com.sun.identity.entitlement.opensso.OpenSSOGroupSubject)1 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)1 ServiceConfig (com.sun.identity.sm.ServiceConfig)1 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Principal (java.security.Principal)1 PrivilegedAction (java.security.PrivilegedAction)1 Date (java.util.Date)1 ResourceType (org.forgerock.openam.entitlement.ResourceType)1