@Override
public void init() {
- ldapConnection = new LdapConnection(getDirectory().getUri().toString(), getDirectory().getProperties());
+ ldapConnection = new LdapConnection(getDirectory().getUri().toString(), getDirectory().cloneConfigProperties());
}
public void destroy() {
// }
@Override
- public Boolean daoHasEntry(LdapName dn) {
+ public Boolean entryExists(LdapName dn) {
try {
- return daoGetEntry(dn) != null;
+ return doGetEntry(dn) != null;
} catch (NameNotFoundException e) {
return false;
}
}
@Override
- public LdapEntry daoGetEntry(LdapName name) throws NameNotFoundException {
+ public LdapEntry doGetEntry(LdapName name) throws NameNotFoundException {
try {
Attributes attrs = ldapConnection.getAttributes(name);
if (attrs.size() == 0)
return null;
// int roleType = roleType(name);
LdapEntry res;
- if (isGroup(name))
+ Rdn technicalRdn = LdapNameUtils.getParentRdn(name);
+ if (getDirectory().getGroupBaseRdn().equals(technicalRdn))
res = newGroup(name, attrs);
- else
+ else if (getDirectory().getSystemRoleBaseRdn().equals(technicalRdn))
+ res = newGroup(name, attrs);
+ else if (getDirectory().getUserBaseRdn().equals(technicalRdn))
res = newUser(name, attrs);
+ else
+ res = new DefaultLdapEntry(getDirectory(), name, attrs);
+// if (isGroup(name))
+// res = newGroup(name, attrs);
+// else
+// res = newUser(name, attrs);
// else
// throw new IllegalArgumentException("Unsupported LDAP type for " + name);
return res;
}
}
- protected boolean isGroup(LdapName dn) {
- Rdn technicalRdn = LdapNameUtils.getParentRdn(dn);
- if (getDirectory().getGroupBaseRdn().equals(technicalRdn)
- || getDirectory().getSystemRoleBaseRdn().equals(technicalRdn))
- return true;
- else if (getDirectory().getUserBaseRdn().equals(technicalRdn))
- return false;
- else
- throw new IllegalArgumentException(
- "Cannot dind role type, " + technicalRdn + " is not a technical RDN for " + dn);
- }
+// protected boolean isGroup(LdapName dn) {
+// Rdn technicalRdn = LdapNameUtils.getParentRdn(dn);
+// if (getDirectory().getGroupBaseRdn().equals(technicalRdn)
+// || getDirectory().getSystemRoleBaseRdn().equals(technicalRdn))
+// return true;
+// else if (getDirectory().getUserBaseRdn().equals(technicalRdn))
+// return false;
+// else
+// throw new IllegalArgumentException(
+// "Cannot find role type, " + technicalRdn + " is not a technical RDN for " + dn);
+// }
@Override
public List<LdapEntry> doGetEntries(LdapName searchBase, String f, boolean deep) {
try {
String searchFilter = "(|(" + objectClass + "=" + LdapObjs.organizationalUnit.name() + ")(" + objectClass
+ "=" + LdapObjs.organization.name() + "))";
+// String searchFilter = "(|(" + objectClass + "=" + LdapObjs.organizationalUnit.name() + ")(" + objectClass
+// + "=" + LdapObjs.organization.name() + ")(cn=accounts)(cn=users)(cn=groups))";
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
@Override
public HierarchyUnit doGetHierarchyUnit(LdapName dn) {
try {
+ if (getDirectory().getBaseDn().equals(dn))
+ return getDirectory();
+ if (!dn.startsWith(getDirectory().getBaseDn()))
+ throw new IllegalArgumentException(dn + " does not start with base DN " + getDirectory().getBaseDn());
Attributes attrs = ldapConnection.getAttributes(dn);
return new LdapHierarchyUnit(getDirectory(), dn, attrs);
} catch (NamingException e) {