1 package org
.argeo
.util
.directory
.ldap
;
3 import java
.util
.Arrays
;
4 import java
.util
.Collection
;
5 import java
.util
.Dictionary
;
8 import java
.util
.StringJoiner
;
9 import java
.util
.TreeSet
;
11 import javax
.naming
.directory
.Attributes
;
12 import javax
.naming
.ldap
.LdapName
;
14 import org
.argeo
.util
.naming
.LdapAttrs
;
17 public interface LdapEntry
{
20 Attributes
getAttributes();
22 void publishAttributes(Attributes modifiedAttributes
);
24 List
<LdapName
> getReferences(String attributeId
);
26 Dictionary
<String
, Object
> getProperties();
28 boolean hasCredential(String key
, Object value
);
34 * Convert a collection of object classes to the format expected by an LDAP
37 public static void addObjectClasses(Dictionary
<String
, Object
> properties
, Collection
<String
> objectClasses
) {
38 String value
= properties
.get(LdapAttrs
.objectClasses
.name()).toString();
39 Set
<String
> currentObjectClasses
= new TreeSet
<>(Arrays
.asList(value
.toString().split("\n")));
40 currentObjectClasses
.addAll(objectClasses
);
41 StringJoiner values
= new StringJoiner("\n");
42 currentObjectClasses
.forEach((s
) -> values
.add(s
));
43 properties
.put(LdapAttrs
.objectClasses
.name(), values
.toString());