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;
}
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);
}
}
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;
}
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;
}
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);
}
Aggregations