Search in sources :

Example 56 with PolicyException

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

the class PolicyModelImpl method createResponseProvider.

/**
     * Returns a response provider object.
     *
     * @param realmName Name of Realm.
     * @param providerType Name of response provider type.
     * @param values Values of the response provider.
     * @return response provider object.
     * @throws AMConsoleException if response provider cannot be created.
     */
public ResponseProvider createResponseProvider(String realmName, String providerType, Map values) throws AMConsoleException {
    ResponseProvider provider = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ResponseProviderTypeManager mgr = policyMgr.getResponseProviderTypeManager();
            provider = mgr.getResponseProvider(providerType);
            provider.setProperties(values);
        }
    } catch (NameNotFoundException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (PolicyException e) {
        throw new AMConsoleException(getErrorString(e));
    }
    return provider;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) ResponseProviderTypeManager(com.sun.identity.policy.ResponseProviderTypeManager)

Example 57 with PolicyException

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

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

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

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

Aggregations

PolicyException (com.sun.identity.policy.PolicyException)151 SSOException (com.iplanet.sso.SSOException)64 HashSet (java.util.HashSet)63 Set (java.util.Set)57 Iterator (java.util.Iterator)50 PolicyManager (com.sun.identity.policy.PolicyManager)35 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)32 HashMap (java.util.HashMap)28 Map (java.util.Map)27 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)26 ByteString (org.forgerock.opendj.ldap.ByteString)16 EntitlementException (com.sun.identity.entitlement.EntitlementException)14 LdapException (org.forgerock.opendj.ldap.LdapException)13 ResultCode (org.forgerock.opendj.ldap.ResultCode)13 Connection (org.forgerock.opendj.ldap.Connection)12 SearchResultEntry (org.forgerock.opendj.ldap.responses.SearchResultEntry)12 InvalidNameException (com.sun.identity.policy.InvalidNameException)11 ValidValues (com.sun.identity.policy.ValidValues)11 IOException (java.io.IOException)11 ConnectionEntryReader (org.forgerock.opendj.ldif.ConnectionEntryReader)11