use of org.opends.server.protocols.ldap.LDAPAttribute in project OpenAM by OpenRock.
the class SMSEmbeddedLdapObject method copyModItemsToLDAPModList.
// Method to covert JNDI ModificationItems to LDAPModificationSet
private static List copyModItemsToLDAPModList(ModificationItem[] mods) throws SMSException {
if ((mods == null) || (mods.length == 0)) {
return null;
}
List<LDAPModification> modList = new ArrayList<>(mods.length);
try {
for (ModificationItem mod : mods) {
Attribute dAttr = mod.getAttribute();
String attrName = dAttr.getID();
List<String> values = new ArrayList<>();
for (NamingEnumeration ne = dAttr.getAll(); ne.hasMore(); ) {
values.add((String) ne.next());
}
ModificationType modType = null;
switch(mod.getModificationOp()) {
case DirContext.ADD_ATTRIBUTE:
modType = ModificationType.ADD;
break;
case DirContext.REPLACE_ATTRIBUTE:
modType = ModificationType.REPLACE;
break;
case DirContext.REMOVE_ATTRIBUTE:
modType = ModificationType.DELETE;
break;
}
if (modType != null) {
modList.add(new LDAPModification(modType, new LDAPAttribute(attrName, values)));
}
}
} catch (NamingException nne) {
throw (new SMSException(nne, "sms-cannot-copy-fromModItemToModSet"));
}
return (modList);
}
use of org.opends.server.protocols.ldap.LDAPAttribute in project OpenAM by OpenRock.
the class TokenDataEntry method getObjectClasses.
public List<LDAPAttribute> getObjectClasses() {
List<String> valueList = new ArrayList<String>();
valueList.add(Constants.TOP);
valueList.add(FR_OAUTH2TOKEN);
LDAPAttribute ldapAttr = new LDAPAttribute(Constants.OBJECTCLASS, valueList);
List<LDAPAttribute> objectClasses = new ArrayList<LDAPAttribute>();
objectClasses.add(ldapAttr);
return objectClasses;
}
use of org.opends.server.protocols.ldap.LDAPAttribute in project OpenAM by OpenRock.
the class SMSEmbeddedLdapObject method copyMapToAttrList.
// Method to convert Map to LDAPAttributeSet
private static List copyMapToAttrList(Map attrs) {
if ((attrs == null) || (attrs.isEmpty())) {
return null;
}
List<LDAPAttribute> attrList = new ArrayList<>(attrs.size());
for (Iterator iter = attrs.keySet().iterator(); iter.hasNext(); ) {
String attrName = (String) iter.next();
Set values = (Set) attrs.get(attrName);
if ((values != null) && (!values.isEmpty())) {
List valueList = new ArrayList();
valueList.addAll(values);
attrList.add(new LDAPAttribute(attrName, valueList));
}
}
return attrList;
}
use of org.opends.server.protocols.ldap.LDAPAttribute in project OpenAM by OpenRock.
the class TokenDataEntry method getAttrList.
public List<RawAttribute> getAttrList() {
List<RawAttribute> attrList = new ArrayList<RawAttribute>(attributeValues.size());
Map<String, Object> map = attributeValues.asMap();
for (String key : map.keySet()) {
List<String> valueList = new ArrayList<String>();
Object o = map.get(key);
if (o instanceof Collection) {
for (Object o2 : (Collection) o) {
if (o2 != null) {
valueList.add(o2.toString());
}
}
} else {
if (o != null) {
valueList.add(o.toString());
}
}
if (!valueList.isEmpty()) {
attrList.add(new LDAPAttribute(key, valueList));
}
}
return attrList;
}
Aggregations