mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-341: Merge automatically pull GUAC_USERNAME token from AuthenticatedUser.
This commit is contained in:
@@ -235,7 +235,7 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
|
|||||||
|
|
||||||
// Build token filter containing credential tokens
|
// Build token filter containing credential tokens
|
||||||
TokenFilter tokenFilter = new TokenFilter();
|
TokenFilter tokenFilter = new TokenFilter();
|
||||||
StandardTokens.addStandardTokens(tokenFilter, user.getCredentials());
|
StandardTokens.addStandardTokens(tokenFilter, user);
|
||||||
|
|
||||||
// Filter the configuration
|
// Filter the configuration
|
||||||
tokenFilter.filterValues(config.getParameters());
|
tokenFilter.filterValues(config.getParameters());
|
||||||
@@ -281,7 +281,7 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
|
|||||||
|
|
||||||
// Build token filter containing credential tokens
|
// Build token filter containing credential tokens
|
||||||
TokenFilter tokenFilter = new TokenFilter();
|
TokenFilter tokenFilter = new TokenFilter();
|
||||||
StandardTokens.addStandardTokens(tokenFilter, user.getCredentials());
|
StandardTokens.addStandardTokens(tokenFilter, user);
|
||||||
|
|
||||||
// Filter the configuration
|
// Filter the configuration
|
||||||
tokenFilter.filterValues(config.getParameters());
|
tokenFilter.filterValues(config.getParameters());
|
||||||
|
@@ -123,7 +123,7 @@ public class ConnectionService {
|
|||||||
|
|
||||||
// Build token filter containing credential tokens
|
// Build token filter containing credential tokens
|
||||||
TokenFilter tokenFilter = new TokenFilter();
|
TokenFilter tokenFilter = new TokenFilter();
|
||||||
StandardTokens.addStandardTokens(tokenFilter, user.getCredentials());
|
StandardTokens.addStandardTokens(tokenFilter, user);
|
||||||
|
|
||||||
// Produce connections for each readable configuration
|
// Produce connections for each readable configuration
|
||||||
Map<String, Connection> connections = new HashMap<String, Connection>();
|
Map<String, Connection> connections = new HashMap<String, Connection>();
|
||||||
|
@@ -21,6 +21,7 @@ package org.apache.guacamole.token;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import org.apache.guacamole.net.auth.AuthenticatedUser;
|
||||||
import org.apache.guacamole.net.auth.Credentials;
|
import org.apache.guacamole.net.auth.Credentials;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,4 +139,31 @@ public class StandardTokens {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds tokens which are standardized by guacamole-ext to the given
|
||||||
|
* TokenFilter using the values from the given AuthenticatedUser object,
|
||||||
|
* including any associated credentials. These standardized tokens include
|
||||||
|
* the current username (GUAC_USERNAME), password (GUAC_PASSWORD), and the
|
||||||
|
* server date and time (GUAC_DATE and GUAC_TIME respectively). If either
|
||||||
|
* the username or password are not set within the given user or their
|
||||||
|
* provided credentials, the corresponding token(s) will remain unset.
|
||||||
|
*
|
||||||
|
* @param filter
|
||||||
|
* The TokenFilter to add standard tokens to.
|
||||||
|
*
|
||||||
|
* @param user
|
||||||
|
* The AuthenticatedUser to use when populating the GUAC_USERNAME and
|
||||||
|
* GUAC_PASSWORD tokens.
|
||||||
|
*/
|
||||||
|
public static void addStandardTokens(TokenFilter filter, AuthenticatedUser user) {
|
||||||
|
|
||||||
|
// Default to the authenticated user's username for the GUAC_USERNAME
|
||||||
|
// token
|
||||||
|
filter.setToken(USERNAME_TOKEN, user.getIdentifier());
|
||||||
|
|
||||||
|
// Add tokens specific to credentials
|
||||||
|
addStandardTokens(filter, user.getCredentials());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user