use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.
the class Subjects method removeSubject.
/**
* Removes the <code>Subject</code> object identified by
* the subject name. If a subject instance with the given
* name does not exist, the method will return silently.
*
* @param subjectName name of the subject instance that
* will be removed from the user collection
* @return the subject that was just removed
*/
public Subject removeSubject(String subjectName) {
Subject subject = null;
QualifiedSubject qualifiedSubject = (QualifiedSubject) users.remove(subjectName);
if (qualifiedSubject != null) {
subject = qualifiedSubject.getSubject();
}
return subject;
}
use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.
the class InactivePolicyTest method createPolicy.
private void createPolicy() throws Exception {
Policy policy = new Policy(POLICY_NAME, "", false, false);
PolicyManager pm = new PolicyManager(adminToken, "/");
SubjectTypeManager mgr = pm.getSubjectTypeManager();
Subject subject = mgr.getSubject("AuthenticatedUsers");
Map<String, Set<String>> actionValues = new HashMap<String, Set<String>>();
{
Set<String> set = new HashSet<String>();
set.add("allow");
actionValues.put("GET", set);
}
{
Set<String> set = new HashSet<String>();
set.add("allow");
actionValues.put("POST", set);
}
policy.addRule(new Rule("rule", "iPlanetAMWebAgentService", "http://www.InactivePolicyTest.com/*", actionValues));
policy.addSubject("subject", subject);
pm.addPolicy(policy);
}
use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.
the class PolicyEvaluatorTest 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(testUser.getUniversalId());
subject.setValues(set);
return subject;
}
use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.
the class PrivilegePolicyMapping 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(testUser.getUniversalId());
subject.setValues(set);
return subject;
}
use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.
the class UpgradeUtils method createRealmAdminPolicy.
/**
* Creates Realm Admin Policy.
*
* @param policyManager the policy manager object.
* @param orgDN the organization dn.
* @param orgID the organization identifier.
*/
private static void createRealmAdminPolicy(PolicyManager policyManager, String orgDN, String orgID) {
String classMethod = "UpgradeUtils:createRealmAdminPolicy";
try {
String policyName = orgID + "^^RealmAdmin";
Policy realmPolicy = new Policy(policyName, null, false, true);
// create Rule
String resourceName = "sms://*" + orgDN + "/*";
Rule rule = getRule(DELEGATION_SERVICE, resourceName);
if (rule != null) {
realmPolicy.addRule(rule);
}
String universalID = getUniversalID(orgDN, ORG_ADMIN_ROLE);
Subject subject = getSubject(policyManager, universalID);
if (subject != null) {
realmPolicy.addSubject(DELEGATION_SUBJECT, subject, false);
}
policyManager.addPolicy(realmPolicy);
} catch (Exception e) {
debug.error(classMethod + "Error creating realm admin policy", e);
}
}
Aggregations