Search in sources :

Example 36 with CaseInsensitiveHashSet

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

the class OpenSSOSubjectAttributesCollector method getAvailableSubjectAttributeNames.

public Set<String> getAvailableSubjectAttributeNames() throws EntitlementException {
    CaseInsensitiveHashSet result = new CaseInsensitiveHashSet();
    try {
        ServiceConfig sc = idRepoServiceConfigManager.getOrganizationConfig(realm, null);
        if (sc != null) {
            Set<String> subConfigNames = sc.getSubConfigNames();
            if (subConfigNames != null) {
                for (String idRepoName : subConfigNames) {
                    ServiceConfig reposc = sc.getSubConfig(idRepoName);
                    Map<String, Set<String>> attrMap = reposc.getAttributesForRead();
                    Set<String> userAttrs = attrMap.get(LDAPv3Config_USER_ATTR);
                    if ((userAttrs != null) && !userAttrs.isEmpty()) {
                        result.addAll(userAttrs);
                    }
                }
            }
        }
        return result;
    } catch (SMSException e) {
        throw new EntitlementException(602, e);
    } catch (SSOException e) {
        throw new EntitlementException(602, e);
    }
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) EntitlementException(com.sun.identity.entitlement.EntitlementException) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) Set(java.util.Set) HashSet(java.util.HashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException)

Example 37 with CaseInsensitiveHashSet

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

the class ConfigureSocialAuthN method mergeAttributes.

/**
     * Carefully merge the values in two maps.  The existing ("base") attributes are added first, then values in
     * newAttrs.
     *
     * @param existingAttrs The "base" attributes.
     * @param newAttrs Coinciding attributes from here overwrite ones in existing attributes.
     * @return A map containing a combination of the two maps.
     */
Map<String, Set<String>> mergeAttributes(Map<String, Set<String>> existingAttrs, Map<String, Set<String>> newAttrs) {
    Map<String, Set<String>> mergedAttrs = new CaseInsensitiveHashMap(existingAttrs);
    for (Map.Entry<String, Set<String>> attr : newAttrs.entrySet()) {
        Set<String> values = attr.getValue();
        Set<String> existingValues = mergedAttrs.get(attr.getKey());
        if (existingValues == null) {
            existingValues = new CaseInsensitiveHashSet();
            mergedAttrs.put(attr.getKey(), existingValues);
        }
        existingValues.addAll(values);
    }
    return mergedAttrs;
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) Set(java.util.Set) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

Aggregations

CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)37 Set (java.util.Set)30 HashSet (java.util.HashSet)27 HashMap (java.util.HashMap)19 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)18 Map (java.util.Map)16 Iterator (java.util.Iterator)13 ByteString (org.forgerock.opendj.ldap.ByteString)9 SSOException (com.iplanet.sso.SSOException)6 IdRepoException (com.sun.identity.idm.IdRepoException)6 IdRepoUnsupportedOpException (com.sun.identity.idm.IdRepoUnsupportedOpException)6 SMSException (com.sun.identity.sm.SMSException)6 CollectionUtils.asSet (org.forgerock.openam.utils.CollectionUtils.asSet)6 LinkedHashSet (java.util.LinkedHashSet)5 CaseInsensitiveTreeSet (com.sun.identity.common.CaseInsensitiveTreeSet)4 PolicyException (com.sun.identity.policy.PolicyException)3 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)3 ServiceConfig (com.sun.identity.sm.ServiceConfig)3 ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)3 File (java.io.File)3