diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnection.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnection.java index 968e7288b..70cff48fd 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnection.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnection.java @@ -91,7 +91,6 @@ public class MySQLConnection implements Connection { * @param connection */ public void initNew(Connection connection) { - configuration = connection.getConfiguration(); this.connection.setConnection_name(connection.getIdentifier()); this.configuration = connection.getConfiguration(); } @@ -150,7 +149,19 @@ public class MySQLConnection implements Connection { public boolean equals(Object other) { if(!(other instanceof MySQLConnection)) return false; - return ((MySQLConnection)other).getConnectionID() == this.getConnectionID(); + boolean idsAreEqual = ((MySQLConnection)other).getConnectionID() == this.getConnectionID(); + // they are both new, check if they have the same name + if(idsAreEqual && this.getConnectionID() == 0) + return this.getIdentifier().equals(((MySQLConnection)other).getIdentifier()); + return idsAreEqual; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 73 * hash + getConnectionID(); + hash = 73 * hash + getIdentifier().hashCode(); + return hash; } @Override diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLUser.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLUser.java index 491d3d9e1..92975ee87 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLUser.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLUser.java @@ -207,6 +207,18 @@ public class MySQLUser implements User { public boolean equals(Object other) { if(!(other instanceof MySQLUser)) return false; - return ((MySQLUser)other).getUserID() == this.getUserID(); + boolean idsAreEqual = ((MySQLUser)other).getUserID() == this.getUserID(); + // they are both new, check if they have the same name + if(idsAreEqual && this.getUserID() == 0) + return this.getUsername().equals(((MySQLUser)other).getUsername()); + return idsAreEqual; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 73 * hash + getUserID(); + hash = 73 * hash + getUsername().hashCode(); + return hash; } }