326 Set<String> readOnlyAttrNames = ldapQuery.getReturningReadOnlyLdapAttributes();
327 Set<String> lowerCasedAttrNames =
new TreeSet<>();
328 for (String attrName : ldapQuery.getReturningLdapAttributes()) {
329 lowerCasedAttrNames.add(attrName.toLowerCase());
333 String entryDN = searchResult.getNameInNamespace();
334 Attributes attributes = searchResult.getAttributes();
336 LDAPObject ldapObject =
new LDAPObject();
337 LDAPDn dn = LDAPDn.fromString(entryDN);
338 ldapObject.setDn(dn);
339 ldapObject.setRdnAttributeName(dn.getFirstRdnAttrName());
341 NamingEnumeration<? extends Attribute> ldapAttributes = attributes.getAll();
343 while (ldapAttributes.hasMore()) {
344 Attribute ldapAttribute = ldapAttributes.next();
348 }
catch (NoSuchElementException nsee) {
352 String ldapAttributeName = ldapAttribute.getID();
354 if (ldapAttributeName.equalsIgnoreCase(
getConfig().getUuidLDAPAttributeName())) {
355 Object uuidValue = ldapAttribute.get();
360 if (!ldapAttributeName.equalsIgnoreCase(
getConfig().getUuidLDAPAttributeName()) || (lowerCasedAttrNames.contains(ldapAttributeName.toLowerCase()))) {
361 Set<String> attrValues =
new LinkedHashSet<>();
362 NamingEnumeration<?> enumm = ldapAttribute.getAll();
363 while (enumm.hasMoreElements()) {
364 Object val = enumm.next();
366 if (val instanceof byte[]) {
367 String attrVal = Base64.encodeBytes((byte[]) val);
368 attrValues.add(attrVal);
370 String attrVal = val.toString().trim();
371 attrValues.add(attrVal);
375 if (ldapAttributeName.equalsIgnoreCase(LDAPConstants.OBJECT_CLASS)) {
376 ldapObject.setObjectClasses(attrValues);
378 ldapObject.setAttribute(ldapAttributeName, attrValues);
381 if (readOnlyAttrNames.contains(ldapAttributeName.toLowerCase())) {
382 ldapObject.addReadOnlyAttributeName(ldapAttributeName);
388 if (
logger.isTraceEnabled()) {
389 logger.tracef(
"Found ldap object and populated with the attributes. LDAP Object: %s", ldapObject.toString());
393 }
catch (Exception e) {
394 throw new ModelException(
"Could not populate attribute type " + searchResult.getNameInNamespace() +
".", e);
String decodeEntryUUID(final Object entryUUID)
Definition: LDAPOperationManager.java:634
static final Logger logger
Definition: LDAPIdentityStore.java:67
final LDAPOperationManager operationManager
Definition: LDAPIdentityStore.java:70
LDAPConfig getConfig()
Definition: LDAPIdentityStore.java:83