use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.
the class PolicyOpViewBeanBase method beginDisplay.
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event);
try {
populateRulesTable();
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
PolicyModel model = (PolicyModel) getModel();
CCButton btn = (CCButton) getChild("tblRulesButtonAdd");
if (!model.canCreateRule(policy, realmName)) {
btn.setDisabled(true);
}
btn = (CCButton) getChild("tblRulesButtonDelete");
btn.setDisabled(true);
Map serviceTypes = model.getServiceTypeNames();
if ((serviceTypes == null) || serviceTypes.isEmpty()) {
((CCButton) getChild("tblRulesButtonDelete")).setDisabled(true);
setDisplayFieldValue("tblRulesNote", model.getLocalizedString("policy.no.service.types"));
} else {
setDisplayFieldValue("tblRulesNote", "");
}
if (!isInlineAlertMessageSet() && cachedPolicy.isPolicyModified() && isProfilePage()) {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.unsaved.message");
}
} catch (AMConsoleException e) {
CCButton btn = (CCButton) getChild("tblRulesButtonAdd");
btn.setDisabled(true);
btn = (CCButton) getChild("tblRulesButtonDelete");
btn.setDisabled(true);
}
}
use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.
the class PolicyOpViewBeanBase method handleTblConditionsButtonAddRequest.
public void handleTblConditionsButtonAddRequest(RequestInvocationEvent event) throws ModelControlException {
PolicyModel model = (PolicyModel) getModel();
try {
if (!reconstructPolicy()) {
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
Map activeConditionTypes = model.getActiveConditionTypes(curRealm);
unlockPageTrail();
if (activeConditionTypes.size() == 1) {
String conditionType = (String) activeConditionTypes.keySet().iterator().next();
String viewBeanURL = model.getConditionViewBeanURL(curRealm, conditionType);
removePageSessionAttribute(WIZARD);
setPageSessionAttribute(ConditionOpViewBeanBase.CALLING_VIEW_BEAN, getClass().getName());
if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
forwardToConditionURL(viewBeanURL, "", conditionType, curRealm, "add");
} else {
forwardToConditionAddViewBean(curRealm, conditionType);
}
} else {
setPageSessionAttribute(SelectConditionTypeViewBean.CALLING_VIEW_BEAN, getClass().getName());
SelectConditionTypeViewBean vb = (SelectConditionTypeViewBean) getViewBean(SelectConditionTypeViewBean.class);
setPageSessionAttribute(WIZARD, "true");
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
}
} else {
forwardTo();
}
} catch (AMConsoleException e) {
debug.warning("PolicyOpViewBeanBase.handleTblConditionsButtonAddRequest", e);
redirectToStartURL();
}
}
use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.
the class IdentityMembershipConditionAddViewBean method beginDisplay.
/**
* Sets the values to UI model.
*
* @param event Display Event.
* @throws ModelControlException if the default UI model is not accessible.
*/
public void beginDisplay(DisplayEvent event) throws ModelControlException {
IdentitySubjectModel subjectModel = getSubjectModel();
PolicyModel model = (PolicyModel) getModel();
super.beginDisplay(event);
CCDropDownMenu menu = (CCDropDownMenu) getChild(FILTER_TYPE);
Map supportedEntityTypes = model.getSupportedEntityTypes(realmName);
OptionList entityTypes = createOptionList(supportedEntityTypes);
entityTypes.add(0, "policy.subject.select.identity.type", "");
menu.setOptions(entityTypes);
menu.setValue("");
// initialize the available/selected component
CCAddRemove child = (CCAddRemove) getChild(VALUES_MULTIPLE_CHOICE_VALUE);
child.restoreStateData();
OptionList selected = addRemoveModel.getSelectedOptionList();
OptionList possible = helper.createOptionList(model.getUserSSOToken(), model.getUserLocale(), this, getPossibleValues(subjectModel, realmName));
child.resetStateData();
addRemoveModel.setAvailableOptionList(possible);
}
use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.
the class IdentityMembershipConditionEditViewBean method beginDisplay.
/**
* Sets the values to UI model.
*
* @param event Display Event.
*/
public void beginDisplay(DisplayEvent event) throws ModelControlException {
IdentitySubjectModel subjectModel = getSubjectModel();
PolicyModel model = (PolicyModel) getModel();
super.beginDisplay(event);
if (!canModify) {
Map mapValues = getDefaultValues();
if ((mapValues != null) && !mapValues.isEmpty()) {
Set values = (Set) mapValues.get(AMIdentityMembershipCondition.AM_IDENTITY_NAME);
Set identityNames = helper.getAMIdentityNames(model.getUserSSOToken(), values);
propertySheetModel.setValue(VALUES_MULTIPLE_CHOICE_VALUE, AMAdminUtils.getString(identityNames, ",", false));
}
} else {
CCDropDownMenu menu = (CCDropDownMenu) getChild(FILTER_TYPE);
Map supportedEntityTypes = model.getSupportedEntityTypes(realmName);
OptionList entityTypes = createOptionList(supportedEntityTypes);
entityTypes.add(0, "policy.subject.select.identity.type", "");
menu.setOptions(entityTypes);
menu.setValue("");
CCAddRemove child = (CCAddRemove) getChild(VALUES_MULTIPLE_CHOICE_VALUE);
child.restoreStateData();
if (!submitCycle) {
helper.setSelectedIdentities(child, model.getUserSSOToken(), model.getUserLocale(), this, getDefaultValues());
} else {
// initialize the available/selected component
OptionList possible = helper.createOptionList(model.getUserSSOToken(), model.getUserLocale(), this, getPossibleValues(subjectModel, realmName));
OptionList selected = addRemoveModel.getSelectedOptionList();
List selectedIds = AMAdminUtils.toList(selected);
child.resetStateData();
addRemoveModel.setAvailableOptionList(possible);
addRemoveModel.setSelectedOptionList(helper.createOptionList(model.getUserSSOToken(), model.getUserLocale(), this, selectedIds));
}
}
}
use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.
the class PMDefaultAuthLevelConditionEditViewBean method beginDisplay.
/**
* Searches for realms and set up realm selectable list.
*
* @param event Display Event.
* @throws ModelControlException if <code>JATO</code> default model fails.
*/
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event);
String filter = (String) getDisplayFieldValue(AuthLevelHelper.ATTR_FILTER);
if ((filter == null) || (filter.trim().length() == 0)) {
setDisplayFieldValue(AuthLevelHelper.ATTR_FILTER, "*");
}
PolicyModel model = (PolicyModel) getModel();
try {
Set realmNames = helper.getRealmNames(filter, model);
if (realmNames.isEmpty()) {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.condition.authlevel.no.search.result.message");
} else {
realmNames.add("");
}
String realmValue = (String) propertySheetModel.getValue(AuthLevelHelper.ATTR_REALM);
if (realmValue == null) {
realmValue = "";
}
if (!bSearchForRealm) {
if ((realmValue.length() > 0) && !realmNames.contains(realmValue)) {
realmNames.add(realmValue);
if (!isInlineAlertMessageSet()) {
String msg = model.getLocalizedString("policy.condition.authlevel.no.longer.exist.realm");
String[] param = { realmValue };
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", MessageFormat.format(msg, (Object[]) param));
}
}
}
CCSelect sl = (CCSelect) getChild(AuthLevelHelper.ATTR_REALM);
sl.setOptions(createOptionList(getLabelValueMap(realmNames)));
if (sl.getValue() == null) {
sl.setValue(realmValue);
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
}
Aggregations