Search in sources :

Example 6 with Subject

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

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

Example 8 with Subject

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

Example 9 with 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;
}
Also used : SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) EntitlementSubject(com.sun.identity.entitlement.EntitlementSubject) PrivilegeSubject(com.sun.identity.policy.plugins.PrivilegeSubject) Subject(com.sun.identity.policy.interfaces.Subject) HashSet(java.util.HashSet)

Example 10 with 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);
    }
}
Also used : Policy(com.sun.identity.policy.Policy) ByteString(org.forgerock.opendj.ldap.ByteString) Rule(com.sun.identity.policy.Rule) Subject(com.sun.identity.policy.interfaces.Subject) LoginException(javax.security.auth.login.LoginException) InvalidAuthContextException(com.sun.identity.authentication.internal.InvalidAuthContextException) UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) PolicyException(com.sun.identity.policy.PolicyException) FileNotFoundException(java.io.FileNotFoundException) SSOException(com.iplanet.sso.SSOException) LdapException(org.forgerock.opendj.ldap.LdapException) SMSException(com.sun.identity.sm.SMSException) IOException(java.io.IOException) AMException(com.iplanet.am.sdk.AMException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException)

Aggregations

Subject (com.sun.identity.policy.interfaces.Subject)47 HashSet (java.util.HashSet)18 PolicyException (com.sun.identity.policy.PolicyException)17 SSOException (com.iplanet.sso.SSOException)14 Policy (com.sun.identity.policy.Policy)14 Set (java.util.Set)12 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)11 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)11 SubjectTypeManager (com.sun.identity.policy.SubjectTypeManager)11 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)8 Rule (com.sun.identity.policy.Rule)8 Iterator (java.util.Iterator)8 PolicyManager (com.sun.identity.policy.PolicyManager)7 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)6 AMException (com.iplanet.am.sdk.AMException)5 InvalidAuthContextException (com.sun.identity.authentication.internal.InvalidAuthContextException)5 ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)5 UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)5 SMSException (com.sun.identity.sm.SMSException)5 FileNotFoundException (java.io.FileNotFoundException)5