X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.util%2Fsrc%2Forg%2Fargeo%2Fosgi%2Fuseradmin%2FLdifGroup.java;h=bdf34aa91414ea77bcc7799bef02e7fa7a260011;hb=138e686fbf65683c3c94a52f1cfbaf8e02362e19;hp=b7167ea134684bacf63b25618446e8b198db27a5;hpb=ddc70245fe7413b7341205914c91015600726b4a;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.util/src/org/argeo/osgi/useradmin/LdifGroup.java b/org.argeo.util/src/org/argeo/osgi/useradmin/LdifGroup.java index b7167ea13..bdf34aa91 100644 --- a/org.argeo.util/src/org/argeo/osgi/useradmin/LdifGroup.java +++ b/org.argeo.util/src/org/argeo/osgi/useradmin/LdifGroup.java @@ -4,19 +4,18 @@ import java.util.ArrayList; import java.util.List; import javax.naming.InvalidNameException; -import javax.naming.NamingEnumeration; import javax.naming.directory.Attribute; -import javax.naming.directory.Attributes; import javax.naming.ldap.LdapName; +import org.argeo.util.directory.ldap.AbstractLdapDirectory; import org.osgi.service.useradmin.Role; /** Directory group implementation */ -abstract class LdifGroup extends LdifUser implements DirectoryGroup { +class LdifGroup extends LdifUser implements DirectoryGroup { private final String memberAttributeId; - LdifGroup(AbstractUserDirectory userAdmin, LdapName dn, Attributes attributes) { - super(userAdmin, dn, attributes); + LdifGroup(AbstractLdapDirectory userAdmin, LdapName dn) { + super(userAdmin, dn); memberAttributeId = userAdmin.getMemberAttributeId(); } @@ -70,10 +69,10 @@ abstract class LdifGroup extends LdifUser implements DirectoryGroup { @Override public Role[] getMembers() { List directMembers = new ArrayList(); - for (LdapName ldapName : getMemberNames()) { + for (LdapName ldapName : getReferences(memberAttributeId)) { Role role = findRole(ldapName); if (role == null) { - throw new UserDirectoryException("Role " + ldapName + " cannot be added."); + throw new IllegalStateException("Role " + ldapName + " not found."); } directMembers.add(role); } @@ -94,23 +93,23 @@ abstract class LdifGroup extends LdifUser implements DirectoryGroup { return role; } - @Override - public List getMemberNames() { - Attribute memberAttribute = getAttributes().get(memberAttributeId); - if (memberAttribute == null) - return new ArrayList(); - try { - List roles = new ArrayList(); - NamingEnumeration values = memberAttribute.getAll(); - while (values.hasMore()) { - LdapName dn = new LdapName(values.next().toString()); - roles.add(dn); - } - return roles; - } catch (Exception e) { - throw new UserDirectoryException("Cannot get members", e); - } - } +// @Override +// public List getMemberNames() { +// Attribute memberAttribute = getAttributes().get(memberAttributeId); +// if (memberAttribute == null) +// return new ArrayList(); +// try { +// List roles = new ArrayList(); +// NamingEnumeration values = memberAttribute.getAll(); +// while (values.hasMore()) { +// LdapName dn = new LdapName(values.next().toString()); +// roles.add(dn); +// } +// return roles; +// } catch (NamingException e) { +// throw new IllegalStateException("Cannot get members", e); +// } +// } @Override public Role[] getRequiredMembers() { @@ -122,30 +121,7 @@ abstract class LdifGroup extends LdifUser implements DirectoryGroup { return GROUP; } - /* - * KIND - */ - static class LdifFunctionalGroup extends LdifGroup implements FunctionalGroup { - - public LdifFunctionalGroup(AbstractUserDirectory userAdmin, LdapName dn, Attributes attributes) { - super(userAdmin, dn, attributes); - } - - } - - static class LdifOrganization extends LdifGroup implements Organization { - - public LdifOrganization(AbstractUserDirectory userAdmin, LdapName dn, Attributes attributes) { - super(userAdmin, dn, attributes); - } - - } - - static class LdifSystemPermissions extends LdifGroup implements SystemPermissions { - - public LdifSystemPermissions(AbstractUserDirectory userAdmin, LdapName dn, Attributes attributes) { - super(userAdmin, dn, attributes); - } - + protected DirectoryUserAdmin getUserAdmin() { + return (DirectoryUserAdmin) getDirectory(); } }