Search in sources :

Example 6 with CaseInsensitiveHashMap

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

the class OrgConfigViaAMSDK method clearCache.

/**
     * Clears the cache
     */
protected static void clearCache() {
    attributeMappings = new CaseInsensitiveHashMap();
    reverseAttributeMappings = new CaseInsensitiveHashMap();
    amsdkdn2realmname = new CaseInsensitiveHashMap();
    amsdkConfiguredRealms = new CaseInsensitiveHashMap();
}
Also used : CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

Example 7 with CaseInsensitiveHashMap

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

the class SMSEntry method setAttribute.

/**
     * Set the attribute values. <code>save()</code> must be called to make
     * the changes persistant
     */
public void setAttribute(String attrName, String[] attrValues) {
    // Attribute Values to be Set and BasicAttribute
    Set attrs = new HashSet();
    BasicAttribute ba = new BasicAttribute(attrName);
    for (int i = 0; attrValues != null && i < attrValues.length; i++) {
        attrs.add(attrValues[i]);
        ba.add(attrValues[i]);
    }
    // Check if attrSet, modSet is present, if not create
    attrSet = (attrSet == null) ? (new CaseInsensitiveHashMap()) : attrSet;
    modSet = (modSet == null) ? (new HashSet()) : modSet;
    // Check if the attribute exists, if not present add, else replace
    if (!attrSet.containsKey(attrName)) {
        // Not present: add it, update modset
        modSet.add(new ModificationItem(DirContext.ADD_ATTRIBUTE, ba));
    } else {
        // Remove old attrbute and add the new attribute, update modset
        modSet.add(new ModificationItem(DirContext.REPLACE_ATTRIBUTE, ba));
    }
    // Update attrset
    attrSet.put(attrName, attrs);
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) ModificationItem(javax.naming.directory.ModificationItem) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

Example 8 with CaseInsensitiveHashMap

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

the class SMSUtils method copyAttributes.

// Performs a deep copy of the Map
public static Map<String, Object> copyAttributes(Map<String, Object> attributes) {
    if (attributes == null) {
        return new HashMap<String, Object>();
    }
    Map<String, Object> answer = attributes instanceof CaseInsensitiveHashMap ? new CaseInsensitiveHashMap(attributes.size()) : new HashMap<String, Object>(attributes.size());
    if (attributes.isEmpty()) {
        return answer;
    }
    for (Map.Entry<String, Object> entry : attributes.entrySet()) {
        String attrName = entry.getKey();
        Object value = entry.getValue();
        if (value instanceof Set) {
            Set<String> set = (Set<String>) value;
            if (set.isEmpty()) {
                if (set == Collections.EMPTY_SET) {
                    answer.put(attrName, Collections.EMPTY_SET);
                } else {
                    answer.put(attrName, new HashSet<String>(0));
                }
            } else {
                // Copy the HashSet
                answer.put(attrName, new HashSet(set));
            }
        } else {
            answer.put(attrName, value);
        }
    }
    return answer;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) HashMap(java.util.HashMap) LDAPUtils.addAttributeToMapAsString(org.forgerock.openam.ldap.LDAPUtils.addAttributeToMapAsString) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) HashSet(java.util.HashSet)

Example 9 with CaseInsensitiveHashMap

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

the class FilesRepo method unassignService.

/*
     * (non-Javadoc)
     *
     * @see com.sun.identity.idm.IdRepo#unassignService(
     *      com.iplanet.sso.SSOToken, com.sun.identity.idm.IdType,
     *      java.lang.String, java.lang.String, java.util.Map)
     */
public void unassignService(SSOToken token, IdType type, String name, String serviceName, Map attrMap) throws IdRepoException, SSOException {
    if (debug.messageEnabled()) {
        debug.message("FilesRepo.unassignService called: " + name + "\n\t" + serviceName + "=" + attrMap);
    }
    if (initializationException != null) {
        debug.error("FilesRepo: throwing initialization exception");
        throw (initializationException);
    }
    // Need to selectively remove the objectclassess
    // First get the objectclasses
    Set set = new HashSet();
    set.add(OC);
    Map attrs = getAttributes(token, type, name, set);
    Set objectclasses = (Set) attrs.get(OC);
    CaseInsensitiveHashMap sAttrs = new CaseInsensitiveHashMap();
    sAttrs.putAll(attrMap);
    Set serviceOCs = (Set) sAttrs.remove(OC);
    if ((objectclasses != null) && !objectclasses.isEmpty() && (serviceOCs != null)) {
        objectclasses.removeAll(serviceOCs);
        setAttributes(token, type, name, attrs, false);
    }
    removeAttributes(token, type, name, sAttrs.keySet());
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

Example 10 with CaseInsensitiveHashMap

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

the class FilesRepo method assignService.

/*
     * (non-Javadoc)
     *
     * @see com.sun.identity.idm.IdRepo#assignService(com.iplanet.sso.SSOToken,
     *      com.sun.identity.idm.IdType, java.lang.String, java.lang.String,
     *      com.sun.identity.sm.SchemaType, java.util.Map)
     */
public void assignService(SSOToken token, IdType type, String name, String serviceName, SchemaType stype, Map attrMap) throws IdRepoException, SSOException {
    if (debug.messageEnabled()) {
        debug.message("Assign service called for: " + type.getName() + ":" + name + "\n\t" + serviceName + "=" + attrMap + "\n\tSchema=" + stype);
    }
    if (initializationException != null) {
        debug.error("FilesRepo: throwing initialization exception");
        throw (initializationException);
    }
    if (type.equals(IdType.USER) || type.equals(IdType.ROLE) || type.equals(IdType.REALM)) {
        // Update the objectclass and set attributes
        Set set = new HashSet();
        set.add(OC);
        Map attrs = getAttributes(token, type, name, set);
        Set objectclasses = (Set) attrs.get(OC);
        CaseInsensitiveHashMap sAttrs = new CaseInsensitiveHashMap();
        sAttrs.putAll(attrMap);
        Set serviceOcs = (Set) sAttrs.get(OC);
        if (objectclasses != null && !objectclasses.isEmpty() && serviceOcs != null) {
            // Update objectclasses
            serviceOcs.addAll(objectclasses);
        }
        setAttributes(token, type, name, attrMap, false);
    } else {
        Object[] args = { NAME, IdOperation.SERVICE.getName() };
        throw new IdRepoUnsupportedOpException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.PLUGIN_OPERATION_NOT_SUPPORTED, args);
    }
}
Also used : IdRepoUnsupportedOpException(com.sun.identity.idm.IdRepoUnsupportedOpException) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

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