\r
**%VERSION%** ([go](http://code.google.com/p/gitblit/downloads/detail?name=%GO%) | [war](http://code.google.com/p/gitblit/downloads/detail?name=%WAR%) | [express](http://code.google.com/p/gitblit/downloads/detail?name=%EXPRESS%) | [fedclient](http://code.google.com/p/gitblit/downloads/detail?name=%FEDCLIENT%) | [manager](http://code.google.com/p/gitblit/downloads/detail?name=%MANAGER%) | [api](http://code.google.com/p/gitblit/downloads/detail?name=%API%)) based on [%JGIT%][jgit] *released %BUILDDATE%*\r
\r
+#### fixes \r
+- Fixed username case-sensitivity issues (issue 43)\r
+\r
+**0.8.2** ([go](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.8.2.zip) | [war](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.8.2.war) | [express](http://code.google.com/p/gitblit/downloads/detail?name=express-0.8.2.zip) | [fedclient](http://code.google.com/p/gitblit/downloads/detail?name=fedclient-0.8.2.zip) | [manager](http://code.google.com/p/gitblit/downloads/detail?name=manager-0.8.2.zip) | [api](http://code.google.com/p/gitblit/downloads/detail?name=gbapi-0.8.2.zip)) based on [JGit 1.2.0 (201112221803-r)][jgit] *released 2012-01-13*\r
+\r
#### fixes\r
\r
- Fixed bug when upgrading from users.properties to users.conf (issue 41)\r
config.load();\r
Set<String> usernames = config.getSubsections(USER);\r
for (String username : usernames) {\r
- UserModel user = new UserModel(username);\r
+ UserModel user = new UserModel(username.toLowerCase());\r
user.password = config.getString(USER, username, PASSWORD);\r
\r
// user roles\r
}\r
\r
// update cache\r
- users.put(username, user);\r
- cookies.put(StringUtils.getSHA1(username + user.password), user);\r
+ users.put(user.username, user);\r
+ cookies.put(StringUtils.getSHA1(user.username + user.password), user);\r
}\r
\r
// load the teams\r
@Override\r
public UserModel getUserModel(String username) {\r
Properties allUsers = read();\r
- String userInfo = allUsers.getProperty(username);\r
+ String userInfo = allUsers.getProperty(username.toLowerCase());\r
if (userInfo == null) {\r
return null;\r
}\r
- UserModel model = new UserModel(username);\r
+ UserModel model = new UserModel(username.toLowerCase());\r
String[] userValues = userInfo.split(",");\r
model.password = userValues[0];\r
for (int i = 1; i < userValues.length; i++) {\r
*/\r
@Override\r
public boolean updateUserModel(String username, UserModel model) {\r
- try {\r
+ try { \r
Properties allUsers = read();\r
UserModel oldUser = getUserModel(username);\r
ArrayList<String> roles = new ArrayList<String>(model.repositories);\r
}\r
// trim trailing comma\r
sb.setLength(sb.length() - 1);\r
- allUsers.remove(username);\r
- allUsers.put(model.username, sb.toString());\r
+ allUsers.remove(username.toLowerCase());\r
+ allUsers.put(model.username.toLowerCase(), sb.toString());\r
\r
// null check on "final" teams because JSON-sourced UserModel\r
// can have a null teams object\r
} else {\r
// user definition\r
String password = roles[0];\r
- cookies.put(StringUtils.getSHA1(username + password), username);\r
+ cookies.put(StringUtils.getSHA1(username.toLowerCase() + password), username.toLowerCase());\r
}\r
}\r
}\r
private JCheckBox notFederatedCheckbox;\r
\r
private JPalette<String> repositoryPalette;\r
- \r
+\r
private JPalette<TeamModel> teamsPalette;\r
\r
private Set<String> usernames;\r
final Insets _insets = new Insets(5, 5, 5, 5);\r
repositoryPalette = new JPalette<String>();\r
teamsPalette = new JPalette<TeamModel>();\r
- \r
+\r
JPanel fieldsPanelTop = new JPanel(new BorderLayout());\r
fieldsPanelTop.add(fieldsPanel, BorderLayout.NORTH);\r
- \r
+\r
JPanel repositoriesPanel = new JPanel(new BorderLayout()) {\r
\r
private static final long serialVersionUID = 1L;\r
}\r
panel.addTab(Translation.get("gb.restrictedRepositories"), repositoriesPanel);\r
\r
-\r
JButton createButton = new JButton(Translation.get("gb.save"));\r
createButton.addActionListener(new ActionListener() {\r
public void actionPerformed(ActionEvent event) {\r
JPanel controls = new JPanel();\r
controls.add(cancelButton);\r
controls.add(createButton);\r
- \r
+\r
JPanel centerPanel = new JPanel(new BorderLayout(5, 5)) {\r
\r
private static final long serialVersionUID = 1L;\r
}\r
\r
private boolean validateFields() {\r
- String uname = usernameField.getText();\r
- if (StringUtils.isEmpty(uname)) {\r
+ if (StringUtils.isEmpty(usernameField.getText())) {\r
error("Please enter a username!");\r
return false;\r
}\r
-\r
+ String uname = usernameField.getText().toLowerCase();\r
boolean rename = false;\r
// verify username uniqueness on create\r
if (isCreate) {\r
- if (usernames.contains(uname.toLowerCase())) {\r
+ if (usernames.contains(uname)) {\r
error(MessageFormat.format("Username ''{0}'' is unavailable.", uname));\r
return false;\r
}\r
// check rename collision\r
rename = !StringUtils.isEmpty(username) && !username.equalsIgnoreCase(uname);\r
if (rename) {\r
- if (usernames.contains(uname.toLowerCase())) {\r
+ if (usernames.contains(uname)) {\r
error(MessageFormat.format(\r
"Failed to rename ''{0}'' because ''{1}'' already exists.", username,\r
uname));\r
} else if (type.equalsIgnoreCase("combined-md5")) {\r
// store MD5 digest of username+password\r
user.password = StringUtils.COMBINED_MD5_TYPE\r
- + StringUtils.getMD5(username.toLowerCase() + password);\r
+ + StringUtils.getMD5(user.username + password);\r
} else {\r
// plain-text password\r
user.password = password;\r
\r
user.repositories.clear();\r
user.repositories.addAll(repositoryPalette.getSelections());\r
- \r
+\r
user.teams.clear();\r
user.teams.addAll(teamsPalette.getSelections());\r
return true;\r
}\r
repositoryPalette.setObjects(restricted, selected);\r
}\r
- \r
+\r
public void setTeams(List<TeamModel> teams, List<TeamModel> selected) {\r
Collections.sort(teams);\r
if (selected != null) {\r
*/\r
@Override\r
protected void onSubmit() {\r
- String username = userModel.username;\r
- if (StringUtils.isEmpty(username)) {\r
+ if (StringUtils.isEmpty(userModel.username)) {\r
error("Please enter a username!");\r
return;\r
}\r
+ // force username to lower-case\r
+ userModel.username = userModel.username.toLowerCase();\r
+ String username = userModel.username;\r
if (isCreate) {\r
UserModel model = GitBlit.self().getUserModel(username);\r
if (model != null) {\r
} else if (type.equalsIgnoreCase("combined-md5")) {\r
// store MD5 digest of username+password\r
userModel.password = StringUtils.COMBINED_MD5_TYPE\r
- + StringUtils.getMD5(username.toLowerCase() + userModel.password);\r
+ + StringUtils.getMD5(username + userModel.password);\r
}\r
} else if (rename\r
&& password.toUpperCase().startsWith(StringUtils.COMBINED_MD5_TYPE)) {\r
userModel.teams.add(team);\r
}\r
\r
- try {\r
+ try { \r
GitBlit.self().updateUserModel(oldName, userModel, isCreate);\r
} catch (GitBlitException e) {\r
error(e.getMessage());\r
service.updateUserModel(newUser);\r
\r
// add one more new user and then test reload of first new user\r
- newUser = new UserModel("garbage");\r
+ newUser = new UserModel("GARBAGE");\r
newUser.password = "garbage";\r
service.updateUserModel(newUser);\r
\r
// confirm all added users\r
assertEquals(3, service.getAllUsernames().size());\r
+ assertTrue(service.getUserModel("garbage") != null);\r
+ assertTrue(service.getUserModel("GaRbAgE") != null);\r
+ assertTrue(service.getUserModel("GARBAGE") != null);\r
\r
// confirm reloaded test user\r
newUser = service.getUserModel("test");\r