use of com.sun.identity.policy.SubjectTypeManager in project OpenAM by OpenRock.
the class IDPPTest method setup.
@BeforeClass
public void setup() throws Exception {
if (!migrated) {
return;
}
user1 = IdRepoUtils.createUser(orgName, USER1_NAME);
group1 = IdRepoUtils.createGroup(orgName, GROUP1_NAME);
group1.addMember(user1);
PolicyManager policyMgr = new PolicyManager(adminToken, orgName);
Policy policy = new Policy("IDPPTestPolicy1");
Set values = new HashSet();
values.add("deny");
Map actionValues = new HashMap();
actionValues.put("MODIFY", values);
actionValues.put("QUERY", values);
String resourceName = "*";
String ruleName = "rule1";
Rule rule = new Rule(ruleName, serviceType, resourceName, actionValues);
policy.addRule(rule);
SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
com.sun.identity.policy.interfaces.Subject subject = subjectTypeMgr.getSubject("AMIdentitySubject");
values = new HashSet();
values.add(group1.getUniversalId());
subject.setValues(values);
policy.addSubject("subject1", subject, false);
policyMgr.addPolicy(policy);
}
use of com.sun.identity.policy.SubjectTypeManager in project OpenAM by OpenRock.
the class IdentityGroupToEntitlementGroupTest method createSubject.
private Subject createSubject(PolicyManager pm) throws PolicyException {
SubjectTypeManager mgr = pm.getSubjectTypeManager();
Subject subject = mgr.getSubject("AMIdentitySubject");
Set<String> set = new HashSet<String>();
set.add(group1.getUniversalId());
set.add(group2.getUniversalId());
subject.setValues(set);
return subject;
}
use of com.sun.identity.policy.SubjectTypeManager in project OpenAM by OpenRock.
the class OrgAliasReferralTestOldAPI method createPrivilege.
private void createPrivilege() throws Exception {
Policy policy = new Policy("OrgAliasReferralTestOldAPI", "", false);
PolicyManager pm = new PolicyManager(adminToken, SUB_REALM1);
SubjectTypeManager sm = pm.getSubjectTypeManager();
policy.addSubject("s", sm.getSubject("AuthenticatedUsers"));
policy.addRule(createRule1());
pm.addPolicy(policy);
}
use of com.sun.identity.policy.SubjectTypeManager in project OpenAM by OpenRock.
the class PolicyModelImpl method getDisplayNameForSubjectValues.
/**
* Returns a map of values to localized label.
*
* @param realmName Name of realm.
* @param subjectTypeName Name of Subject Type.
* @param values Valid values.
* @return a map of values to localized label.
*/
public Map getDisplayNameForSubjectValues(String realmName, String subjectTypeName, Set values) {
Map map = null;
if ((values != null) && !values.isEmpty()) {
map = new HashMap(values.size() * 2);
Locale locale = getUserLocale();
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
Subject subject = subjectTypeMgr.getSubject(subjectTypeName);
for (Iterator i = values.iterator(); i.hasNext(); ) {
String v = (String) i.next();
map.put(v, subject.getDisplayNameForValue(v, locale));
}
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getDisplayNameForSubjectValues", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getDisplayNameForSubjectValues", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getDisplayNameForSubjectValues", e);
}
}
return (map == null) ? Collections.EMPTY_MAP : map;
}
use of com.sun.identity.policy.SubjectTypeManager in project OpenAM by OpenRock.
the class PolicyModelImpl method getSubjectViewBeanURL.
/**
* Returns properties view bean URL of a subject.
*
* @param realmName Name of realm.
* @param subject Subject instance.
* @return properties view bean URL of a subject.
*/
public String getSubjectViewBeanURL(String realmName, Subject subject) {
String url = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
url = subjectTypeMgr.getViewBeanURL(subject);
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getSubjectViewBeanURL", e);
}
return url;
}
Aggregations