Search in sources :

Example 41 with PolicyManager

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

the class PolicyModelImpl method getSubjectSyntax.

/**
     * Returns syntax for a subject.
     *
     * @param realmName Name of Realm.
     * @param subjectType Name of Subject type.
     * @return syntax for a subject.
     */
public Syntax getSubjectSyntax(String realmName, String subjectType) {
    Syntax syntax = Syntax.NONE;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
            Subject subject = subjectTypeMgr.getSubject(subjectType);
            syntax = subject.getValueSyntax(getUserSSOToken());
        }
    } catch (SSOException e) {
        debug.warning("PolicyModelImpl.getActiveSubjectTypes", e);
    } catch (NameNotFoundException e) {
        debug.warning("PolicyModelImpl.getActiveSubjectTypes", e);
    } catch (PolicyException e) {
        debug.warning("PolicyModelImpl.getActiveSubjectTypes", e);
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getActiveSubjectTypes", e);
    }
    return syntax;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) SSOException(com.iplanet.sso.SSOException) Syntax(com.sun.identity.policy.Syntax) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Subject(com.sun.identity.policy.interfaces.Subject)

Example 42 with PolicyManager

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

the class PolicyModelImpl method createSubject.

/**
     * Returns a subject object.
     *
     * @param realmName Name of Realm.
     * @param subjectType Name of subject type.
     * @param values Values of the subject.
     * @return subject object.
     * @throws AMConsoleException if subject cannot be created.
     */
public Subject createSubject(String realmName, String subjectType, Set values) throws AMConsoleException {
    Subject subject = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
            subject = subjectTypeMgr.getSubject(subjectType);
            subject.setValues(values);
        }
    } catch (NameNotFoundException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (PolicyException e) {
        throw new AMConsoleException(getErrorString(e));
    }
    return subject;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Subject(com.sun.identity.policy.interfaces.Subject)

Example 43 with PolicyManager

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

the class PolicyModelImpl method getActiveConditionTypes.

/**
     * Returns a map of active condition types for a realm to its display name.
     *
     * @param realmName Name of Realm.
     * @return a map of active condition types for a realm to its display name.
     */
public Map getActiveConditionTypes(String realmName) {
    Map condTypes = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ConditionTypeManager condTypeMgr = policyMgr.getConditionTypeManager();
            if (condTypeMgr != null) {
                Set types = condTypeMgr.getSelectedConditionTypeNames();
                condTypes = new HashMap(types.size() * 2);
                for (Iterator iter = types.iterator(); iter.hasNext(); ) {
                    String rName = (String) iter.next();
                    condTypes.put(rName, condTypeMgr.getDisplayName(rName));
                }
            }
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getActiveConditionTypes", e);
    } catch (SSOException e) {
        debug.warning("PolicyModelImpl.getActiveConditionTypes", e);
    } catch (NameNotFoundException e) {
        debug.warning("PolicyModelImpl.getActiveConditionTypes", e);
    } catch (PolicyException e) {
        debug.warning("PolicyModelImpl.getActiveConditionTypes", e);
    }
    return (condTypes == null) ? Collections.EMPTY_MAP : condTypes;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) Set(java.util.Set) HashSet(java.util.HashSet) ConditionTypeManager(com.sun.identity.policy.ConditionTypeManager) HashMap(java.util.HashMap) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) Iterator(java.util.Iterator) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 44 with PolicyManager

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

the class PolicyModelImpl method cachePolicy.

/**
     * Caches an existing policy. Returns the cache ID of the policy object.
     *
     * @param realmName Name of realm.
     * @param policyName Name of policy.
     * @return cache ID of the policy object.
     * @throws AMConsoleException if policy cannot be cached.
     */
public String cachePolicy(String realmName, String policyName) throws AMConsoleException {
    try {
        PolicyManager policyManager = getPolicyManager(realmName);
        Policy policy = policyManager.getPolicy(policyName);
        PolicyCache cache = PolicyCache.getInstance();
        return cache.cachePolicy(getUserSSOToken(), new CachedPolicy(policy));
    } catch (InvalidFormatException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (InvalidNameException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (NoPermissionException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (NameNotFoundException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (PolicyException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : Policy(com.sun.identity.policy.Policy) PolicyManager(com.sun.identity.policy.PolicyManager) InvalidNameException(com.sun.identity.policy.InvalidNameException) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) NoPermissionException(com.sun.identity.policy.NoPermissionException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) InvalidFormatException(com.sun.identity.policy.InvalidFormatException)

Example 45 with PolicyManager

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

the class PolicyModelImpl method createReferral.

/**
     * Returns a referral object.
     *
     * @param realmName Name of Realm.
     * @param referralType Name of referral type.
     * @param values Values of the referral.
     * @return referral obejct.
     * @throws AMConsoleException if referral cannot be created.
     */
public Referral createReferral(String realmName, String referralType, Set values) throws AMConsoleException {
    Referral referral = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
            referral = referralTypeMgr.getReferral(referralType);
            referral.setValues(values);
        }
    } catch (NameNotFoundException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (PolicyException e) {
        throw new AMConsoleException(getErrorString(e));
    }
    return referral;
}
Also used : ReferralTypeManager(com.sun.identity.policy.ReferralTypeManager) PolicyManager(com.sun.identity.policy.PolicyManager) Referral(com.sun.identity.policy.interfaces.Referral) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

PolicyManager (com.sun.identity.policy.PolicyManager)61 PolicyException (com.sun.identity.policy.PolicyException)40 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)33 SSOException (com.iplanet.sso.SSOException)28 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)23 HashSet (java.util.HashSet)18 Set (java.util.Set)18 Policy (com.sun.identity.policy.Policy)16 Map (java.util.Map)13 HashMap (java.util.HashMap)12 Iterator (java.util.Iterator)11 SubjectTypeManager (com.sun.identity.policy.SubjectTypeManager)10 SSOToken (com.iplanet.sso.SSOToken)8 Subject (com.sun.identity.policy.interfaces.Subject)8 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)8 ReferralTypeManager (com.sun.identity.policy.ReferralTypeManager)7 Referral (com.sun.identity.policy.interfaces.Referral)7 ConditionTypeManager (com.sun.identity.policy.ConditionTypeManager)6 ResponseProviderTypeManager (com.sun.identity.policy.ResponseProviderTypeManager)6 Condition (com.sun.identity.policy.interfaces.Condition)5