Uploaded image for project: 'Runtime'
  1. Runtime
  2. RUNTIME-602

LdapUsersManager not enough flexible (as JdbcUsersManager)

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 2.2.1
    • None
    • Plugin core
    • 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));
      }

            laurence Laurence Aumeunier
            bmaurel Bérénice Maurel
            Votes:
            2 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: