Search in sources :

Example 1 with SubjectTypeManager

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);
}
Also used : Policy(com.sun.identity.policy.Policy) PolicyManager(com.sun.identity.policy.PolicyManager) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) Rule(com.sun.identity.policy.Rule) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with SubjectTypeManager

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;
}
Also used : SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) Subject(com.sun.identity.policy.interfaces.Subject) HashSet(java.util.HashSet)

Example 3 with SubjectTypeManager

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);
}
Also used : Policy(com.sun.identity.policy.Policy) PolicyManager(com.sun.identity.policy.PolicyManager) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager)

Example 4 with SubjectTypeManager

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;
}
Also used : Locale(java.util.Locale) PolicyManager(com.sun.identity.policy.PolicyManager) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) HashMap(java.util.HashMap) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) Iterator(java.util.Iterator) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap) Subject(com.sun.identity.policy.interfaces.Subject)

Example 5 with SubjectTypeManager

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;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

SubjectTypeManager (com.sun.identity.policy.SubjectTypeManager)15 Subject (com.sun.identity.policy.interfaces.Subject)11 PolicyManager (com.sun.identity.policy.PolicyManager)10 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)8 PolicyException (com.sun.identity.policy.PolicyException)7 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)6 HashSet (java.util.HashSet)6 SSOException (com.iplanet.sso.SSOException)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Set (java.util.Set)3 Policy (com.sun.identity.policy.Policy)2 Syntax (com.sun.identity.policy.Syntax)2 Iterator (java.util.Iterator)2 AMException (com.iplanet.am.sdk.AMException)1 InvalidAuthContextException (com.sun.identity.authentication.internal.InvalidAuthContextException)1 ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)1 UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)1 QueryResults (com.sun.identity.console.base.model.QueryResults)1 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)1