Search in sources :

Example 41 with CaseInsensitiveHashMap

use of com.sun.identity.common.CaseInsensitiveHashMap in project OpenAM by OpenRock.

the class IdServicesImpl method mapAttributeNames.

private Map mapAttributeNames(Map attrMap, Map configMap) {
    if (attrMap == null || attrMap.isEmpty()) {
        return attrMap;
    }
    Map resultMap;
    Map[] mapArray = getAttributeNameMap(configMap);
    if (mapArray == null) {
        resultMap = attrMap;
    } else {
        resultMap = new CaseInsensitiveHashMap();
        Map forwardMap = mapArray[0];
        Iterator it = attrMap.keySet().iterator();
        while (it.hasNext()) {
            String curr = (String) it.next();
            if (forwardMap.containsKey(curr)) {
                resultMap.put((String) forwardMap.get(curr), (Set) attrMap.get(curr));
            } else {
                resultMap.put(curr, (Set) attrMap.get(curr));
            }
        }
    }
    return resultMap;
}
Also used : Iterator(java.util.Iterator) Map(java.util.Map) AMHashMap(com.iplanet.am.sdk.AMHashMap) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

Example 42 with CaseInsensitiveHashMap

use of com.sun.identity.common.CaseInsensitiveHashMap in project OpenAM by OpenRock.

the class IdServicesImpl method reverseMapAttributeNames.

private Map reverseMapAttributeNames(Map attrMap, Map configMap) {
    if (attrMap == null || attrMap.isEmpty()) {
        return attrMap;
    }
    Map resultMap;
    Map[] mapArray = getAttributeNameMap(configMap);
    if (mapArray == null) {
        resultMap = attrMap;
    } else {
        resultMap = new CaseInsensitiveHashMap();
        Map reverseMap = mapArray[1];
        Iterator it = attrMap.keySet().iterator();
        while (it.hasNext()) {
            String curr = (String) it.next();
            if (reverseMap.containsKey(curr)) {
                resultMap.put((String) reverseMap.get(curr), attrMap.get(curr));
            } else {
                // if there wasn't an attribute mapped with the same name already
                if (!resultMap.containsKey(curr)) {
                    DEBUG.message("IdServicesImpl.reverseMapAttributeNames(): " + "adding unmapped attribute " + curr);
                    resultMap.put(curr, attrMap.get(curr));
                }
            }
        }
    }
    return resultMap;
}
Also used : Iterator(java.util.Iterator) Map(java.util.Map) AMHashMap(com.iplanet.am.sdk.AMHashMap) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

Example 43 with CaseInsensitiveHashMap

use of com.sun.identity.common.CaseInsensitiveHashMap in project OpenAM by OpenRock.

the class IdRepoJAXRPCObjectImpl method getAttributes2_idrepo.

public Map getAttributes2_idrepo(String token, String type, String name, String amOrgName, String amsdkDN) throws RemoteException, IdRepoException, SSOException {
    SSOToken ssoToken = getSSOToken(token);
    IdType idtype = IdUtils.getType(type);
    Map res = idServices.getAttributes(ssoToken, idtype, name, amOrgName, amsdkDN);
    if (res != null && res instanceof CaseInsensitiveHashMap) {
        Map res2 = new HashMap();
        Iterator it = res.keySet().iterator();
        while (it.hasNext()) {
            Object attr = it.next();
            Set set = (Set) res.get(attr);
            set = XMLUtils.encodeAttributeSet(set, idRepoDebug);
            res2.put(attr, set);
        }
        res = res2;
    }
    return res;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) HashSet(java.util.HashSet) NotificationSet(com.iplanet.services.comm.share.NotificationSet) Set(java.util.Set) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Iterator(java.util.Iterator) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) IdType(com.sun.identity.idm.IdType) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

Example 44 with CaseInsensitiveHashMap

use of com.sun.identity.common.CaseInsensitiveHashMap in project OpenAM by OpenRock.

the class OrgConfigViaAMSDK method setAttributes.

