use of com.sun.identity.policy.Policy in project OpenAM by OpenRock.
the class PolicyOpViewBeanBase method populateSubjectsTable.
protected void populateSubjectsTable() throws AMConsoleException {
tblSubjectsModel.clearAll();
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
Set subjectsNames = policy.getSubjectNames();
if ((subjectsNames != null) && !subjectsNames.isEmpty()) {
PolicyModel model = (PolicyModel) getModel();
String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
QueryResults queryResults = model.getActiveSubjectTypes(realmName);
Map localizedSbjTypeNames = (Map) queryResults.getResults();
boolean firstEntry = true;
for (Iterator iter = subjectsNames.iterator(); iter.hasNext(); ) {
if (firstEntry) {
firstEntry = false;
} else {
tblSubjectsModel.appendRow();
}
try {
String name = (String) iter.next();
Subject subject = policy.getSubject(name);
tblSubjectsModel.setValue(TBL_SUBJECTS_DATA_NAME, name);
String sbjTypeName = model.getSubjectTypeName(realmName, subject);
String displayName = (String) localizedSbjTypeNames.get(sbjTypeName);
if (displayName == null) {
displayName = sbjTypeName;
}
tblSubjectsModel.setValue(TBL_SUBJECTS_DATA_TYPE, displayName);
tblSubjectsModel.setValue(TBL_SUBJECTS_ACTION_HREF, stringToHex(name));
} catch (NameNotFoundException e) {
debug.warning("PolicyOpViewBeanBase.populateSubjectsTable", e);
}
}
}
}
use of com.sun.identity.policy.Policy 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.Policy in project OpenAM by OpenRock.
the class PolicyOpViewBeanBase method handleTblReferralsEditLinkRequest.
public void handleTblReferralsEditLinkRequest(RequestInvocationEvent event) throws ModelControlException {
PolicyModel model = (PolicyModel) getModel();
String name = hexToString((String) getDisplayFieldValue(TBL_REFERRALS_ACTION_HREF));
setPageSessionAttribute(ReferralEditViewBean.CALLING_VIEW_BEAN, getClass().getName());
setPageSessionAttribute(ReferralEditViewBean.EDIT_REFERRAL_NAME, name);
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
Referral referral = policy.getReferral(name);
String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
String referralType = referral.getReferralTypeName();
String viewBeanURL = model.getReferralViewBeanURL(realmName, referralType);
unlockPageTrail();
if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
forwardToReferralURL(viewBeanURL, name, referralType, realmName, "edit");
} else {
forwardToReferralEditViewBean(model, realmName, name, referralType);
}
} catch (NameNotFoundException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
forwardTo();
} catch (AMConsoleException e) {
debug.warning("PolicyOpViewBeanBase.handleTblReferralsEditLinkRequest", e);
redirectToStartURL();
}
}
use of com.sun.identity.policy.Policy in project OpenAM by OpenRock.
the class PolicyOpViewBeanBase method handleTblResponseProvidersButtonDeleteRequest.
/**
* Handles delete response attribute request.
*
* @param event Request Invocation Event.
*/
public void handleTblResponseProvidersButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
CCActionTable table = (CCActionTable) getChild(TBL_RESPONSE_ATTRIBUTES);
table.restoreStateData();
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
Integer[] selected = tblResponseProvidersModel.getSelectedRows();
for (int i = 0; i < selected.length; i++) {
tblResponseProvidersModel.setRowIndex(selected[i].intValue());
String responseProviderName = (String) tblResponseProvidersModel.getValue(TBL_RESPONSE_ATTRIBUTES_DATA_NAME);
policy.removeResponseProvider(responseProviderName);
}
cachedPolicy.setPolicyModified(true);
populateResponseProvidersTable();
forwardTo();
} catch (AMConsoleException e) {
debug.warning("PolicyOpViewBeanBase.handleTblResponseProvidersButtonDeleteRequest", e);
redirectToStartURL();
}
}
use of com.sun.identity.policy.Policy 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);
}
}
Aggregations