]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.util/src/org/argeo/util/directory/ldap/DefaultLdapEntry.java
Fix various issues on a fresh dev environment deployment
[lgpl/argeo-commons.git] / org.argeo.util / src / org / argeo / util / directory / ldap / DefaultLdapEntry.java
index 8eff6690003c014a70b947fb1d19b8e42b71ca53..7166710f61191e594dd776714d6b7bd56f73d459 100644 (file)
@@ -25,7 +25,6 @@ import javax.naming.ldap.LdapName;
 import org.argeo.util.directory.DirectoryDigestUtils;
 import org.argeo.util.naming.LdapAttrs;
 import org.argeo.util.naming.LdapObjs;
-import org.argeo.util.naming.SharedSecret;
 
 /** An entry in an LDAP (or LDIF) directory. */
 public class DefaultLdapEntry implements LdapEntry {
@@ -36,8 +35,8 @@ public class DefaultLdapEntry implements LdapEntry {
        private Attributes publishedAttributes;
 
        // Temporarily expose the fields
-       protected final AttributeDictionary properties;
-       protected final AttributeDictionary credentials;
+       protected AttributeDictionary properties;
+       protected AttributeDictionary credentials;
 
        protected DefaultLdapEntry(AbstractLdapDirectory directory, LdapName dn, Attributes attributes) {
                Objects.requireNonNull(directory);
@@ -45,8 +44,8 @@ public class DefaultLdapEntry implements LdapEntry {
                this.directory = directory;
                this.dn = dn;
                this.publishedAttributes = attributes;
-               properties = new AttributeDictionary(false);
-               credentials = new AttributeDictionary(true);
+//             properties = new AttributeDictionary(false);
+//             credentials = new AttributeDictionary(true);
        }
 
        @Override
@@ -55,6 +54,9 @@ public class DefaultLdapEntry implements LdapEntry {
        }
 
        public synchronized Attributes getAttributes() {
+               // lazy loading
+               if (publishedAttributes == null)
+                       publishedAttributes = getDirectory().getDirectoryDao().doGetAttributes(dn);
                return isEditing() ? getModifiedAttributes() : publishedAttributes;
        }
 
@@ -104,15 +106,23 @@ public class DefaultLdapEntry implements LdapEntry {
        public synchronized void publishAttributes(Attributes modifiedAttributes) {
                publishedAttributes = modifiedAttributes;
        }
-       
+
        /*
         * PROPERTIES
         */
        @Override
        public Dictionary<String, Object> getProperties() {
+               if (properties == null)
+                       properties = new AttributeDictionary(false);
                return properties;
        }
 
+       public Dictionary<String, Object> getCredentials() {
+               if (credentials == null)
+                       credentials = new AttributeDictionary(false);
+               return credentials;
+       }
+
        /*
         * CREDENTIALS
         */
@@ -154,7 +164,7 @@ public class DefaultLdapEntry implements LdapEntry {
                        return false;
                }
 
-               Object storedValue = credentials.get(key);
+               Object storedValue = getCredentials().get(key);
                if (storedValue == null || value == null)
                        return false;
                if (!(value instanceof String || value instanceof byte[]))