Search in sources :

Example 51 with PolicyManager

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

the class PolicyModelImpl method getConditionInstance.

private Condition getConditionInstance(String realmName, String conditionTypeName) {
    Condition condition = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ConditionTypeManager condTypeMgr = policyMgr.getConditionTypeManager();
            condition = condTypeMgr.getCondition(conditionTypeName);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getConditionInstance", e);
    } catch (NameNotFoundException e) {
        debug.warning("PolicyModelImpl.getConditionInstance", e);
    } catch (PolicyException e) {
        debug.warning("PolicyModelImpl.getConditionInstance", e);
    }
    return condition;
}
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 52 with PolicyManager

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

the class PolicyModelImpl method replacePolicy.

/**
     * Modifies a policy.
     *
     * @param realmName Name of realm.
     * @param policy Policy object.
     * @throws AMConsoleException if policy cannot be created.
     */
public void replacePolicy(String realmName, Policy policy) throws AMConsoleException {
    try {
        String[] params = { realmName, policy.getName() };
        logEvent("ATTEMPT_MODIFY_POLICY", params);
        PolicyManager policyManager = getPolicyManager(realmName);
        policyManager.replacePolicy(policy);
        logEvent("SUCCEED_MODIFY_POLICY", params);
    } catch (PolicyException e) {
        String strError = getErrorString(e);
        String[] params = { realmName, policy.getName(), strError };
        logEvent("POLICY_EXCEPTION_MODIFY_POLICY", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] params = { realmName, policy.getName(), strError };
        logEvent("SSO_EXCEPTION_MODIFY_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 53 with PolicyManager

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

the class PolicyModelImpl method getReferralViewBeanURL.

/**
     * Returns properties view bean URL of a referral.
     *
     * @param realmName Name of realm.
     * @param referralTypeName Name of Referral Type.
     * @return properties view bean URL of a referral.
     */
public String getReferralViewBeanURL(String realmName, String referralTypeName) {
    String url = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
            Referral referral = referralTypeMgr.getReferral(referralTypeName);
            url = referralTypeMgr.getViewBeanURL(referral);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getReferralViewBeanURL", e);
    } catch (NameNotFoundException e) {
        debug.warning("PolicyModelImpl.getReferralViewBeanURL", e);
    } catch (PolicyException e) {
        debug.warning("PolicyModelImpl.getReferralViewBeanURL", e);
    }
    return url;
}
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 54 with PolicyManager

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

the class PolicyModelImpl method getSubjectTypeName.

/**
     * Returns subject type name of a subject.
     *
     * @param realmName Name of realm.
     * @param subject Subject instance.
     * @return subject type name of a subject.
     */
public String getSubjectTypeName(String realmName, Subject subject) {
    String typeName = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
            typeName = subjectTypeMgr.getSubjectTypeName(subject);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getSubjectTypeName", e);
    }
    return typeName;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 55 with PolicyManager

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

the class PolicyModelImpl method getConditionTypeName.

/**
     * Returns condition type name of a condition.
     *
     * @param realmName Name of realm.
     * @param condition Condition instance.
     * @return Condition type name of a condition.
     */
public String getConditionTypeName(String realmName, Condition condition) {
    String typeName = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ConditionTypeManager conditionTypeMgr = policyMgr.getConditionTypeManager();
            typeName = conditionTypeMgr.getConditionTypeName(condition);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getConditionTypeName", e);
    }
    return typeName;
}
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