Search in sources :

Example 6 with SubjectTypeManager

use of com.sun.identity.policy.SubjectTypeManager 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 7 with SubjectTypeManager

use of com.sun.identity.policy.SubjectTypeManager in project OpenAM by OpenRock.

the class Util method createAMIdentitySubject.

/**
     * Returns a Subject for the given AMIdentity.
     * @param pm The PolicyManager to use.
     * @param user The user to convert into a Subject
     * @return a Subject for the given AMIdentity.
     * @throws PolicyException if there was a problem creating the Subject.
     */
public static Subject createAMIdentitySubject(PolicyManager pm, AMIdentity user) throws PolicyException {
    SubjectTypeManager mgr = pm.getSubjectTypeManager();
    Subject subject = mgr.getSubject("AMIdentitySubject");
    Set<String> set = new HashSet<String>();
    set.add(user.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 8 with SubjectTypeManager

use of com.sun.identity.policy.SubjectTypeManager in project OpenAM by OpenRock.

the class Util method createAuthenticatedUsersSubject.

/**
     * Returns A Subject that represents all authenticated users.
     * @param pm The PolicyManager to use.
     * @return A Subject that represents all authenticated users.
     * @throws PolicyException if there was a problem creating the Subject.
     */
public static Subject createAuthenticatedUsersSubject(PolicyManager pm) throws PolicyException {
    SubjectTypeManager mgr = pm.getSubjectTypeManager();
    Subject subject = mgr.getSubject("AuthenticatedUsers");
    return subject;
}
Also used : SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) Subject(com.sun.identity.policy.interfaces.Subject)

Example 9 with SubjectTypeManager

use of com.sun.identity.policy.SubjectTypeManager in project OpenAM by OpenRock.

the class UpgradeUtils method getSubject.

/**
     * Returns the policy <code>Subject</code>
     *
     */
private static Subject getSubject(PolicyManager policyManager, String universalID) {
    String classMethod = "UpgradeUtils:getSubject : ";
    Subject subject = null;
    try {
        SubjectTypeManager stm = policyManager.getSubjectTypeManager();
        subject = stm.getSubject(AM_ID_SUBJECT);
        Set subjectValues = new HashSet(1);
        subjectValues.add(universalID);
        subject.setValues(subjectValues);
    } catch (Exception e) {
        debug.error(classMethod + "Error creating subject", e);
    }
    return subject;
}
Also used : SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) Set(java.util.Set) HashSet(java.util.HashSet) ByteString(org.forgerock.opendj.ldap.ByteString) 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) HashSet(java.util.HashSet)

Example 10 with SubjectTypeManager

use of com.sun.identity.policy.SubjectTypeManager in project OpenAM by OpenRock.

the class PolicyModelImpl method getSubjectPossibleValues.

/**
     * Returns a set of possible values for a subject type.
     *
     * @param realmName Name of Realm.
     * @param subjectType Name of Subject Type.
     * @param filter wildcards for filtering the results.
     * @return a set of possible values for a subject type.
     * @throws AMConsoleException if values cannot be obtained.
     */
public ValidValues getSubjectPossibleValues(String realmName, String subjectType, String filter) throws AMConsoleException {
    debug.error("PolicyModelImpl.getSubjectPossibleValues()");
    ValidValues values = null;
    if ((filter == null) || (filter.trim().length() == 0)) {
        filter = "*";
    }
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
            Subject subject = subjectTypeMgr.getSubject(subjectType);
            values = subject.getValidValues(getUserSSOToken(), filter);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getSubjectPossibleValues", e);
    } catch (NameNotFoundException e) {
        debug.warning("PolicyModelImpl.getSubjectPossibleValues", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        debug.warning("PolicyModelImpl.getSubjectPossibleValues", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (PolicyException e) {
        debug.warning("PolicyModelImpl.getSubjectPossibleValues", e);
        throw new AMConsoleException(getErrorString(e));
    }
    return values;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) ValidValues(com.sun.identity.policy.ValidValues) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Subject(com.sun.identity.policy.interfaces.Subject)

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