Search in sources :

Example 1 with FSAuthDomainsModel

use of com.sun.identity.console.federation.model.FSAuthDomainsModel in project OpenAM by OpenRock.

the class FederationViewBean method handleDeleteCOTButtonRequest.

public void handleDeleteCOTButtonRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable tbl = (CCActionTable) getChild(COT_TABLE);
    tbl.restoreStateData();
    CCActionTableModel tableModel = (CCActionTableModel) propertySheetModel.getModel(COT_TABLE);
    // get selected rows
    Integer[] selected = tableModel.getSelectedRows();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    List list = (List) szCache.getSerializedObj();
    FSAuthDomainsModel model = (FSAuthDomainsModel) getModel();
    StringBuilder deletedNames = new StringBuilder();
    StringBuilder cannotDeleteds = new StringBuilder();
    // each COT is deleted separately as they can be in separate realms
    for (int i = 0; i < selected.length; i++) {
        String str = (String) list.get(selected[i].intValue());
        int pipeIndex = str.indexOf(",");
        String name = str.substring(0, pipeIndex);
        String realm = str.substring(pipeIndex + 1);
        try {
            model.deleteAuthenticationDomain(realm, name);
            if (deletedNames.length() > 0) {
                deletedNames.append(", ");
            }
            deletedNames.append(name);
        } catch (AMConsoleException e) {
            if (cannotDeleteds.length() > 0) {
                cannotDeleteds.append(", ");
            }
            cannotDeleteds.append(e.getMessage());
        }
    }
    StringBuilder message = new StringBuilder();
    if (deletedNames.length() > 0) {
        Object[] params = { deletedNames };
        message.append(MessageFormat.format(model.getLocalizedString("authDomain.message.deleted"), params));
    }
    if (cannotDeleteds.length() > 0) {
        Object[] params = { cannotDeleteds };
        message.append(MessageFormat.format(model.getLocalizedString("generic.error.message"), params));
    }
    if (message.length() > 0) {
        setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", message.toString());
    }
    forwardTo();
}
Also used : CCActionTableModel(com.sun.web.ui.model.CCActionTableModel) FSAuthDomainsModel(com.sun.identity.console.federation.model.FSAuthDomainsModel) CCActionTable(com.sun.web.ui.view.table.CCActionTable) SerializedField(com.sun.identity.console.components.view.html.SerializedField) ArrayList(java.util.ArrayList) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 2 with FSAuthDomainsModel

use of com.sun.identity.console.federation.model.FSAuthDomainsModel in project OpenAM by OpenRock.

the class FederationViewBean method populateCOTTable.

private void populateCOTTable() {
    tablePopulated = true;
    FSAuthDomainsModel model = (FSAuthDomainsModel) getModel();
    Set circleOfTrustDescriptors = model.getCircleOfTrustDescriptors();
    CCActionTableModel tableModel = (CCActionTableModel) propertySheetModel.getModel(COT_TABLE);
    tableModel.clearAll();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    if ((circleOfTrustDescriptors != null) && (!circleOfTrustDescriptors.isEmpty())) {
        List cache = new ArrayList(circleOfTrustDescriptors.size());
        boolean first = true;
        for (Iterator iter = circleOfTrustDescriptors.iterator(); iter.hasNext(); ) {
            if (first) {
                first = false;
            } else {
                tableModel.appendRow();
            }
            CircleOfTrustDescriptor desc = (CircleOfTrustDescriptor) iter.next();
            String name = desc.getCircleOfTrustName();
            tableModel.setValue(COT_NAME_VALUE, name);
            tableModel.setValue(COT_NAME_HREF, stringToHex(name));
            // get entity/provider name
            Set entitySet = desc.getTrustedProviders();
            if ((entitySet != null) && (!entitySet.isEmpty())) {
                Iterator it = entitySet.iterator();
                StringBuffer sb = new StringBuffer();
                Encoder encoder = ESAPI.encoder();
                while (it.hasNext()) {
                    String entity = (String) it.next();
                    sb.append(encoder.encodeForHTML(entity)).append("<br>");
                }
                tableModel.setValue(COT_ENTITY_VALUE, sb.toString());
            } else {
                tableModel.setValue(COT_ENTITY_VALUE, "");
            }
            // get realm name
            String realm = desc.getCircleOfTrustRealm();
            tableModel.setValue(COT_REALM_VALUE, realm);
            // get cot status
            String status = desc.getCircleOfTrustStatus();
            if ((status != null) && status.equals("active")) {
                tableModel.setValue(COT_STATUS_VALUE, "label.active");
            } else {
                tableModel.setValue(COT_STATUS_VALUE, "label.inactive");
            }
            cache.add(name + "," + realm);
        }
        szCache.setValue((ArrayList) cache);
    } else {
        szCache.setValue(null);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CCActionTableModel(com.sun.web.ui.model.CCActionTableModel) SerializedField(com.sun.identity.console.components.view.html.SerializedField) Encoder(org.owasp.esapi.Encoder) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) FSAuthDomainsModel(com.sun.identity.console.federation.model.FSAuthDomainsModel) ArrayList(java.util.ArrayList) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor)

