Search in sources :

Example 31 with NameNotFoundException

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

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

use of com.sun.identity.policy.NameNotFoundException 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)

Example 34 with NameNotFoundException

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

the class PolicyModelImpl method getActiveSubjectTypes.

/**
     * Returns a map of active subject types for a realm to its display name.
     *
     * @param realmName Name of Realm.
     * @return a map of active subject types for a realm to its display name.
     */
public QueryResults getActiveSubjectTypes(String realmName) {
    Map subjectTypes = Collections.EMPTY_MAP;
    String strError = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
            if (subjectTypeMgr != null) {
                Set types = subjectTypeMgr.getSelectedSubjectTypeNames();
                subjectTypes = new HashMap(types.size() * 2);
                for (Iterator iter = types.iterator(); iter.hasNext(); ) {
                    String rName = (String) iter.next();
                    try {
                        Subject subject = subjectTypeMgr.getSubject(rName);
                        if (subject != null) {
                            Syntax syntax = subject.getValueSyntax(getUserSSOToken());
                            if (!syntax.equals(Syntax.NONE)) {
                                subjectTypes.put(rName, subjectTypeMgr.getDisplayName(rName));
                            }
                        }
                    } catch (SSOException e) {
                        strError = getErrorString(e);
                    } catch (NameNotFoundException e) {
                        strError = getErrorString(e);
                    } catch (PolicyException e) {
                        strError = getErrorString(e);
                    }
                }
            }
        }
    } catch (AMConsoleException e) {
        debug.error("PolicyModelImpl.getActiveSubjectTypes", e);
    } catch (SSOException e) {
        debug.error("PolicyModelImpl.getActiveSubjectTypes", e);
    } catch (NameNotFoundException e) {
        debug.error("PolicyModelImpl.getActiveSubjectTypes", e);
    } catch (PolicyException e) {
        debug.error("PolicyModelImpl.getActiveSubjectTypes", e);
    }
    return new QueryResults(subjectTypes, strError);
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) SSOException(com.iplanet.sso.SSOException) Subject(com.sun.identity.policy.interfaces.Subject) QueryResults(com.sun.identity.console.base.model.QueryResults) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) PolicyException(com.sun.identity.policy.PolicyException) Iterator(java.util.Iterator) Syntax(com.sun.identity.policy.Syntax) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 35 with NameNotFoundException

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

the class PolicyModelImpl method getDisplayNameForReferralValues.

/**
     * Returns a map of values to localized label.
     *
     * @param realmName Name of realm.
     * @param referralTypeName Name of referral Type.
     * @param values Valid values.
     * @return a map of values to localized label.
     */
public Map getDisplayNameForReferralValues(String realmName, String referralTypeName, 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) {
                ReferralTypeManager mgr = policyMgr.getReferralTypeManager();
                Referral referral = mgr.getReferral(referralTypeName);
                for (Iterator i = values.iterator(); i.hasNext(); ) {
                    String v = (String) i.next();
                    map.put(v, referral.getDisplayNameForValue(v, locale));
                }
            }
        } catch (AMConsoleException e) {
            debug.warning("PolicyModelImpl.getDisplayNameForReferralValues", e);
        } catch (NameNotFoundException e) {
            debug.warning("PolicyModelImpl.getDisplayNameForReferralValues", e);
        } catch (PolicyException e) {
            debug.warning("PolicyModelImpl.getDisplayNameForReferralValues", e);
        }
    }
    return (map == null) ? Collections.EMPTY_MAP : map;
}
Also used : Locale(java.util.Locale) ReferralTypeManager(com.sun.identity.policy.ReferralTypeManager) PolicyManager(com.sun.identity.policy.PolicyManager) HashMap(java.util.HashMap) Referral(com.sun.identity.policy.interfaces.Referral) 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)

Aggregations

NameNotFoundException (com.sun.identity.policy.NameNotFoundException)52 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)41 Policy (com.sun.identity.policy.Policy)24 PolicyManager (com.sun.identity.policy.PolicyManager)23 PolicyException (com.sun.identity.policy.PolicyException)22 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)21 Set (java.util.Set)21 Map (java.util.Map)17 Iterator (java.util.Iterator)15 HashMap (java.util.HashMap)14 SSOException (com.iplanet.sso.SSOException)11 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)11 Subject (com.sun.identity.policy.interfaces.Subject)11 Referral (com.sun.identity.policy.interfaces.Referral)10 HashSet (java.util.HashSet)10 Condition (com.sun.identity.policy.interfaces.Condition)8 ResponseProvider (com.sun.identity.policy.interfaces.ResponseProvider)7 InvalidNameException (com.sun.identity.policy.InvalidNameException)6 ReferralTypeManager (com.sun.identity.policy.ReferralTypeManager)6 Rule (com.sun.identity.policy.Rule)6