From 3517a7a6d44673e7944808ce464bcf1b037cd471 Mon Sep 17 00:00:00 2001 From: James Moger Date: Mon, 23 Sep 2013 11:36:27 -0400 Subject: [PATCH] Synchronize critical ConfigUserService methods --- .../java/com/gitblit/ConfigUserService.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gitblit/ConfigUserService.java b/src/main/java/com/gitblit/ConfigUserService.java index a9217b5c..44687b49 100644 --- a/src/main/java/com/gitblit/ConfigUserService.java +++ b/src/main/java/com/gitblit/ConfigUserService.java @@ -200,7 +200,7 @@ public class ConfigUserService implements IUserService { * @return a user object or null */ @Override - public UserModel authenticate(char[] cookie) { + public synchronized UserModel authenticate(char[] cookie) { String hash = new String(cookie); if (StringUtils.isEmpty(hash)) { return null; @@ -269,7 +269,7 @@ public class ConfigUserService implements IUserService { * @return a user object or null */ @Override - public UserModel getUserModel(String username) { + public synchronized UserModel getUserModel(String username) { read(); UserModel model = users.get(username.toLowerCase()); if (model != null) { @@ -299,7 +299,7 @@ public class ConfigUserService implements IUserService { * @since 1.2.0 */ @Override - public boolean updateUserModels(Collection models) { + public synchronized boolean updateUserModels(Collection models) { try { read(); for (UserModel model : models) { @@ -351,7 +351,7 @@ public class ConfigUserService implements IUserService { * @return true if update is successful */ @Override - public boolean updateUserModel(String username, UserModel model) { + public synchronized boolean updateUserModel(String username, UserModel model) { UserModel originalUser = null; try { read(); @@ -417,7 +417,7 @@ public class ConfigUserService implements IUserService { * @return true if successful */ @Override - public boolean deleteUser(String username) { + public synchronized boolean deleteUser(String username) { try { // Read realm file read(); @@ -467,7 +467,7 @@ public class ConfigUserService implements IUserService { * @since 0.8.0 */ @Override - public List getAllTeams() { + public synchronized List getAllTeams() { read(); List list = new ArrayList(teams.values()); list = DeepCopier.copy(list); @@ -484,7 +484,7 @@ public class ConfigUserService implements IUserService { * @return list of all usernames that can bypass the access restriction */ @Override - public List getTeamnamesForRepositoryRole(String role) { + public synchronized List getTeamnamesForRepositoryRole(String role) { List list = new ArrayList(); try { read(); @@ -511,7 +511,7 @@ public class ConfigUserService implements IUserService { * @return true if successful */ @Override - public boolean setTeamnamesForRepositoryRole(String role, List teamnames) { + public synchronized boolean setTeamnamesForRepositoryRole(String role, List teamnames) { try { Set specifiedTeams = new HashSet(); for (String teamname : teamnames) { @@ -548,7 +548,7 @@ public class ConfigUserService implements IUserService { * @since 0.8.0 */ @Override - public TeamModel getTeamModel(String teamname) { + public synchronized TeamModel getTeamModel(String teamname) { read(); TeamModel model = teams.get(teamname.toLowerCase()); if (model != null) { @@ -678,7 +678,7 @@ public class ConfigUserService implements IUserService { * @return list of all usernames */ @Override - public List getAllUsers() { + public synchronized List getAllUsers() { read(); List list = new ArrayList(users.values()); list = DeepCopier.copy(list); @@ -695,7 +695,7 @@ public class ConfigUserService implements IUserService { * @return list of all usernames that can bypass the access restriction */ @Override - public List getUsernamesForRepositoryRole(String role) { + public synchronized List getUsernamesForRepositoryRole(String role) { List list = new ArrayList(); try { read(); @@ -723,7 +723,7 @@ public class ConfigUserService implements IUserService { */ @Override @Deprecated - public boolean setUsernamesForRepositoryRole(String role, List usernames) { + public synchronized boolean setUsernamesForRepositoryRole(String role, List usernames) { try { Set specifiedUsers = new HashSet(); for (String username : usernames) { @@ -760,7 +760,7 @@ public class ConfigUserService implements IUserService { * @return true if successful */ @Override - public boolean renameRepositoryRole(String oldRole, String newRole) { + public synchronized boolean renameRepositoryRole(String oldRole, String newRole) { try { read(); // identify users which require role rename @@ -795,7 +795,7 @@ public class ConfigUserService implements IUserService { * @return true if successful */ @Override - public boolean deleteRepositoryRole(String role) { + public synchronized boolean deleteRepositoryRole(String role) { try { read(); -- 2.39.5