mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-05 20:57:40 +00:00
GUACAMOLE-341: Automatically pull GUAC_USERNAME token from AuthenticatedUser's identifier if there is no username provided via Credentials (closes #174).
This commit is contained in:
@@ -235,7 +235,7 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
|
||||
|
||||
// Build token filter containing credential tokens
|
||||
TokenFilter tokenFilter = new TokenFilter();
|
||||
StandardTokens.addStandardTokens(tokenFilter, user.getCredentials());
|
||||
StandardTokens.addStandardTokens(tokenFilter, user);
|
||||
|
||||
// Filter the configuration
|
||||
tokenFilter.filterValues(config.getParameters());
|
||||
@@ -281,7 +281,7 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
|
||||
|
||||
// Build token filter containing credential tokens
|
||||
TokenFilter tokenFilter = new TokenFilter();
|
||||
StandardTokens.addStandardTokens(tokenFilter, user.getCredentials());
|
||||
StandardTokens.addStandardTokens(tokenFilter, user);
|
||||
|
||||
// Filter the configuration
|
||||
tokenFilter.filterValues(config.getParameters());
|
||||
|
@@ -123,7 +123,7 @@ public class ConnectionService {
|
||||
|
||||
// Build token filter containing credential tokens
|
||||
TokenFilter tokenFilter = new TokenFilter();
|
||||
StandardTokens.addStandardTokens(tokenFilter, user.getCredentials());
|
||||
StandardTokens.addStandardTokens(tokenFilter, user);
|
||||
|
||||
// Produce connections for each readable configuration
|
||||
Map<String, Connection> connections = new HashMap<String, Connection>();
|
||||
|
@@ -21,6 +21,7 @@ package org.apache.guacamole.token;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import org.apache.guacamole.net.auth.AuthenticatedUser;
|
||||
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