use of com.sun.identity.policy.Policy in project OpenAM by OpenRock.
the class RuleEditViewBean method getRule.
protected Rule getRule() throws NameNotFoundException, AMConsoleException {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
String ruleName = (String) getPageSessionAttribute(EDIT_RULE_NAME);
return policy.getRule(ruleName);
}
use of com.sun.identity.policy.Policy in project OpenAM by OpenRock.
the class SubjectEditViewBean method handleButton1Request.
private void handleButton1Request(CachedPolicy cachedPolicy) throws ModelControlException {
submitCycle = true;
Subject deleted = null;
String origName = (String) getPageSessionAttribute(EDIT_SUBJECT_NAME);
Policy policy = cachedPolicy.getPolicy();
try {
Subject subject = createSubject();
if (subject != null) {
String name = (String) propertySheetModel.getValue(SUBJECT_NAME);
if (origName.equals(name)) {
policy.replaceSubject(name, subject, isExclusive());
} else {
deleted = policy.removeSubject(origName);
policy.addSubject(name, subject, isExclusive());
}
deleted = null;
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.subject.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.addSubject(origName, deleted);
} catch (NameAlreadyExistsException e) {
debug.warning("SubjectEditViewBean.handleButton1Request", e);
} catch (InvalidNameException e) {
debug.warning("SubjectEditViewBean.handleButton1Request", e);
}
}
}
forwardTo();
}
use of com.sun.identity.policy.Policy in project OpenAM by OpenRock.
the class SelectServiceTypeViewBean method getTypeOptions.
protected OptionList getTypeOptions() {
PolicyModel model = (PolicyModel) getModel();
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
try {
Policy policy = getCachedPolicy().getPolicy();
Map map = model.getServiceTypeNames();
Map options = new HashMap();
for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
String name = (String) iter.next();
String label = (String) map.get(name);
if (model.requiredResourceName(policy, curRealm, name)) {
String[] param = { label };
String lbl = MessageFormat.format(model.getLocalizedString("policy.rules.withResourceName"), (Object[]) param);
options.put(name + "|" + WITH_RESOURCE_SUFFIX, lbl);
}
if (model.notRequiredResourceName(policy, curRealm, name)) {
String[] param = { label };
String lbl = MessageFormat.format(model.getLocalizedString("policy.rules.withoutResourceName"), (Object[]) param);
options.put(name + "|" + WITHOUT_RESOURCE_SUFFIX, lbl);
}
}
return AMFormatUtils.getSortedOptionList(options, model.getUserLocale());
} catch (AMConsoleException e) {
debug.message("SelectServiceTypeViewBean.getTypeOptions " + "creating empty option list");
return new OptionList();
}
}
use of com.sun.identity.policy.Policy in project OpenAM by OpenRock.
the class PolicyOpViewBeanBase method handleTblSubjectsButtonDeleteRequest.
/**
* Handles delete subject request.
*
* @param event Request Invocation Event.
*/
public void handleTblSubjectsButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
CCActionTable table = (CCActionTable) getChild(TBL_SUBJECTS);
table.restoreStateData();
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
Integer[] selected = tblSubjectsModel.getSelectedRows();
for (int i = 0; i < selected.length; i++) {
tblSubjectsModel.setRowIndex(selected[i].intValue());
String subjectName = (String) tblSubjectsModel.getValue(TBL_SUBJECTS_DATA_NAME);
policy.removeSubject(subjectName);
}
cachedPolicy.setPolicyModified(true);
populateSubjectsTable();
forwardTo();
} catch (AMConsoleException e) {
debug.warning("PolicyOpViewBeanBase.handleTblSubjectsButtonDeleteRequest", e);
redirectToStartURL();
}
}
use of com.sun.identity.policy.Policy in project OpenAM by OpenRock.
the class PolicyOpViewBeanBase method reconstructPolicyGeneral.
private boolean reconstructPolicyGeneral(PolicyModel model) throws AMConsoleException {
boolean bError = false;
String policyName = (String) propertySheetModel.getValue(PolicyModel.TF_NAME);
policyName = policyName.trim();
String description = (String) propertySheetModel.getValue(ATTR_DESCRIPTION);
description = description.trim();
String isActive = (String) propertySheetModel.getValue(ATTR_ISACTIVE);
boolean active = (isActive != null) && isActive.equals("true");
if (policyName.length() == 0) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "policy.missing.policyName");
bError = true;
return bError;
}
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
try {
policy.setDescription(description);
policy.setActive(active);
policy.setName(policyName);
} catch (InvalidNameException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
bError = true;
}
return bError;
}
Aggregations