use of com.sun.identity.policy.interfaces.Condition in project OpenAM by OpenRock.
the class PMDefaultTimeConditionEditViewBean method getDefaultValues.
protected Map getDefaultValues() {
Map values = null;
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
String conditionName = (String) getPageSessionAttribute(ConditionOpViewBeanBase.PG_SESSION_CONDITION_NAME);
Condition condition = policy.getCondition(conditionName);
Map map = condition.getProperties();
for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
String propName = (String) iter.next();
Set val = (Set) map.get(propName);
if (propName.equals(SimpleTimeCondition.START_DATE)) {
String strDate = (String) val.iterator().next();
helper.setDate(this, true, strDate, getModel());
} else if (propName.equals(SimpleTimeCondition.END_DATE)) {
String strDate = (String) val.iterator().next();
helper.setDate(this, false, strDate, getModel());
} else if (propName.equals(SimpleTimeCondition.START_TIME)) {
String strTime = (String) val.iterator().next();
helper.setTime(this, true, strTime);
} else if (propName.equals(SimpleTimeCondition.END_TIME)) {
String strTime = (String) val.iterator().next();
helper.setTime(this, false, strTime);
} else if (propName.equals(SimpleTimeCondition.START_DAY)) {
String strDay = (String) val.iterator().next();
helper.setDay(this, true, strDay);
} else if (propName.equals(SimpleTimeCondition.END_DAY)) {
String strDay = (String) val.iterator().next();
helper.setDay(this, false, strDay);
} else if (propName.equals(SimpleTimeCondition.ENFORCEMENT_TIME_ZONE)) {
String strTz = (String) val.iterator().next();
helper.setTimeZone(this, canModify, strTz);
}
}
} catch (NameNotFoundException e) {
debug.warning("ConditionEditViewBean.getDefaultValues", e);
} catch (AMConsoleException e) {
debug.warning("ConditionEditViewBean.getDefaultValues", e);
}
//Yes, we are returning null;
return values;
}
use of com.sun.identity.policy.interfaces.Condition in project OpenAM by OpenRock.
the class ConditionEditViewBean method handleButton1Request.
private void handleButton1Request(CachedPolicy cachedPolicy) throws ModelControlException {
submitCycle = true;
boolean forwarded = false;
Condition deleted = null;
String origName = (String) getPageSessionAttribute(EDIT_CONDITION_NAME);
Policy policy = cachedPolicy.getPolicy();
try {
Condition condition = createCondition();
if (condition != null) {
String name = (String) propertySheetModel.getValue(CONDITION_NAME);
if (origName.equals(name)) {
policy.replaceCondition(name, condition);
} else {
deleted = policy.removeCondition(origName);
policy.addCondition(name, condition);
}
deleted = null;
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.condition.updated");
cachedPolicy.setPolicyModified(true);
}
} catch (NameAlreadyExistsException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
} catch (InvalidNameException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
} catch (NameNotFoundException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
} finally {
if (deleted != null) {
try {
policy.addCondition(origName, deleted);
} catch (NameAlreadyExistsException e) {
debug.warning("ConditionEditViewBean.handleButton1Request", e);
} catch (InvalidNameException e) {
debug.warning("ConditionEditViewBean.handleButton1Request", e);
}
}
}
forwardTo();
}
use of com.sun.identity.policy.interfaces.Condition 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;
}
use of com.sun.identity.policy.interfaces.Condition in project OpenAM by OpenRock.
the class MetaDataTest method createIPCondition.
private Condition createIPCondition(PolicyManager pm) throws PolicyException {
Map<String, Set<String>> ipConditionEnvMap = new HashMap<String, Set<String>>();
Set<String> set = new HashSet<String>();
set.add("whatever.whatever");
ipConditionEnvMap.put(Condition.DNS_NAME, set);
ConditionTypeManager mgr = pm.getConditionTypeManager();
Condition cond = mgr.getCondition("IPCondition");
cond.setProperties(ipConditionEnvMap);
return cond;
}
use of com.sun.identity.policy.interfaces.Condition in project OpenAM by OpenRock.
the class PolicyEvaluatorTest method createIPCondition.
private Condition createIPCondition(PolicyManager pm) throws PolicyException {
ConditionTypeManager mgr = pm.getConditionTypeManager();
Condition cond = mgr.getCondition("IPCondition");
Map<String, Set<String>> map = new HashMap<String, Set<String>>();
Set<String> set = new HashSet<String>();
set.add("whatever.whatever");
map.put(Condition.DNS_NAME, set);
cond.setProperties(map);
return cond;
}
Aggregations