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