use of com.sun.identity.entitlement.opensso.OpenSSOUserSubject in project OpenAM by OpenRock.
the class TestEvaluator method createReferral.
private void createReferral(SSOToken adminToken, Subject adminSubject) throws SMSException, EntitlementException, SSOException, IdRepoException, InterruptedException {
OrganizationConfigManager orgMgr = new OrganizationConfigManager(adminToken, "/");
String subRealm = SUB_REALM.substring(1);
orgMgr.createSubOrganization(subRealm, Collections.EMPTY_MAP);
Map<String, Set<String>> map = new HashMap<String, Set<String>>();
Set<String> set = new HashSet<String>();
map.put(APPL_NAME, set);
set.add("http://www.testevaluator.com:80/*");
Set<String> realms = new HashSet<String>();
realms.add(SUB_REALM);
ReferralPrivilege referral = new ReferralPrivilege(REFERRAL_NAME, map, realms);
PrivilegeManager pm = PrivilegeManager.getInstance(SUB_REALM, 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);
user2 = IdRepoUtils.createUser("/", USER2_NAME);
Set<EntitlementSubject> esSet = new HashSet<EntitlementSubject>();
EntitlementSubject es1 = new OpenSSOUserSubject(user1.getUniversalId());
EntitlementSubject es2 = new OpenSSOUserSubject(user2.getUniversalId());
esSet.add(es1);
esSet.add(es2);
EntitlementSubject eSubject = new OrSubject(esSet);
Privilege privilege = Privilege.getNewInstance();
privilege.setName(PRIVILEGE1_NAME);
privilege.setEntitlement(ent);
privilege.setSubject(eSubject);
pm.add(privilege);
Thread.sleep(1000);
}
use of com.sun.identity.entitlement.opensso.OpenSSOUserSubject in project OpenAM by OpenRock.
the class ApplicationPrivilegeBase method getSubjects.
protected Set<SubjectImplementation> getSubjects(RequestContext rc) throws CLIException {
Set<SubjectImplementation> eSubjects = new HashSet<SubjectImplementation>();
boolean bUser = isUserSubject();
IdType idType = (bUser) ? IdType.USER : IdType.GROUP;
String realm = getStringOptionValue(IArgument.REALM_NAME);
List<String> subjects = rc.getOption(PARAM_SUBJECTS);
for (String s : subjects) {
// create AMIdentity just to get the uuid.
AMIdentity amid = new AMIdentity(null, s, idType, realm, null);
String universalId = amid.getUniversalId();
SubjectImplementation sbj = (bUser) ? new OpenSSOUserSubject(universalId) : new OpenSSOGroupSubject(universalId);
eSubjects.add(sbj);
}
return eSubjects;
}
Aggregations