use of com.sun.identity.policy.interfaces.Condition in project OpenAM by OpenRock.
the class PrivilegePolicyMapping method createIPCondition.
private Condition createIPCondition(PolicyManager pm) throws PolicyException {
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 PrivilegePolicyMapping method createIPCondition1.
private Condition createIPCondition1(PolicyManager pm) throws PolicyException {
ConditionTypeManager mgr = pm.getConditionTypeManager();
Condition cond = mgr.getCondition("IPCondition");
cond.setProperties(ipConditionEnvMap1);
return cond;
}
use of com.sun.identity.policy.interfaces.Condition in project OpenAM by OpenRock.
the class UpgradeUtils method removeDelegationPolicyAttribute.
/**
* Removes attribute from a condition.
*
* @param policyName Name of Policy.
* @param attributeName the name of the attribute to be removed.
* @param conditionName name of the condition
*/
public static void removeDelegationPolicyAttribute(String policyName, String attributeName, String conditionName) {
String classMethod = "UpgradeUtils:removeDelegationPolicyAttribute";
try {
PolicyManager pm = new PolicyManager(ssoToken, HIDDEN_REALM);
Policy policy = pm.getPolicy(policyName);
Condition cond = policy.getCondition(conditionName);
HashMap newMap = new HashMap();
if (cond != null) {
Map orig = cond.getProperties();
Iterator i = (orig.keySet()).iterator();
while (i.hasNext()) {
String key = (String) i.next();
if (!key.equals(attributeName)) {
HashSet values = (HashSet) orig.get(key);
newMap.put(key, values);
}
}
if (debug.messageEnabled()) {
debug.message(classMethod + "attributes :" + newMap);
}
cond.setProperties(newMap);
policy.replaceCondition(conditionName, cond);
}
pm.replacePolicy(policy);
} catch (PolicyException e) {
debug.error(classMethod, e);
} catch (SSOException e) {
debug.error(classMethod, e);
}
}
use of com.sun.identity.policy.interfaces.Condition in project OpenAM by OpenRock.
the class PrivilegeUtils method privilegeToPolicy.
public static Policy privilegeToPolicy(String realm, Privilege privilege) throws PolicyException, SSOException, EntitlementException {
Policy policy = new Policy(privilege.getName());
policy.setDescription(privilege.getDescription());
if (privilege.getEntitlement() != null) {
Entitlement entitlement = privilege.getEntitlement();
Set<Rule> rules = entitlementToRule(realm, entitlement);
for (Rule rule : rules) {
policy.addRule(rule);
}
}
EntitlementSubject es = privilege.getSubject();
if ((es != null) && (es != Privilege.NOT_SUBJECT)) {
Subject sbj = eSubjectToEPSubject(es);
policy.addSubject(getSubjectName(es), sbj, false);
}
EntitlementCondition ec = privilege.getCondition();
if (ec != null) {
Condition cond = eConditionToEPCondition(ec);
policy.addCondition(getConditionName(ec), cond);
}
if (privilege.getResourceAttributes() != null) {
Map<String, ResponseProvider> nrps = resourceAttributesToResponseProviders(privilege.getResourceAttributes());
for (String rpName : nrps.keySet()) {
ResponseProvider responseProvider = nrps.get(rpName);
policy.addResponseProvider(rpName, responseProvider);
}
}
policy.setCreatedBy(privilege.getCreatedBy());
policy.setCreationDate(privilege.getCreationDate());
policy.setLastModifiedBy(privilege.getLastModifiedBy());
policy.setLastModifiedDate(privilege.getLastModifiedDate());
return policy;
}
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();
}
Aggregations