use of com.sun.identity.policy.ActionSchema in project OpenAM by OpenRock.
the class RuleOpViewBeanBase method populateActionsTable.
protected void populateActionsTable(boolean retainSelectedEntry) throws ModelControlException, AMConsoleException {
CCActionTable table = (CCActionTable) getChild(TBL_ACTIONS);
table.resetStateData();
tblActionsModel.clearAll();
PolicyModel model = (PolicyModel) getModel();
String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
String serviceType = (String) propertySheetModel.getValue(SERVICE_TYPE);
boolean withResource = false;
Boolean b = ((Boolean) getPageSessionAttribute(WITH_RESOURCE));
if (b != null) {
withResource = b.booleanValue();
}
actionSchemas = new ArrayList(model.getActionSchemas(getCachedPolicy().getPolicy(), realmName, serviceType, withResource));
if ((actionSchemas != null) && !actionSchemas.isEmpty()) {
int sz = actionSchemas.size();
ArrayList actionSchemaNames = new ArrayList(sz);
for (int i = 0; i < sz; i++) {
if (i > 0) {
tblActionsModel.appendRow();
}
ActionSchema as = (ActionSchema) actionSchemas.get(i);
boolean sel = isActionSelected(as);
tblActionsModel.setRowSelected(i, sel);
actionSchemaNames.add(as.getName());
tblActionsModel.setValue(TBL_ACTIONS_DATA_NAME, model.getActionSchemaLocalizedName(serviceType, as));
}
setPageSessionAttribute(PG_SESSION_ACTION_SCHEMA_NAMES, actionSchemaNames);
}
}
use of com.sun.identity.policy.ActionSchema in project OpenAM by OpenRock.
the class RuleOpViewBeanBase method getActionValues.
private Map getActionValues(String serviceType, boolean withResource) throws ModelControlException {
Map actionValues = new HashMap();
PolicyModel model = (PolicyModel) getModel();
String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
try {
Map mapActionSchemas = mapActionSchemaNameToActionSchema(model.getActionSchemas(getCachedPolicy().getPolicy(), realmName, serviceType, withResource));
CCActionTable table = (CCActionTable) getChild(TBL_ACTIONS);
table.restoreStateData();
List actionSchemaNames = (List) getPageSessionAttribute(PG_SESSION_ACTION_SCHEMA_NAMES);
if ((actionSchemaNames != null) && !actionSchemaNames.isEmpty()) {
HttpServletRequest req = getRequestContext().getRequest();
String chkName = getName() + "." + SELECTION_CHKBOX_NAME;
int sz = actionSchemaNames.size();
for (int i = 0; i < sz; i++) {
String chkValue = req.getParameter(chkName + i);
if ((chkValue != null) && chkValue.equals("true")) {
String actionSchemaName = (String) actionSchemaNames.get(i);
ActionSchema actionSchema = (ActionSchema) mapActionSchemas.get(actionSchemaName);
Set values = getActionSchemaValues(actionSchema, i);
actionValues.put(actionSchemaName, values);
}
}
}
if (actionValues.isEmpty()) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "policy.missing.actionValues");
actionValues = null;
}
} catch (AMConsoleException e) {
debug.warning("RuleOpViewBeanBase.getActionValues", e);
//NO-OP
}
return actionValues;
}
use of com.sun.identity.policy.ActionSchema in project OpenAM by OpenRock.
the class PrivilegeUtils method pravToPav.
static Map pravToPav(Map<String, Boolean> actionValues, String serviceName) throws PolicyException, SSOException {
if (actionValues == null) {
return null;
}
ServiceType serviceType = null;
try {
serviceType = svcTypeManager.getServiceType(serviceName);
} catch (NameNotFoundException e) {
//ignore
}
Map av = new HashMap();
Set<String> keySet = actionValues.keySet();
for (String action : keySet) {
try {
Set values = new HashSet();
Boolean value = actionValues.get(action);
if (serviceType != null) {
ActionSchema as = serviceType.getActionSchema(action);
String trueValue = as.getTrueValue();
String falseValue = as.getFalseValue();
if (value.equals(Boolean.TRUE)) {
values.add(trueValue);
} else {
values.add(falseValue);
}
} else {
values.add(value.toString());
}
av.put(action, values);
} catch (InvalidNameException e) {
Boolean value = actionValues.get(action);
Set values = new HashSet();
values.add(value.toString());
av.put(action, values);
}
}
return av;
}
use of com.sun.identity.policy.ActionSchema in project OpenAM by OpenRock.
the class PolicyModelImpl method getActionSchemas.
private Set getActionSchemas(ServiceType svcType) {
Set actionSchemas = null;
Set actionNames = svcType.getActionNames();
if ((actionNames != null) && !actionNames.isEmpty()) {
actionSchemas = new HashSet(actionNames.size() * 2);
for (Iterator iter = actionNames.iterator(); iter.hasNext(); ) {
String name = (String) iter.next();
ActionSchema as = getActionSchema(svcType, name);
if ((as != null) && isActionSchemaSupported(as)) {
actionSchemas.add(as);
}
}
}
return actionSchemas;
}
use of com.sun.identity.policy.ActionSchema in project OpenAM by OpenRock.
the class ActionTiledView method beginChildDisplay.
public boolean beginChildDisplay(ChildDisplayEvent event) {
super.endDisplay(event);
boolean display = true;
int rowIndex = model.getRowIndex();
if (rowIndex < model.getNumRows()) {
String childName = event.getChildName();
ActionSchema actionSchema = getActionSchema(rowIndex);
int type = AMDisplayType.getInstance().getDisplayType(actionSchema);
int syntax = AMDisplayType.getInstance().getDisplaySyntax(actionSchema);
if (childName.indexOf(RuleOpViewBeanBase.TBL_ACTIONS_RADIO_VALUE) != -1) {
display = displayRadioAction(actionSchema, childName, type, syntax);
} else if (childName.indexOf(RuleOpViewBeanBase.TBL_ACTIONS_CHECKBOX_VALUE) != -1) {
display = displayBooleanAction(actionSchema, childName, type, syntax);
} else if (childName.indexOf(RuleOpViewBeanBase.TBL_ACTIONS_PASSWORD_VALUE) != -1) {
display = displayPasswordAction(actionSchema, childName, type, syntax);
} else if (childName.indexOf(RuleOpViewBeanBase.TBL_ACTIONS_TEXTAREA_VALUE) != -1) {
display = displayTextAreaAction(actionSchema, childName, type, syntax);
} else if (childName.indexOf(RuleOpViewBeanBase.TBL_ACTIONS_TEXT_VALUE) != -1) {
display = displayTextFieldAction(actionSchema, childName, type, syntax);
} else if (childName.indexOf(RuleOpViewBeanBase.TBL_ACTIONS_DROPDOWN_MENU) != -1) {
display = displaySingleChoiceAction(actionSchema, childName, type, syntax);
} else if (childName.indexOf(RuleOpViewBeanBase.TBL_ACTIONS_SELECTABLE_LIST) != -1) {
display = displayMultipleChoiceAction(actionSchema, childName, type, syntax);
} else if (childName.indexOf(RuleOpViewBeanBase.TBL_ACTIONS_EDITABLE_LIST) != -1) {
display = displayEditableListAction(actionSchema, childName, type, syntax);
}
}
return display;
}
Aggregations