Search in sources :

Example 6 with PolicyManager

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

the class PolicyModelImpl method deletePolicies.

/**
     * Deletes policies.
     *
     * @param realmName Name of realm that contains these policies.
     * @param names Set of policy names to be deleted.
     * @throws AMConsoleException if policies cannot be deleted.
     */
public void deletePolicies(String realmName, Set names) throws AMConsoleException {
    PolicyManager policyManager = getPolicyManager(realmName);
    List unableToDelete = new ArrayList(names.size());
    String[] params = new String[2];
    params[0] = realmName;
    String[] paramsEx = new String[3];
    paramsEx[0] = realmName;
    for (Iterator iter = names.iterator(); iter.hasNext(); ) {
        String name = (String) iter.next();
        params[1] = name;
        try {
            logEvent("ATTEMPT_DELETE_POLICY", params);
            policyManager.removePolicy(name);
            logEvent("SUCCEED_DELETE_POLICY", params);
        } catch (PolicyException e) {
            paramsEx[1] = name;
            paramsEx[2] = getErrorString(e);
            logEvent("POLICY_EXCEPTION_DELETE_POLICY", params);
            debug.warning("PolicyModelImpl.deletePolicies", e);
            unableToDelete.add(name);
        } catch (SSOException e) {
            paramsEx[1] = name;
            paramsEx[2] = getErrorString(e);
            logEvent("SSO_EXCEPTION_DELETE_POLICY", params);
            debug.warning("PolicyModelImpl.deletePolicies", e);
            unableToDelete.add(name);
        }
    }
    if (!unableToDelete.isEmpty()) {
        Object[] p = (Object[]) unableToDelete.toArray();
        String msg = MessageFormat.format("policy.message.unableToDeletePolicies", p);
        throw new AMConsoleException(msg);
    }
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) PolicyException(com.sun.identity.policy.PolicyException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) OptionList(com.iplanet.jato.view.html.OptionList) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 7 with PolicyManager

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

the class PolicyModelImpl method getResponseProviderTypeName.

/**
     * Returns response provider type name of a response provider.
     *
     * @param realmName Name of realm.
     * @param provider response provider instance.
     * @return response provider type name of a response provider.
     */
public String getResponseProviderTypeName(String realmName, ResponseProvider provider) {
    String typeName = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ResponseProviderTypeManager mgr = policyMgr.getResponseProviderTypeManager();
            typeName = mgr.getResponseProviderTypeName(provider);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getResponseProviderTypeName", e);
    }
    return typeName;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) ResponseProviderTypeManager(com.sun.identity.policy.ResponseProviderTypeManager)

Example 8 with PolicyManager

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

the class PolicyModelImpl method createPolicy.

/**
     * Creates a policy.
     *
     * @param realmName Name of realm.
     * @param policy Policy object.
     * @throws AMConsoleException if policy cannot be created.
     */
public void createPolicy(String realmName, Policy policy) throws AMConsoleException {
    try {
        String[] params = { realmName, policy.getName() };
        logEvent("ATTEMPT_CREATE_POLICY", params);
        PolicyManager policyManager = getPolicyManager(realmName);
        policyManager.addPolicy(policy);
        logEvent("SUCCEED_CREATE_POLICY", params);
    } catch (PolicyException e) {
        String strError = getErrorString(e);
        String[] params = { realmName, policy.getName(), strError };
        logEvent("POLICY_EXCEPTION_CREATE_POLICY", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] params = { realmName, policy.getName(), strError };
        logEvent("SSO_EXCEPTION_CREATE_POLICY", params);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) PolicyException(com.sun.identity.policy.PolicyException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 9 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 subject Subject instance.
     * @return properties view bean URL of a subject.
     */
public String getSubjectViewBeanURL(String realmName, Subject subject) {
    String url = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
            url = subjectTypeMgr.getViewBeanURL(subject);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getSubjectViewBeanURL", e);
    }
    return url;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 10 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 condition Condition Object.
     * @return properties view bean URL of a condition.
     */
public String getConditionViewBeanURL(String realmName, Condition condition) {
    String url = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ConditionTypeManager conditionTypeMgr = policyMgr.getConditionTypeManager();
            url = conditionTypeMgr.getViewBeanURL(condition);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getConditionViewBeanURL", e);
    }
    return url;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) ConditionTypeManager(com.sun.identity.policy.ConditionTypeManager) 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