Search in sources :

Example 31 with OptionList

use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.

the class SAMLv2Base method populateAuthenticationContext.

/**
     * For the given set of authContexts read from the extended metadata, populate the table and dropdown menu
     * @param authContexts The set of SAMLv2AuthContexts read from the extended metadata
     * @param tblAuthContextsModel The table model to populate
     * @param dropdownContextRef The name of the context dropdown menu component to populate
     */
protected void populateAuthenticationContext(SAMLv2AuthContexts authContexts, CCActionTableModel tblAuthContextsModel, String dropdownContextRef) {
    // Create lists from defaults that can be updated as there maybe custom entries from the extended metadata.
    Set<String> contextNames = new LinkedHashSet<String>(DEFAULT_AUTH_CONTEXT_REF_NAMES);
    OptionList options = new OptionList();
    // Used to indicate no default context
    options.add(getLabel("none"), "none");
    for (String name : contextNames) {
        options.add(getLabel(name), name);
    }
    // Need to compare the list from the metadata to the default list and any that are missing should be added
    // to the set being shown in the console as they will be custom entries
    Map<String, SAMLv2AuthContexts.SAMLv2AuthContext> contexts = authContexts.getCollections();
    for (SAMLv2AuthContexts.SAMLv2AuthContext value : contexts.values()) {
        if (contextNames.add(value.name)) {
            options.add(getLabel(value.name), value.name);
        }
    }
    CCDropDownMenu ac = (CCDropDownMenu) getChild(dropdownContextRef);
    ac.setOptions(options);
    tblAuthContextsModel.clear();
    int i = 0;
    for (String name : contextNames) {
        populateAuthenticationContext(name, authContexts, i++, tblAuthContextsModel, dropdownContextRef);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CCDropDownMenu(com.sun.web.ui.view.html.CCDropDownMenu) OptionList(com.iplanet.jato.view.html.OptionList)

Example 32 with OptionList

use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.

the class SubjectOpViewBeanBase method createOptionList.

protected OptionList createOptionList(Set values) {
    OptionList optList = new OptionList();
    if ((values != null) && !values.isEmpty()) {
        PolicyModel model = (PolicyModel) getModel();
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        String subjectType = (String) propertySheetModel.getValue(SUBJECT_TYPE);
        Map mapLabels = model.getDisplayNameForSubjectValues(realmName, subjectType, values);
        List tmp = AMFormatUtils.sortItems(values, model.getUserLocale());
        for (Iterator iter = tmp.iterator(); iter.hasNext(); ) {
            String value = (String) iter.next();
            optList.add((String) mapLabels.get(value), value);
        }
    }
    return optList;
}
Also used : Iterator(java.util.Iterator) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) Map(java.util.Map) OptionList(com.iplanet.jato.view.html.OptionList)

Example 33 with OptionList

use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.

the class SubjectOpViewBeanBase method setPossibleValues.

private void setPossibleValues(String childName) {
    if (canModify) {
        CCSelect selectView = (CCSelect) getChild(childName);
        Set values = getValidValues();
        if (values != null) {
            OptionList optList = createOptionList(values);
            selectView.setOptions(optList);
        }
        String defaultVal = "";
        if (!bFilter) {
            Set defaultsValues = getDefaultValues();
            if ((defaultsValues != null) && !defaultsValues.isEmpty()) {
                defaultVal = (String) defaultsValues.iterator().next();
            }
            selectView.setValue("");
        }
    } else {
        if (!bFilter) {
            Set defaultsValues = getDefaultValues();
            propertySheetModel.setValue(childName, defaultsValues.iterator().next());
        }
    }
}
Also used : Set(java.util.Set) CCSelect(com.sun.web.ui.view.html.CCSelect) OptionList(com.iplanet.jato.view.html.OptionList)

Example 34 with OptionList

use of com.iplanet.jato.view.html.OptionList 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();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) HashMap(java.util.HashMap) Iterator(java.util.Iterator) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) OptionList(com.iplanet.jato.view.html.OptionList)

Example 35 with OptionList

use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.

the class SubjectOpViewBeanBase method setAddRemoveModel.

protected void setAddRemoveModel() throws ModelControlException {
    if (canModify) {
        Set values = getValidValues();
        CCAddRemove child = (CCAddRemove) getChild(VALUES_MULTIPLE_CHOICE_VALUE);
        Set defaultValues = (bFilter) ? getValues() : getDefaultValues();
        child.resetStateData();
        if (values != null) {
            if (defaultValues != null) {
                values.removeAll(defaultValues);
            }
            addRemoveModel.setAvailableOptionList(createOptionList(values));
        } else {
            addRemoveModel.setAvailableOptionList(new OptionList());
        }
        addRemoveModel.setSelectedOptionList(createOptionList(defaultValues));
    }
}
Also used : Set(java.util.Set) CCAddRemove(com.sun.web.ui.view.addremove.CCAddRemove) OptionList(com.iplanet.jato.view.html.OptionList)

Aggregations

OptionList (com.iplanet.jato.view.html.OptionList)75 Set (java.util.Set)35 Iterator (java.util.Iterator)27 CCDropDownMenu (com.sun.web.ui.view.html.CCDropDownMenu)25 Map (java.util.Map)24 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)21 HashSet (java.util.HashSet)17 List (java.util.List)15 HashMap (java.util.HashMap)13 ArrayList (java.util.ArrayList)9 Option (com.iplanet.jato.view.html.Option)7 CCAddRemoveModel (com.sun.web.ui.model.CCAddRemoveModel)7 CCAddRemove (com.sun.web.ui.view.addremove.CCAddRemove)7 EntitiesModel (com.sun.identity.console.idm.model.EntitiesModel)6 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)6 CCRadioButton (com.sun.web.ui.view.html.CCRadioButton)6 TreeSet (java.util.TreeSet)6 IdentitySubjectModel (com.sun.identity.console.policy.model.IdentitySubjectModel)5 TaskModel (com.sun.identity.console.task.model.TaskModel)5 CCSelect (com.sun.web.ui.view.html.CCSelect)5