Search in sources :

Example 11 with PolicyManager

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

the class PolicyModelImpl method getConditionViewBeanURL.

/**
     * Returns properties view bean URL of a condition.
     *
     * @param realmName Name of realm.
     * @param conditionTypeName Name of Condition Type.
     * @return properties view bean URL of a condition.
     */
public String getConditionViewBeanURL(String realmName, String conditionTypeName) {
    String url = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ConditionTypeManager condTypeMgr = policyMgr.getConditionTypeManager();
            Condition condition = condTypeMgr.getCondition(conditionTypeName);
            url = condTypeMgr.getViewBeanURL(condition);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getConditionViewBeanURL", e);
    } catch (NameNotFoundException e) {
        debug.warning("PolicyModelImpl.getConditionViewBeanURL", e);
    } catch (PolicyException e) {
        debug.warning("PolicyModelImpl.getConditionViewBeanURL", e);
    }
    return url;
}
Also used : Condition(com.sun.identity.policy.interfaces.Condition) PolicyManager(com.sun.identity.policy.PolicyManager) ConditionTypeManager(com.sun.identity.policy.ConditionTypeManager) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 12 with PolicyManager

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

the class PolicyModelImpl method getReferralPossibleValues.

/**
     * Returns a set of possible values for a referral type.
     *
     * @param realmName Name of Realm.
     * @param referralType Name of Referral Type.
     * @param filter wildcards for filtering the results.
     * @return a set of possible values for a referral type.
     */
public ValidValues getReferralPossibleValues(String realmName, String referralType, String filter) {
    ValidValues values = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
            Referral referral = referralTypeMgr.getReferral(referralType);
            values = referral.getValidValues(getUserSSOToken(), filter);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getReferralPossibleValues", e);
    } catch (NameNotFoundException e) {
        debug.warning("PolicyModelImpl.getReferralPossibleValues", e);
    } catch (SSOException e) {
        debug.warning("PolicyModelImpl.getReferralPossibleValues", e);
    } catch (PolicyException e) {
        debug.warning("PolicyModelImpl.getReferralPossibleValues", e);
    }
    return values;
}
Also used : ReferralTypeManager(com.sun.identity.policy.ReferralTypeManager) PolicyManager(com.sun.identity.policy.PolicyManager) ValidValues(com.sun.identity.policy.ValidValues) Referral(com.sun.identity.policy.interfaces.Referral) 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)

Example 13 with PolicyManager

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

the class PolicyModelImpl method getActiveReferralTypes.

/**
     * Returns a map of active referral types for a realm to its display name.
     *
     * @param realmName Name of Realm.
     * @return a map of active referral types for a realm to its display name.
     */
public Map getActiveReferralTypes(String realmName) {
    Map referralTypes = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
            if (referralTypeMgr != null) {
                Set types = referralTypeMgr.getSelectedReferralTypeNames();
                referralTypes = new HashMap(types.size() * 2);
                for (Iterator iter = types.iterator(); iter.hasNext(); ) {
                    String rName = (String) iter.next();
                    Referral referral = referralTypeMgr.getReferral(rName);
                    if (referral != null) {
                        Syntax syntax = referral.getValueSyntax(getUserSSOToken());
                        if (!syntax.equals(Syntax.NONE)) {
                            referralTypes.put(rName, referralTypeMgr.getDisplayName(rName));
                        }
                    }
                }
            }
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
    } catch (SSOException e) {
        debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
    } catch (NameNotFoundException e) {
        debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
    } catch (PolicyException e) {
        debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
    }
    return (referralTypes == null) ? Collections.EMPTY_MAP : referralTypes;
}
Also used : ReferralTypeManager(com.sun.identity.policy.ReferralTypeManager) 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) Referral(com.sun.identity.policy.interfaces.Referral) 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 14 with PolicyManager

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

the class PolicyModelImpl method getManagedResources.

/**
     * Returns a list of managed resource names.
     *
     * @param realmName Name of realm.
     * @param serviceTypeName Name of service type.
     * @return a list of managed resource names.
     */
public List getManagedResources(String realmName, String serviceTypeName) {
    List managedResources = (List) mapSvcNameToManagedResource.get(serviceTypeName);
    if (managedResources == null) {
        managedResources = Collections.EMPTY_LIST;
        try {
            PolicyManager mgr = getPolicyManager(realmName);
            if (mgr != null) {
                Set resources = mgr.getManagedResourceNames(serviceTypeName);
                if ((resources != null) && !resources.isEmpty()) {
                    managedResources = AMFormatUtils.sortItems(resources, getUserLocale());
                }
            }
        } catch (PolicyException e) {
            debug.warning("PolicyModelImpl.getManagedResources", e);
        } catch (AMConsoleException e) {
            debug.warning("PolicyModelImpl.getManagedResources", e);
        }
        mapSvcNameToManagedResource.put(serviceTypeName, managedResources);
    }
    return managedResources;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) Set(java.util.Set) HashSet(java.util.HashSet) PolicyException(com.sun.identity.policy.PolicyException) List(java.util.List) ArrayList(java.util.ArrayList) OptionList(com.iplanet.jato.view.html.OptionList) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 15 with PolicyManager

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

the class PrivilegePolicyMapping method cleanup.

@AfterClass
public void cleanup() throws Exception {
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    IdRepoUtils.deleteIdentity("/", testUser);
    PolicyManager pm = new PolicyManager(adminToken, "/");
    pm.removePolicy(POLICY_NAME);
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) SSOToken(com.iplanet.sso.SSOToken) AfterClass(org.testng.annotations.AfterClass)

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