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();
}
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);
}
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;
}
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());
}
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);
}
}
Aggregations