Remove dependency to OSGi user admin from API
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / directory / ldap / DefaultLdapEntry.java
index 94ff20b03a185caa6ce5dcf111946d139cb8f94f..f919fa6c843050d7a8564d133e91c3e91173c7db 100644 (file)
@@ -22,6 +22,7 @@ import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
 import javax.naming.ldap.LdapName;
 
+import org.argeo.api.acr.QNamed;
 import org.argeo.api.acr.ldap.LdapAttr;
 import org.argeo.api.acr.ldap.LdapObj;
 import org.argeo.api.cms.directory.DirectoryDigestUtils;
@@ -74,7 +75,8 @@ public class DefaultLdapEntry implements LdapEntry {
 
        @Override
        public LdapName getDn() {
-               return dn;
+               // always return a copy since LdapName is mutable
+               return (LdapName) dn.clone();
        }
 
        public synchronized Attributes getAttributes() {
@@ -124,9 +126,9 @@ public class DefaultLdapEntry implements LdapEntry {
                // modifiedAttributes = (Attributes) publishedAttributes.clone();
        }
 
-       public synchronized void publishAttributes(Attributes modifiedAttributes) {
-//             publishedAttributes = modifiedAttributes;
-       }
+//     public synchronized void publishAttributes(Attributes modifiedAttributes) {
+////           publishedAttributes = modifiedAttributes;
+//     }
 
        /*
         * PROPERTIES
@@ -144,6 +146,17 @@ public class DefaultLdapEntry implements LdapEntry {
                return credentials;
        }
 
+       protected String getPropertyAsString(QNamed key) {
+               return getPropertyAsString(key.localName());
+       }
+
+       protected String getPropertyAsString(String key) {
+               Object res = getProperties().get(key);
+               if (res == null)
+                       return null;
+               return res.toString();
+       }
+
        /*
         * CREDENTIALS
         */