Search in sources :

Example 1 with FSSAMLServiceModel

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

the class FederationViewBean method populateSAMLTable.

private void populateSAMLTable() {
    tablePopulated = true;
    FSSAMLServiceModel model = (FSSAMLServiceModel) getSAMLModel();
    Map attrValues = model.getAttributeValues();
    CCActionTableModel tblModel = (CCActionTableModel) propertySheetModel.getModel(SAML_TABLE);
    tblModel.clearAll();
    removePageSessionAttribute(SAML_TABLE_ATTRIBUTE);
    List cache = new ArrayList();
    for (Iterator iter = attrValues.keySet().iterator(); iter.hasNext(); ) {
        String name = (String) iter.next();
        Set values = (Set) attrValues.get(name);
        if (name.equals(TABLE_TRUSTED_PARTNERS)) {
            AMPipeDelimitAttrTokenizer tokenizer = AMPipeDelimitAttrTokenizer.getInstance();
            boolean firstEntry = true;
            int counter = 0;
            for (Iterator iter2 = values.iterator(); iter2.hasNext(); ) {
                if (!firstEntry) {
                    tblModel.appendRow();
                } else {
                    firstEntry = false;
                }
                String tokenizedValue = (String) iter2.next();
                Map map = AMAdminUtils.upCaseKeys(tokenizer.tokenizes(tokenizedValue));
                String partnerName = (String) map.get(SAMLConstants.PARTNERNAME);
                if (partnerName == null) {
                    partnerName = (String) map.get(SAMLConstants.SOURCEID);
                }
                tblModel.setValue(SAML_TRUSTED_PARTNER_VALUE, partnerName);
                tblModel.setValue(SAML_TRUSTED_PARTNER_HREF, Integer.toString(counter++));
                cache.add(tokenizedValue);
                // get trusted partner type
                SAMLPropertyXMLBuilder builder = SAMLPropertyXMLBuilder.getInstance();
                List profiles = (ArrayList) builder.getSAMLProperties(map);
                StringBuffer trustedPartnerSourceType = new StringBuffer();
                StringBuffer trustedPartnerDestinationType = new StringBuffer();
                int size = profiles.size();
                for (int i = 0; i < size; i++) {
                    if (((SAMLProperty) profiles.get(i)).getRole().equals("destination")) {
                        if (trustedPartnerDestinationType.length() != 0) {
                            trustedPartnerDestinationType.append(", ");
                        }
                        trustedPartnerDestinationType.append(getTrustedPartnersSelectType(((SAMLProperty) profiles.get(i)).getBindMethod()));
                    } else {
                        // source
                        if (trustedPartnerSourceType.length() != 0) {
                            trustedPartnerSourceType.append(", ");
                        }
                        trustedPartnerSourceType.append(getTrustedPartnersSelectType(((SAMLProperty) profiles.get(i)).getBindMethod()));
                    }
                }
                tblModel.setValue(SAML_TRUSTED_PARTNER_DESTINATION_TYPE, trustedPartnerDestinationType.toString());
                tblModel.setValue(SAML_TRUSTED_PARTNER_SOURCE_TYPE, trustedPartnerSourceType.toString());
            }
            break;
        }
    }
    setPageSessionAttribute(SAML_TABLE_ATTRIBUTE, (ArrayList) cache);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CCActionTableModel(com.sun.web.ui.model.CCActionTableModel) ArrayList(java.util.ArrayList) AMPipeDelimitAttrTokenizer(com.sun.identity.console.base.AMPipeDelimitAttrTokenizer) Iterator(java.util.Iterator) FSSAMLServiceModel(com.sun.identity.console.federation.model.FSSAMLServiceModel) ArrayList(java.util.ArrayList) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with FSSAMLServiceModel

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

the class FSSAMLTrustedPartnersViewBeanBase method editEntry.

/**
     * Edits an entry to the cache value in page session.
     *
     * @param values Map of attribute name to value.
     * @throws AMConsoleException if there are duplicate entries.
     */
protected void editEntry(Map values) throws AMConsoleException {
    List list = (List) getPageSessionAttribute("samlPropertyAttributes");
    int index = Integer.parseInt((String) getPageSessionAttribute(PGATTR_INDEX));
    String value = AMPipeDelimitAttrTokenizer.getInstance().deTokenizes(values);
    int count = 0;
    for (Iterator i = list.iterator(); i.hasNext(); ) {
        String v = (String) i.next();
        if ((count != index) && v.equals(value)) {
            throw new AMConsoleException("saml.profile.trustedPartner.already.exists");
        }
        count++;
    }
    list.set(index, value);
    Set set = new HashSet(list);
    try {
        FSSAMLServiceModel model = (FSSAMLServiceModel) getModel();
        model.modifyTrustPartners(set);
        setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "saml.message.trusted.partner.updated");
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) Iterator(java.util.Iterator) List(java.util.List) FSSAMLServiceModel(com.sun.identity.console.federation.model.FSSAMLServiceModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashSet(java.util.HashSet)

Example 3 with FSSAMLServiceModel

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

the class FSSAMLTrustedPartnersAddViewBean method handleButton1Request.

protected void handleButton1Request(Map values) throws AMConsoleException {
    String value = AMPipeDelimitAttrTokenizer.getInstance().deTokenizes(values);
    // get the existing partners here
    FSSAMLServiceModel model = (FSSAMLServiceModel) getModel();
    Map attrValues = model.getAttributeValues();
    Set partners = null;
    Iterator iter = attrValues.keySet().iterator();
    while (iter.hasNext()) {
        String name = (String) iter.next();
        if (name.equals("iplanet-am-saml-partner-urls")) {
            partners = (Set) attrValues.get(name);
        }
    }
    if ((partners == null) || partners.isEmpty()) {
        partners = new HashSet();
    }
    // add new partner to existing partner set
    partners.add(value);
    Map map = new HashMap();
    map.put("iplanet-am-saml-partner-urls", partners);
    model.setAttributeValues(map);
    forwardToFederationView();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Iterator(java.util.Iterator) FSSAMLServiceModel(com.sun.identity.console.federation.model.FSSAMLServiceModel) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 4 with FSSAMLServiceModel

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

the class FSSAMLServiceViewBean method setValues.

void setValues() {
    Map attrValues = (Map) getPageSessionAttribute(PROPERTY_ATTRIBUTE);
    FSSAMLServiceModel model = (FSSAMLServiceModel) getModel();
    if (attrValues == null) {
        attrValues = model.getAttributeValues();
    }
    Map displayValues = new HashMap(attrValues.size() * 2);
    // set tables
    for (Iterator iter = attrValues.keySet().iterator(); iter.hasNext(); ) {
        String name = (String) iter.next();
        Set values = (Set) attrValues.get(name);
        if (tabledAttributes.contains(name)) {
            populateTable(name, values);
            OrderedSet ordered = new OrderedSet();
            ordered.addAll(values);
            displayValues.put(name, ordered);
        } else {
            displayValues.put(name, values);
        }
    }
    // set other attributes
    AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
    ps.setAttributeValues(attrValues, model);
    setPageSessionAttribute(PROPERTY_ATTRIBUTE, (HashMap) displayValues);
}
Also used : OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) HashSet(java.util.HashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) HashMap(java.util.HashMap) AMPropertySheet(com.sun.identity.console.base.AMPropertySheet) Iterator(java.util.Iterator) FSSAMLServiceModel(com.sun.identity.console.federation.model.FSSAMLServiceModel) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with FSSAMLServiceModel

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

the class FSSAMLServiceViewBean method handleButton1Request.

public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    FSSAMLServiceModel model = (FSSAMLServiceModel) getModel();
    try {
        model.setAttributeValues(getValues(true));
        setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "message.updated");
        handleButton2Request(event);
    } catch (AMConsoleException e) {
        try {
            setPageSessionAttribute(PROPERTY_ATTRIBUTE, (HashMap) getValues(false, false));
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            forwardTo();
        } catch (AMConsoleException ex) {
        /* exception will not be thrown because we are instructing
                 * AMPropertySheet to return values without doing password
                 * validation.
                 */
        }
    }
}
Also used : HashMap(java.util.HashMap) FSSAMLServiceModel(com.sun.identity.console.federation.model.FSSAMLServiceModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

FSSAMLServiceModel (com.sun.identity.console.federation.model.FSSAMLServiceModel)10 HashMap (java.util.HashMap)7 Iterator (java.util.Iterator)7 HashSet (java.util.HashSet)6 Map (java.util.Map)6 Set (java.util.Set)6 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)5 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)3 List (java.util.List)3 DisplayField (com.iplanet.jato.view.DisplayField)2 View (com.iplanet.jato.view.View)2 OptionList (com.iplanet.jato.view.html.OptionList)2 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)2 CCActionTableModel (com.sun.web.ui.model.CCActionTableModel)2 ArrayList (java.util.ArrayList)2 AMPipeDelimitAttrTokenizer (com.sun.identity.console.base.AMPipeDelimitAttrTokenizer)1 CCActionTable (com.sun.web.ui.view.table.CCActionTable)1