GUACAMOLE-1239: JDBC module should pull case-sensitivity from authentcated user when possible.

This commit is contained in:
Virtually Nick
2024-10-27 22:29:12 -04:00
parent d3da20ff54
commit 240dcd9a52
5 changed files with 14 additions and 20 deletions

View File

@@ -494,7 +494,7 @@ public class ConnectionService extends ModeledChildDirectoryObjectService<Modele
if (user.isPrivileged() || user.getUser().getEffectivePermissions().getSystemPermissions().hasPermission(SystemPermission.Type.AUDIT))
searchResults = connectionRecordMapper.search(identifier,
recordIdentifier, requiredContents, sortPredicates, limit,
environment.getCaseSensitiveUsernames());
user.isCaseSensitive());
// Otherwise only return explicitly readable history records
else
@@ -502,7 +502,7 @@ public class ConnectionService extends ModeledChildDirectoryObjectService<Modele
user.getUser().getModel(), recordIdentifier,
requiredContents, sortPredicates, limit,
user.getEffectiveUserGroups(),
environment.getCaseSensitiveUsernames());
user.isCaseSensitive());
return getObjectInstances(searchResults);

View File

@@ -479,7 +479,7 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
try {
// This MUST happen before getUUID() is invoked, to ensure the ID driving the UUID exists
connectionRecordMapper.insert(activeConnection.getModel(),
environment.getCaseSensitiveUsernames());
activeConnection.getUser().isCaseSensitive());
activeTunnels.put(activeConnection.getUUID().toString(), activeConnection);
}

View File

@@ -194,7 +194,7 @@ public class ModeledUserContext extends RestrictedObject
userRecord.setRemoteHost(getCurrentUser().getCredentials().getRemoteAddress());
// Insert record representing login
userRecordMapper.insert(userRecord, environment.getCaseSensitiveUsernames());
userRecordMapper.insert(userRecord, getCurrentUser().isCaseSensitive());
}

View File

@@ -254,7 +254,7 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
// Do not create duplicate users
Collection<UserModel> existing = userMapper.select(Collections.singleton(
model.getIdentifier()), environment.getCaseSensitiveUsernames());
model.getIdentifier()), user.isCaseSensitive());
if (!existing.isEmpty())
throw new GuacamoleClientException("User \"" + model.getIdentifier() + "\" already exists.");
@@ -291,7 +291,7 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
// Check whether such a user is already present
UserModel existing = userMapper.selectOne(model.getIdentifier(),
environment.getCaseSensitiveUsernames());
user.isCaseSensitive());
if (existing != null) {
// Do not rename to existing user
@@ -359,7 +359,7 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
beforeDelete(user, identifier);
// Delete object
userMapper.delete(identifier, environment.getCaseSensitiveUsernames());
userMapper.delete(identifier, user.isCaseSensitive());
}
@@ -401,7 +401,7 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
// Retrieve corresponding user model, if such a user exists
UserModel userModel = userMapper.selectOne(username,
environment.getCaseSensitiveUsernames());
getCaseSensitiveIdentifiers());
if (userModel == null)
return null;
@@ -443,7 +443,7 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
// Retrieve corresponding user model, if such a user exists
UserModel userModel = userMapper.selectOne(authenticatedUser.getIdentifier(),
environment.getCaseSensitiveUsernames());
authenticatedUser.isCaseSensitive());
if (userModel == null)
return null;
@@ -642,7 +642,7 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
if (user.isPrivileged() || user.getUser().getEffectivePermissions().getSystemPermissions().hasPermission(SystemPermission.Type.AUDIT))
searchResults = userRecordMapper.search(username, recordIdentifier,
requiredContents, sortPredicates, limit,
environment.getCaseSensitiveUsernames());
user.isCaseSensitive());
// Otherwise only return explicitly readable history records
else
@@ -650,7 +650,7 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
user.getUser().getModel(), recordIdentifier,
requiredContents, sortPredicates, limit,
user.getEffectiveUserGroups(),
environment.getCaseSensitiveUsernames());
user.isCaseSensitive());
return getObjectInstances(searchResults);

View File

@@ -38,15 +38,9 @@ public class UserGroupMemberUserSet extends RelatedObjectSet<ModeledUserGroup, U
@Inject
private UserGroupMemberUserMapper userGroupMemberUserMapper;
/**
* The server environment for retrieving configuration information.
*/
@Inject
private JDBCEnvironment environment;
@Override
protected boolean getCaseSensitiveIdentifiers() throws GuacamoleException {
return environment.getCaseSensitiveUsernames();
return getCurrentUser().isCaseSensitive();
}
@Override