summaryrefslogtreecommitdiffstats
path: root/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java')
-rw-r--r--src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java
index 88208b9..93fda8d 100644
--- a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java
+++ b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java
@@ -5,6 +5,7 @@ import org.apache.guacamole.net.auth.AbstractUserContext;
import org.apache.guacamole.net.auth.AuthenticatedUser;
import org.apache.guacamole.net.auth.AuthenticationProvider;
import org.apache.guacamole.net.auth.Connection;
+import org.apache.guacamole.net.auth.Credentials;
import org.apache.guacamole.net.auth.Directory;
import org.apache.guacamole.net.auth.User;
import org.apache.guacamole.net.auth.UserContext;
@@ -32,17 +33,24 @@ public class BwlpUserContext extends AbstractUserContext {
private final UserContext originalContext;
private final Integer groupid;
private final String resolution;
+ private final String username;
/**
* The Directory with access to all connections within the root group associated
* with this UserContext.
*/
private Directory<Connection> connectionDirectory;
-
+
public BwlpUserContext(AuthenticatedUser authenticatedUser, UserContext context, int groupid, String resolution)
throws GuacamoleCredentialsException {
authUser = authenticatedUser;
originalContext = context;
+ Credentials cred = authenticatedUser.getCredentials();
+ if (cred != null && cred.getUsername() != null) {
+ username = cred.getUsername();
+ } else {
+ username = authenticatedUser.getIdentifier();
+ }
this.groupid = groupid;
this.resolution = resolution;
// OK
@@ -52,13 +60,19 @@ public class BwlpUserContext extends AbstractUserContext {
public BwlpUserContext(AuthenticatedUser authenticatedUser, UserContext context, WrappedConnection exConn) {
authUser = authenticatedUser;
originalContext = context;
+ Credentials cred = authenticatedUser.getCredentials();
+ if (cred != null && cred.getUsername() != null) {
+ username = cred.getUsername();
+ } else {
+ username = authenticatedUser.getIdentifier();
+ }
this.groupid = -1;
this.resolution = "";
connectionDirectory = new SimpleDirectory<Connection>(exConn);
}
private void addConn() throws GuacamoleCredentialsException {
- WrappedConnection connection = ConnectionManager.getForUser(authUser.getCredentials().getUsername(), groupid);
+ WrappedConnection connection = ConnectionManager.getForUser(username, groupid);
if (connection != null) {
connection.remoteLogin(authUser.getCredentials(), this.resolution);
connection.setContext(this);
@@ -69,7 +83,7 @@ public class BwlpUserContext extends AbstractUserContext {
}
public User self() {
- return new SimpleUser(authUser.getCredentials().getUsername()) {
+ return new SimpleUser(username) {
@Override
public ObjectPermissionSet getConnectionGroupPermissions() throws GuacamoleException {