mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-1239: Make identifier comparison case-insensitive.
This commit is contained in:
@@ -271,5 +271,18 @@ public abstract class JDBCEnvironment extends DelegatingEnvironment {
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean value that indicates whether or not usernames should
|
||||
* be treated as case-sensitive.
|
||||
*
|
||||
* @return
|
||||
* true if usernames should be treated as case-sensitive, or false if
|
||||
* usernames should be treated as case-insensitive.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If guacamole.properties cannot be parsed.
|
||||
*/
|
||||
public abstract boolean getCaseSensitiveUsernames() throws GuacamoleException;
|
||||
|
||||
}
|
||||
|
@@ -194,5 +194,10 @@ public class ModeledAuthenticatedUser extends RemoteAuthenticatedUser {
|
||||
public boolean isPrivileged() throws GuacamoleException {
|
||||
return getUser().isPrivileged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCaseSensitive() {
|
||||
return user.isCaseSensitive();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ import java.util.TimeZone;
|
||||
import org.apache.guacamole.auth.jdbc.security.PasswordEncryptionService;
|
||||
import org.apache.guacamole.auth.jdbc.security.SaltService;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.auth.jdbc.JDBCEnvironment;
|
||||
import org.apache.guacamole.auth.jdbc.base.ModeledPermissions;
|
||||
import org.apache.guacamole.form.BooleanField;
|
||||
import org.apache.guacamole.form.DateField;
|
||||
@@ -180,6 +181,13 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
|
||||
*/
|
||||
@Inject
|
||||
private Provider<UserRecordSet> userRecordSetProvider;
|
||||
|
||||
/**
|
||||
* The environment associated with this instance of the JDBC authentication
|
||||
* module.
|
||||
*/
|
||||
@Inject
|
||||
private JDBCEnvironment environment;
|
||||
|
||||
/**
|
||||
* Whether attributes which control access restrictions should be exposed
|
||||
@@ -780,5 +788,15 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
|
||||
public boolean isSkeleton() {
|
||||
return (getModel().getEntityID() == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCaseSensitive() {
|
||||
try {
|
||||
return environment.getCaseSensitiveUsernames();
|
||||
}
|
||||
catch (GuacamoleException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -439,7 +439,18 @@ public class MySQLEnvironment extends JDBCEnvironment {
|
||||
// Enforce access window restrictions for active sessions unless explicitly disabled
|
||||
return getProperty(
|
||||
MySQLGuacamoleProperties.MYSQL_ENFORCE_ACCESS_WINDOWS_FOR_ACTIVE_SESSIONS,
|
||||
true);
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getCaseSensitiveUsernames() throws GuacamoleException {
|
||||
|
||||
return getProperty(
|
||||
MySQLGuacamoleProperties.MYSQL_CASE_SENSITIVE_USERNAMES,
|
||||
false
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -301,6 +301,14 @@ public class MySQLGuacamoleProperties {
|
||||
@Override
|
||||
public String getName() { return "mysql-batch-size"; }
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
public static final BooleanGuacamoleProperty MYSQL_CASE_SENSITIVE_USERNAMES =
|
||||
new BooleanGuacamoleProperty() {
|
||||
|
||||
@Override
|
||||
public String getName() { return "mysql-case-sensitive-usernames"; }
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -398,5 +398,17 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
|
||||
PostgreSQLGuacamoleProperties.POSTGRESQL_ENFORCE_ACCESS_WINDOWS_FOR_ACTIVE_SESSIONS,
|
||||
true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getCaseSensitiveUsernames() throws GuacamoleException {
|
||||
|
||||
// By default, PostgreSQL does use case-sensitive string searches, so
|
||||
// we will honor case-sensitive usernames.
|
||||
return getProperty(
|
||||
PostgreSQLGuacamoleProperties.POSTGRESQL_CASE_SENSITIVE_USERNAMES,
|
||||
true
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -314,5 +314,17 @@ public class PostgreSQLGuacamoleProperties {
|
||||
public String getName() { return "postgresql-batch-size"; }
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* A property that configures whether or not usernames should be treated as
|
||||
* case-sensitive with the Postgres JDBC backend.
|
||||
*/
|
||||
public static final BooleanGuacamoleProperty POSTGRESQL_CASE_SENSITIVE_USERNAMES =
|
||||
new BooleanGuacamoleProperty() {
|
||||
|
||||
@Override
|
||||
public String getName() { return "postgresql-case-sensitive-usernames"; }
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -328,5 +328,17 @@ public class SQLServerEnvironment extends JDBCEnvironment {
|
||||
SQLServerGuacamoleProperties.SQLSERVER_TRUST_ALL_SERVER_CERTIFICATES,
|
||||
false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getCaseSensitiveUsernames() throws GuacamoleException {
|
||||
|
||||
// SQL Server uses case-insensitive string searches by default, so
|
||||
// we do not enforce case-sensitivity unless otherwise configured.
|
||||
return getProperty(
|
||||
SQLServerGuacamoleProperties.SQLSERVER_CASE_SENSITIVE_USERNAMES,
|
||||
false
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -257,5 +257,13 @@ public class SQLServerGuacamoleProperties {
|
||||
public String getName() { return "sqlserver-trust-all-server-certificates"; }
|
||||
|
||||
};
|
||||
|
||||
public static final BooleanGuacamoleProperty SQLSERVER_CASE_SENSITIVE_USERNAMES =
|
||||
new BooleanGuacamoleProperty() {
|
||||
|
||||
@Override
|
||||
public String getName() { return "sqlserver-case-sensitive-usernames" ; }
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user