Search in sources :

Example 6 with ActionSchema

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);
    }
}
Also used : ArrayList(java.util.ArrayList) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) CCActionTable(com.sun.web.ui.view.table.CCActionTable) ActionSchema(com.sun.identity.policy.ActionSchema)

Example 7 with ActionSchema

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;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Set(java.util.Set) HashMap(java.util.HashMap) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) CCSelectableList(com.sun.web.ui.view.html.CCSelectableList) ArrayList(java.util.ArrayList) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) CCActionTable(com.sun.web.ui.view.table.CCActionTable) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) ActionSchema(com.sun.identity.policy.ActionSchema)

Example 8 with ActionSchema

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;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) InvalidNameException(com.sun.identity.policy.InvalidNameException) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) HashMap(java.util.HashMap) ServiceType(com.sun.identity.policy.ServiceType) HashMap(java.util.HashMap) Map(java.util.Map) ActionSchema(com.sun.identity.policy.ActionSchema) HashSet(java.util.HashSet)

Example 9 with ActionSchema

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;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) ActionSchema(com.sun.identity.policy.ActionSchema) HashSet(java.util.HashSet)

Example 10 with ActionSchema

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;
}
Also used : ActionSchema(com.sun.identity.policy.ActionSchema)

Aggregations

ActionSchema (com.sun.identity.policy.ActionSchema)10 Set (java.util.Set)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 Iterator (java.util.Iterator)5 Map (java.util.Map)5 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)2 InvalidNameException (com.sun.identity.policy.InvalidNameException)2 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)2 ServiceType (com.sun.identity.policy.ServiceType)2 CCActionTable (com.sun.web.ui.view.table.CCActionTable)2 ArrayList (java.util.ArrayList)2 OptionList (com.iplanet.jato.view.html.OptionList)1 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)1 CCSelectableList (com.sun.web.ui.view.html.CCSelectableList)1 List (java.util.List)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1