Multiple user referentials working with IPA.
[lgpl/argeo-commons.git] / org.argeo.util / src / org / argeo / osgi / useradmin / OsUserDirectory.java
index 1adc7e0dfe6f1806b0b7186a8a5ef2d75e6aa5f7..5d7e97ddeea487975ebd64609f63167a0720656d 100644 (file)
@@ -6,7 +6,6 @@ import java.util.List;
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttributes;
 import javax.naming.ldap.LdapName;
 
 import org.argeo.util.directory.HierarchyUnit;
@@ -27,9 +26,9 @@ public class OsUserDirectory extends AbstractLdapDirectoryDao {
                try {
                        osUserDn = new LdapName(LdapAttrs.uid.name() + "=" + osUsername + "," + directory.getUserBaseRdn() + ","
                                        + directory.getBaseDn());
-                       Attributes attributes = new BasicAttributes();
-                       attributes.put(LdapAttrs.uid.name(), osUsername);
-                       osUser = newUser(osUserDn, attributes);
+//                     Attributes attributes = new BasicAttributes();
+//                     attributes.put(LdapAttrs.uid.name(), osUsername);
+                       osUser = newUser(osUserDn);
                } catch (NamingException e) {
                        throw new IllegalStateException("Cannot create system user", e);
                }
@@ -41,12 +40,17 @@ public class OsUserDirectory extends AbstractLdapDirectoryDao {
        }
 
        @Override
-       public Boolean daoHasEntry(LdapName dn) {
+       public boolean entryExists(LdapName dn) {
                return osUserDn.equals(dn);
        }
 
        @Override
-       public LdapEntry daoGetEntry(LdapName key) throws NameNotFoundException {
+       public boolean checkConnection() {
+               return true;
+       }
+
+       @Override
+       public LdapEntry doGetEntry(LdapName key) throws NameNotFoundException {
                if (osUserDn.equals(key))
                        return osUser;
                else
@@ -86,14 +90,22 @@ public class OsUserDirectory extends AbstractLdapDirectoryDao {
        @Override
        public void init() {
                // TODO Auto-generated method stub
-               
+
        }
 
        @Override
        public void destroy() {
                // TODO Auto-generated method stub
-               
+
+       }
+
+       @Override
+       public Attributes doGetAttributes(LdapName name) {
+               try {
+                       return doGetEntry(name).getAttributes();
+               } catch (NameNotFoundException e) {
+                       throw new IllegalStateException(name + " doe not exist in " + getDirectory().getBaseDn(), e);
+               }
        }
 
-       
 }