Search in sources :

Example 46 with PolicyManager

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

the class PolicyModelImpl method getPolicyNames.

/**
     * Returns policy names that are under a realm.
     *
     * @param realmName Name of realm.
     * @param filter Filter string.
     * @return policy names that are under a realm.
     * @throws AMConsoleException if policy names cannot be returned.
     */
public Set getPolicyNames(String realmName, String filter) throws AMConsoleException {
    Set names = null;
    try {
        String[] param = { realmName };
        logEvent("ATTEMPT_GET_POLICY_NAMES", param);
        PolicyManager policyManager = getPolicyManager(realmName);
        names = policyManager.getPolicyNames(filter);
        logEvent("SUCCEED_GET_POLICY_NAMES", param);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] params = { realmName, strError };
        logEvent("SSO_EXCEPTION_GET_POLICY_NAMES", params);
        throw new AMConsoleException(strError);
    } catch (PolicyException e) {
        String strError = getErrorString(e);
        String[] params = { realmName, strError };
        logEvent("POLICY_EXCEPTION_GET_POLICY_NAMES", params);
        throw new AMConsoleException(strError);
    }
    return (names != null) ? names : Collections.EMPTY_SET;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) Set(java.util.Set) HashSet(java.util.HashSet) PolicyException(com.sun.identity.policy.PolicyException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 47 with PolicyManager

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

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

the class PolicyModelImpl method canCreateNewResource.

/**
     * Returns true of new resource can be created under a realm of a given
     * service type.
     *
     * @param realmName Name of Realm.
     * @param svcTypeName Name of Service Type.
     * @return true of new resource can be created under a realm of a given
     *         service type.
     */
public boolean canCreateNewResource(String realmName, String svcTypeName) {
    boolean can = false;
    try {
        PolicyManager mgr = getPolicyManager(realmName);
        can = mgr.canCreateNewResource(svcTypeName);
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.canCreateNewResource", e);
    }
    return can;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 49 with PolicyManager

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

Example 50 with PolicyManager

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

the class PolicyModelImpl method getSubjectViewBeanURL.

/**
     * Returns properties view bean URL of a subject.
     *
     * @param realmName Name of realm.
     * @param subjectTypeName Name of Subject Type.
     * @return properties view bean URL of a subject.
     */
public String getSubjectViewBeanURL(String realmName, String subjectTypeName) {
    String url = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
            Subject subject = subjectTypeMgr.getSubject(subjectTypeName);
            url = subjectTypeMgr.getViewBeanURL(subject);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getSubjectViewBeanURL", e);
    } catch (NameNotFoundException e) {
        debug.warning("PolicyModelImpl.getSubjectViewBeanURL", e);
    } catch (PolicyException e) {
        debug.warning("PolicyModelImpl.getSubjectViewBeanURL", e);
    }
    return url;
}
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)

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