Example 3 with FSAuthDomainsModel

use of com.sun.identity.console.federation.model.FSAuthDomainsModel in project OpenAM by OpenRock.

the class CreateCOTViewBean method populateRealmData.

private void populateRealmData() {
    FSAuthDomainsModel model = (FSAuthDomainsModel) getModel();
    try {
        Set realmNames = new TreeSet(model.getRealmNames("/", "*"));
        CCDropDownMenu menu = (CCDropDownMenu) getChild(SINGLECHOICE_REALM_MENU);
        OptionList list = new OptionList();
        for (Iterator i = realmNames.iterator(); i.hasNext(); ) {
            String name = (String) i.next();
            list.add(getPath(name), name);
        }
        menu.setOptions(list);
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) FSAuthDomainsModel(com.sun.identity.console.federation.model.FSAuthDomainsModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) CCDropDownMenu(com.sun.web.ui.view.html.CCDropDownMenu) OptionList(com.iplanet.jato.view.html.OptionList)

Example 4 with FSAuthDomainsModel

use of com.sun.identity.console.federation.model.FSAuthDomainsModel in project OpenAM by OpenRock.

the class CreateCOTViewBean method handleButton1Request.

/**
     * Handles save button request.
     * save
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    FSAuthDomainsModel model = (FSAuthDomainsModel) getModel();
    AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTIES);
    try {
        Map values = ps.getAttributeValues(model.getDataMap(), false, model);
        String name = (String) getDisplayFieldValue(model.TF_NAME);
        if ((name == null) || (name.length() < 1)) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getLocalizedString("authdomain.authentication.domain.name.missing.message"));
            psModel.setErrorProperty("nameProperty", true);
            forwardTo();
        } else {
            CCAddRemove addRemoveList = (CCAddRemove) getChild(ADD_REMOVE_PROVIDERS);
            addRemoveList.restoreStateData();
            CCAddRemoveModel addRemoveModel = (CCAddRemoveModel) addRemoveList.getModel();
            Set providers = new HashSet(getSelectedValues(addRemoveModel));
            model.createAuthenticationDomain(values, providers);
            Object[] params = { name };
            String message = MessageFormat.format(model.getLocalizedString("authentication.domain.create.message"), params);
            setPageSessionAttribute(FederationViewBean.MESSAGE_TEXT, message);
            backTrail();
            FederationViewBean vb = (FederationViewBean) getViewBean(FederationViewBean.class);
            passPgSessionMap(vb);
            vb.forwardTo(getRequestContext());
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        forwardTo();
    }
}
Also used : CCAddRemoveModel(com.sun.web.ui.model.CCAddRemoveModel) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) AMPropertySheet(com.sun.identity.console.base.AMPropertySheet) FSAuthDomainsModel(com.sun.identity.console.federation.model.FSAuthDomainsModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) CCAddRemove(com.sun.web.ui.view.addremove.CCAddRemove) HashSet(java.util.HashSet)

Example 5 with FSAuthDomainsModel

use of com.sun.identity.console.federation.model.FSAuthDomainsModel in project OpenAM by OpenRock.

the class FSAuthDomainsEditViewBean method getBreadCrumbDisplayName.

protected String getBreadCrumbDisplayName() {
    String name = (String) getPageSessionAttribute(FSAuthDomainsModel.TF_NAME);
    String[] arg = { name };
    FSAuthDomainsModel model = (FSAuthDomainsModel) getModel();
    return MessageFormat.format(model.getLocalizedString("breadcrumbs.federation.authdomains.edit"), arg);
}
Also used : FSAuthDomainsModel(com.sun.identity.console.federation.model.FSAuthDomainsModel)

Aggregations

FSAuthDomainsModel (com.sun.identity.console.federation.model.FSAuthDomainsModel)8 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)6 HashSet (java.util.HashSet)5 Set (java.util.Set)5 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)4 CCAddRemoveModel (com.sun.web.ui.model.CCAddRemoveModel)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 OptionList (com.iplanet.jato.view.html.OptionList)3 SerializedField (com.sun.identity.console.components.view.html.SerializedField)3 TreeSet (java.util.TreeSet)3 CCActionTableModel (com.sun.web.ui.model.CCActionTableModel)2 CCAddRemove (com.sun.web.ui.view.addremove.CCAddRemove)2 Iterator (java.util.Iterator)2 CircleOfTrustDescriptor (com.sun.identity.cot.CircleOfTrustDescriptor)1 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)1 CCDropDownMenu (com.sun.web.ui.view.html.CCDropDownMenu)1 CCActionTable (com.sun.web.ui.view.table.CCActionTable)1