Search in sources :

Example 26 with Condition

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

the class ProxyPETest method createAuthSchemeCondition.

private Condition createAuthSchemeCondition(PolicyManager pm) throws PolicyException {
    ConditionTypeManager mgr = pm.getConditionTypeManager();
    Condition cond = mgr.getCondition("AuthSchemeCondition");
    Map<String, Set<String>> map = new HashMap<String, Set<String>>();
    Set<String> set = new HashSet<String>();
    set.add("LDAP");
    map.put(Condition.AUTH_SCHEME, set);
    cond.setProperties(map);
    return cond;
}
Also used : Condition(com.sun.identity.policy.interfaces.Condition) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 27 with Condition

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

the class UpgradeUtils method removeDelegationCondition.

/**
      * Removes Condition Properties.
      *
      * @param policyName Name of Policy.
      * @param attributeName the name of the attribute whose default values
      *        needs to be updated.
      * @param conditionNameMap Map of condition name to map of property name to
      *        set of attribute values to be removed.
      */
public static void removeDelegationCondition(String policyName, String attributeName, Map conditionNameMap) {
    try {
        PolicyManager pm = new PolicyManager(ssoToken, HIDDEN_REALM);
        Policy policy = pm.getPolicy(policyName);
        for (Iterator i = conditionNameMap.keySet().iterator(); i.hasNext(); ) {
            String condName = (String) i.next();
            Condition cond = policy.getCondition(condName);
            if (cond != null) {
                Set removeSet = (HashSet) conditionNameMap.get(condName);
                Map orig = cond.getProperties();
                for (Iterator j = removeSet.iterator(); j.hasNext(); ) {
                    String defaultValue = (String) j.next();
                    Set origValues = (Set) orig.get(attributeName);
                    if (origValues != null) {
                        origValues.removeAll(removeSet);
                    }
                }
                cond.setProperties(orig);
                policy.replaceCondition(condName, cond);
            }
        }
        pm.replacePolicy(policy);
    } catch (PolicyException e) {
        debug.error("UpgradeUtils.removeDelegationCondition", e);
    } catch (SSOException e) {
        debug.error("UpgradeUtils.removeDelegationCondition", e);
    }
}
Also used : Policy(com.sun.identity.policy.Policy) Condition(com.sun.identity.policy.interfaces.Condition) PolicyManager(com.sun.identity.policy.PolicyManager) Set(java.util.Set) HashSet(java.util.HashSet) PolicyException(com.sun.identity.policy.PolicyException) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) SSOException(com.iplanet.sso.SSOException) ByteString(org.forgerock.opendj.ldap.ByteString) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Aggregations

Condition (com.sun.identity.policy.interfaces.Condition)27 Policy (com.sun.identity.policy.Policy)10 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)8 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)8 PolicyException (com.sun.identity.policy.PolicyException)8 HashMap (java.util.HashMap)8 Set (java.util.Set)8 HashSet (java.util.HashSet)7 Map (java.util.Map)7 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)6 EntitlementCondition (com.sun.identity.entitlement.EntitlementCondition)6 OrCondition (com.sun.identity.entitlement.OrCondition)6 PrivilegeCondition (com.sun.identity.policy.plugins.PrivilegeCondition)6 ConditionTypeManager (com.sun.identity.policy.ConditionTypeManager)5 PolicyManager (com.sun.identity.policy.PolicyManager)5 SSOException (com.iplanet.sso.SSOException)4 Iterator (java.util.Iterator)4 AndCondition (com.sun.identity.entitlement.AndCondition)3 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)2 EntitlementException (com.sun.identity.entitlement.EntitlementException)2