-
Improvement
-
Resolution: Fixed
-
Major
-
None
-
None
The LdapUsersManager is not enough flexible. It is difficult to add new attributes and return an extending class of User.
For example, into the getUser(login) and getUsers() method, the creation of a user isn't externalize. We have the same code in both methods which get the attributes and create the user :
// Récupérer le nom complet StringBuffer fullname = new StringBuffer(); if (_usersFirstnameAttribute != null) { fullname.append(attributes.get(_usersFirstnameAttribute) + " "); } fullname.append(attributes.get(_usersLastnameAttribute)); // Ajouter un nouveau principal à la liste principal = new User((String) attributes.get(_usersLoginAttribute), fullname.toString(), (String) attributes.get(_usersEmailAttribute));
It should be externalize in an overridable method like this :
protected User _createUser(Map<String, Object> attributes) { // Récupérer le nom complet StringBuffer fullname = new StringBuffer(); if (_usersFirstnameAttribute != null) { fullname.append(attributes.get(_usersFirstnameAttribute) + " "); } fullname.append(attributes.get(_usersLastnameAttribute)); // Ajouter un nouveau principal à la liste return new User((String) attributes.get(_usersLoginAttribute), fullname.toString(), (String) attributes.get(_usersEmailAttribute)); }