James Moger
2012-08-01 d65fb8f1b77a7254c22edc9e7d8f47b29ec33072
src/com/gitblit/LdapUserService.java
@@ -27,6 +27,7 @@
import com.gitblit.models.TeamModel;
import com.gitblit.models.UserModel;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.StringUtils;
import com.unboundid.ldap.sdk.Attribute;
import com.unboundid.ldap.sdk.LDAPConnection;
@@ -140,17 +141,6 @@
      return !settings.getBoolean(Keys.realm.ldap.maintainTeams, false);
   }
   /**
    * Does the user service support cookie authentication?
    *
    * @return true or false
    */
   @Override
   public boolean supportsCookies() {
      // TODO cookies need to be reviewed
      return false;
   }
   @Override
   public UserModel authenticate(String username, char[] password) {
      String simpleUsername = getSimpleUsername(username);
@@ -173,8 +163,11 @@
               UserModel user = getUserModel(simpleUsername);
               if (user == null)   // create user object for new authenticated user
                  user = new UserModel(simpleUsername);
               // create a user cookie
               if (StringUtils.isEmpty(user.cookie) && !ArrayUtils.isEmpty(password)) {
                  user.cookie = StringUtils.getSHA1(user.username + new String(password));
               }
               
               if (!supportsTeamMembershipChanges())
                  getTeamsFromLdap(ldapConnection, simpleUsername, loggingInUser, user);
@@ -227,7 +220,10 @@
            user.displayName = displayName;
         } else {
            user.displayName = userEntry.getAttribute(displayName).getValue();
            Attribute attribute = userEntry.getAttribute(displayName);
            if (attribute != null && attribute.hasValue()) {
               user.displayName = attribute.getValue();
            }
         }
      }
      
@@ -240,7 +236,10 @@
            user.emailAddress = email;
         } else {
            user.emailAddress = userEntry.getAttribute(email).getValue();
            Attribute attribute = userEntry.getAttribute(email);
            if (attribute != null && attribute.hasValue()) {
               user.emailAddress = attribute.getValue();
            }
         }
      }
   }