use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class HttpStarEvaluationTest method setup.
@BeforeClass
public void setup() throws Exception {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
adminSubject = SubjectUtils.createSubject(adminToken);
PrivilegeManager pm = PrivilegeManager.getInstance("/", adminSubject);
Privilege privilege = Privilege.getNewInstance();
privilege.setName(POLICY_NAME);
Map<String, Boolean> actions = new HashMap<String, Boolean>();
actions.put("findAll", true);
Entitlement entitlement = new Entitlement(ApplicationTypeManager.URL_APPLICATION_TYPE_NAME, "http://*", actions);
privilege.setEntitlement(entitlement);
privilege.setSubject(new AuthenticatedUsers());
pm.add(privilege);
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class IdentityGroupToEntitlementGroupTest method test.
@Test
public void test() throws Exception {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
PolicyManager pm = new PolicyManager(adminToken, "/");
Policy policy = new Policy("IdentityGroupToEntitlementGroupTest", "desc", false);
policy.addRule(createRule());
policy.addSubject("subject", createSubject(pm));
Set<IPrivilege> privileges = PrivilegeUtils.policyObjectToPrivileges(policy);
if ((privileges == null) || privileges.isEmpty()) {
throw new Exception("IdentityGroupToEntitlementGroupTest, set is empty");
}
Privilege p = (Privilege) privileges.iterator().next();
//uncomment after the groupsubject mapping is done
/* EntitlementSubject subject = p.getSubject();
if (!(subject instanceof OrSubject)) {
throw new Exception(
"IdentityGroupToEntitlementGroupTest, orSubject not found");
}
OrSubject orSubject = (OrSubject)subject;
Set<EntitlementSubject> subjects = orSubject.getESubjects();
if ((subjects == null) || (subjects.size() != 2)) {
throw new Exception(
"IdentityGroupToEntitlementGroupTest, subjects collection is incorrect");
}
for (EntitlementSubject s : subjects) {
if (!(s instanceof GroupSubject)) {
throw new Exception(
"IdentityGroupToEntitlementGroupTest, no group subject");
}
}*/
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class IdentityGroupToEntitlementGroupTest method setup.
@BeforeClass
public void setup() throws Exception {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
AMIdentityRepository amir = new AMIdentityRepository(adminToken, "/");
group1 = amir.createIdentity(IdType.GROUP, GROUP_NAME1, Collections.EMPTY_MAP);
group2 = amir.createIdentity(IdType.GROUP, GROUP_NAME2, Collections.EMPTY_MAP);
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class SubRealmEvaluationTest method setup.
@BeforeClass
public void setup() throws Exception {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
adminSubject = SubjectUtils.createSubject(adminToken);
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);
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class SubRealmEvaluationTest method evaluate.
private boolean evaluate(String res) throws EntitlementException {
Subject subject = createSubject(user1.getUniversalId());
Set actions = new HashSet();
actions.add("GET");
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
Evaluator evaluator = new Evaluator(SubjectUtils.createSubject(adminToken), APPL_NAME);
return evaluator.hasEntitlement(SUB_REALM, subject, new Entitlement(res, actions), Collections.EMPTY_MAP);
}
Aggregations