Search in sources :

Example 16 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 17 with Condition

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

the class PolicyCondition method evaluate.

/**
     * Returns condition decision.
     *
     * @param realm Realm name.
     * @param subject Subject to be evaluated.
     * @param resourceName Resource name.
     * @param environment Environment map.
     * @return condition decision.
     * @throws com.sun.identity.entitlement.EntitlementException if error occur.
     */
public ConditionDecision evaluate(String realm, Subject subject, String resourceName, Map<String, Set<String>> environment) throws EntitlementException {
    try {
        SSOToken token = (subject != null) ? getSSOToken(subject) : null;
        Condition cond = getPolicyCondition();
        com.sun.identity.policy.ConditionDecision dec = cond.getConditionDecision(token, environment);
        return new ConditionDecision(dec.isAllowed(), dec.getAdvices(), dec.getTimeToLive());
    } catch (SSOException ex) {
        throw new EntitlementException(510, ex);
    } catch (PolicyException ex) {
        throw new EntitlementException(510, ex);
    }
}
Also used : Condition(com.sun.identity.policy.interfaces.Condition) EntitlementException(com.sun.identity.entitlement.EntitlementException) SSOToken(com.iplanet.sso.SSOToken) PolicyException(com.sun.identity.policy.PolicyException) SSOException(com.iplanet.sso.SSOException) ConditionDecision(com.sun.identity.entitlement.ConditionDecision)

Example 18 with Condition

use of com.sun.identity.policy.interfaces.Condition 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 19 with Condition

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

the class PolicyModelImpl method createCondition.

/**
     * Returns a condition object.
     *
     * @param realmName Name of Realm.
     * @param conditionType Name of condition type.
     * @param values Values of the condition.
     * @return condition object.
     * @throws AMConsoleException if condition cannot be created.
     */
public Condition createCondition(String realmName, String conditionType, Map values) throws AMConsoleException {
    Condition condition = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ConditionTypeManager conditionTypeMgr = policyMgr.getConditionTypeManager();
            condition = conditionTypeMgr.getCondition(conditionType);
            condition.setProperties(values);
        }
    } catch (NameNotFoundException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (PolicyException e) {
        throw new AMConsoleException(getErrorString(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 20 with Condition

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

the class Conditions method clone.

/**
     * Returns a new copy of this object with the identical
     * set of conditions collections (conditions).
     *
     * @return a copy of this object with identical values
     */
public Object clone() {
    Conditions answer = null;
    try {
        answer = (Conditions) super.clone();
    } catch (CloneNotSupportedException se) {
        answer = new Conditions();
    }
    answer.name = name;
    answer.description = description;
    answer.conditions = new HashMap();
    Iterator items = conditions.keySet().iterator();
    while (items.hasNext()) {
        Object item = items.next();
        Condition condition = (Condition) conditions.get(item);
        answer.conditions.put(item, condition.clone());
    }
    return (answer);
}
Also used : Condition(com.sun.identity.policy.interfaces.Condition)

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