X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.util%2Fsrc%2Forg%2Fargeo%2Futil%2Fdirectory%2Fldap%2FDefaultLdapEntry.java;h=7166710f61191e594dd776714d6b7bd56f73d459;hb=36c0ba6709ae9a3974c1d1dce01ebe47c5aec24e;hp=8eff6690003c014a70b947fb1d19b8e42b71ca53;hpb=0ce8ecfe974cec9f524c16884209cd08544d890d;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.util/src/org/argeo/util/directory/ldap/DefaultLdapEntry.java b/org.argeo.util/src/org/argeo/util/directory/ldap/DefaultLdapEntry.java index 8eff66900..7166710f6 100644 --- a/org.argeo.util/src/org/argeo/util/directory/ldap/DefaultLdapEntry.java +++ b/org.argeo.util/src/org/argeo/util/directory/ldap/DefaultLdapEntry.java @@ -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 getProperties() { + if (properties == null) + properties = new AttributeDictionary(false); return properties; } + public Dictionary 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[]))