/**
     * Sets attributes to AMSDK Organization. The organziation attribute names
     * are defined in the IdRepo service.
     */
void setAttributes(Map attributes) throws SMSException {
    Map amsdkAttrs = null;
    // These attributes must be defined in ../idm/xml/idRepoService.xml
    if (attributes != null && !attributes.isEmpty()) {
        Map smsIdRepoAttrs = new CaseInsensitiveHashMap(attributes);
        // Iterate through the attribute mappings
        Map attrs = getAttributeMapping();
        Map existingAttributes = getAttributes();
        if (attrs != null && !attrs.isEmpty()) {
            for (Iterator items = attrs.keySet().iterator(); items.hasNext(); ) {
                String key = (String) items.next();
                Set value = (Set) smsIdRepoAttrs.get(key);
                if (value != null) {
                    if (amsdkAttrs == null) {
                        amsdkAttrs = new HashMap();
                    }
                    boolean notEmptyFlg = false;
                    if (!value.isEmpty()) {
                        for (Iterator iter = value.iterator(); iter.hasNext(); ) {
                            String val = (String) iter.next();
                            // Avoid empty string storage.
                            if (val.length() > 0) {
                                notEmptyFlg = true;
                            }
                        }
                        if (notEmptyFlg) {
                            amsdkAttrs.put(attrs.get(key), value);
                        }
                    } else {
                        Set existingValues = (Set) existingAttributes.get(key);
                        if (existingValues != null && !existingValues.isEmpty()) {
                            amsdkAttrs.put(attrs.get(key), value);
                        }
                    }
                }
            }
        }
    }
    // Update the organization entry
    if (amsdkAttrs != null) {
        try {
            parentOrg.setAttributes(amsdkAttrs);
            parentOrg.store();
        } catch (AMException ame) {
            if (debug.messageEnabled()) {
                debug.message("OrgConfigViaAMSDK::createSub" + "Organization: failed with AMException", ame);
            }
            throw (new SMSException(AMSDKBundle.BUNDLE_NAME, ame.getMessage(), ame, ame.getMessage()));
        } catch (SSOException ssoe) {
            throw (new SMSException(bundle.getString("sms-INVALID_SSO_TOKEN"), ssoe, "sms-INVALID_SSO_TOKEN"));
        }
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Iterator(java.util.Iterator) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

Example 45 with CaseInsensitiveHashMap

use of com.sun.identity.common.CaseInsensitiveHashMap in project OpenAM by OpenRock.

the class ServiceSchemaImpl method update.

// -----------------------------------------------------------
// Protected methods
// -----------------------------------------------------------
synchronized void update(Node sNode) {
    schemaNode = sNode;
    if (schemaNode == null) {
        if (debug.warningEnabled()) {
            debug.warning("ServiceSchemaImpl::update schema node is NULL");
        }
        name = "";
        i18nKey = null;
        i18nFileName = null;
        statusAttribute = null;
        serviceAttributes = new HashSet();
        searchableAttributeNames = new HashSet();
        attrSchemas = attrValidators = attrDefaults = new HashMap();
        subSchemas = new CaseInsensitiveHashMap();
        attrReadOnlyDefaults = Collections.unmodifiableMap(new HashMap());
    }
    // Get the name and i18nKey
    name = XMLUtils.getNodeAttributeValue(schemaNode, SMSUtils.NAME);
    i18nKey = XMLUtils.getNodeAttributeValue(schemaNode, SMSUtils.I18N_KEY);
    i18nFileName = XMLUtils.getNodeAttributeValue(schemaNode, SMSUtils.PROPERTIES_FILENAME);
    statusAttribute = XMLUtils.getNodeAttributeValue(schemaNode, SMSUtils.STATUS_ATTRIBUTE);
    inheritance = XMLUtils.getNodeAttributeValue(schemaNode, SMSUtils.INHERITANCE);
    validate = XMLUtils.getNodeAttributeValue(schemaNode, SMSUtils.VALIDATE);
    resourceName = XMLUtils.getNodeAttributeValue(schemaNode, SMSUtils.RESOURCE_NAME);
    hideConfigUI = XMLUtils.getNodeAttributeValue(schemaNode, SMSUtils.HIDE_CONFIG_UI);
    realmCloneable = XMLUtils.getNodeAttributeValue(schemaNode, SMSUtils.REALM_CLONEABLE);
    // Update sub-schema's, organization schema and attributes
    Set newServiceAttributes = new HashSet();
    Set newSearchableAttributeNames = new HashSet();
    Map<String, AttributeSchemaImpl> newAttrSchemas = new HashMap<String, AttributeSchemaImpl>();
    Map newAttrValidators = new HashMap();
    Map newAttrDefaults = new HashMap();
    Map newSubSchemas = new CaseInsensitiveHashMap();
    Map tempUnmodifiableDefaults = new HashMap();
    NodeList children = schemaNode.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node node = children.item(i);
        String name = XMLUtils.getNodeAttributeValue(node, SMSUtils.NAME);
        if (node.getNodeName().equals(SMSUtils.SCHEMA_ATTRIBUTE)) {
            AttributeSchemaImpl asi = null;
            if (attrSchemas != null) {
                asi = attrSchemas.get(name);
            }
            if (asi == null) {
                asi = new AttributeSchemaImpl(node);
            } else {
                // Get the instance of attribute schema and update it
                asi.update(node);
            }
            newAttrSchemas.put(name, asi);
            if (!asi.isStatusAttribute() && !asi.isServiceIdentifier()) {
                newServiceAttributes.add(name);
            }
            if (asi.isSearchable()) {
                newSearchableAttributeNames.add(name);
            }
            newAttrValidators.put(name, new AttributeValidator(asi));
            newAttrDefaults.put(name, asi.getDefaultValues());
            tempUnmodifiableDefaults.put(name, Collections.unmodifiableSet(asi.getDefaultValues()));
        } else if (node.getNodeName().equals(SMSUtils.SUB_SCHEMA)) {
            ServiceSchemaImpl ssi = null;
            if (subSchemas != null) {
                ssi = (ServiceSchemaImpl) subSchemas.get(name);
            }
            if (ssi == null) {
                newSubSchemas.put(name, new ServiceSchemaImpl(ssm, node));
            } else {
                ssi.update(node);
                newSubSchemas.put(name, ssi);
            }
        } else if (node.getNodeName().equals(SMSUtils.ORG_ATTRIBUTE_SCHEMA)) {
            orgAttrSchema = new ServiceSchemaImpl(ssm, node);
        }
    }
    serviceAttributes = newServiceAttributes;
    attrSchemas = newAttrSchemas;
    searchableAttributeNames = newSearchableAttributeNames;
    attrValidators = newAttrValidators;
    attrDefaults = newAttrDefaults;
    attrReadOnlyDefaults = Collections.unmodifiableMap(tempUnmodifiableDefaults);
    subSchemas = newSubSchemas;
    valid = true;
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet)

Aggregations

CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)52 HashMap (java.util.HashMap)40 Map (java.util.Map)38 Set (java.util.Set)35 HashSet (java.util.HashSet)34 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)23 Iterator (java.util.Iterator)22 AMHashMap (com.iplanet.am.sdk.AMHashMap)13 CollectionUtils.asSet (org.forgerock.openam.utils.CollectionUtils.asSet)8 LinkedHashSet (java.util.LinkedHashSet)6 SSOException (com.iplanet.sso.SSOException)5 AMIdentity (com.sun.identity.idm.AMIdentity)5 IdRepoUnsupportedOpException (com.sun.identity.idm.IdRepoUnsupportedOpException)5 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)5 IdRepoException (com.sun.identity.idm.IdRepoException)4 ByteString (org.forgerock.opendj.ldap.ByteString)4 SMSException (com.sun.identity.sm.SMSException)3 File (java.io.File)3 CollectionUtils.asOrderedSet (org.forgerock.openam.utils.CollectionUtils.asOrderedSet)3 Test (org.testng.annotations.Test)3