summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUdo Walter2020-05-14 04:45:10 +0200
committerUdo Walter2020-05-14 04:45:10 +0200
commitc72ab24dadf00b8a930f0baf739a7cdf10a139da (patch)
treec7a8b7ace92c04413c0a20353faaaa031da9707b
parentFix two ways a client could be listed as free but be not connectable. (diff)
downloadbwlp-guacamole-ext-c72ab24dadf00b8a930f0baf739a7cdf10a139da.tar.gz
bwlp-guacamole-ext-c72ab24dadf00b8a930f0baf739a7cdf10a139da.tar.xz
bwlp-guacamole-ext-c72ab24dadf00b8a930f0baf739a7cdf10a139da.zip
Fix bug where user could reconnect to an old connection.
-rw-r--r--src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java1
-rw-r--r--src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java5
-rw-r--r--src/main/java/de/bwlehrpool/bwlp_guac/WrappedConnection.java10
3 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java b/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java
index 5d551d9..8798813 100644
--- a/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java
+++ b/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java
@@ -66,6 +66,7 @@ public class AvailableClient implements Cloneable {
if (this.inUseBy != null) {
LOGGER.info("Client " + this + " is available again");
this.inUseBy = null;
+ if (this.connection != null) this.connection.invalidate();
}
}
this.lastConnectionCheck = 0;
diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java
index 91d5849..813b6f2 100644
--- a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java
+++ b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java
@@ -50,6 +50,7 @@ public class BwlpUserContext extends AbstractUserContext {
private void addConn() throws GuacamoleCredentialsException {
WrappedConnection connection = ConnectionManager.getForUser(authUser.getCredentials().getUsername(), groupid);
if (connection != null) {
+ connection.setContext(this);
connectionDirectory = new SimpleDirectory<Connection>(connection);
} else {
connectionDirectory = new SimpleDirectory<Connection>();
@@ -86,6 +87,10 @@ public class BwlpUserContext extends AbstractUserContext {
return connectionDirectory;
}
+ public void clearConnections() {
+ connectionDirectory = new SimpleDirectory<Connection>();
+ }
+
public boolean hasValidConnection() {
boolean ok = false;
try {
diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/WrappedConnection.java b/src/main/java/de/bwlehrpool/bwlp_guac/WrappedConnection.java
index a2ecb52..95a014b 100644
--- a/src/main/java/de/bwlehrpool/bwlp_guac/WrappedConnection.java
+++ b/src/main/java/de/bwlehrpool/bwlp_guac/WrappedConnection.java
@@ -11,6 +11,8 @@ public class WrappedConnection extends SimpleConnection {
private boolean valid = true;
+ private BwlpUserContext context;
+
public WrappedConnection(String name, AvailableClient ac) {
super(name, name, makeConfig(ac));
this.ac = ac.clone();
@@ -31,6 +33,14 @@ public class WrappedConnection extends SimpleConnection {
public void invalidate() {
this.valid = false;
+ if (this.context != null) {
+ this.context.clearConnections();
+ this.context = null;
+ }
+ }
+
+ public void setContext(BwlpUserContext context) {
+ this.context = context;
}
}