mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-47: Merge support for GUAC_CLIENT_HOSTNAME and GUAC_CLIENT_ADDRESS parameter tokens.
This commit is contained in:
@@ -22,6 +22,7 @@ package org.apache.guacamole.token;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import org.apache.guacamole.net.auth.Credentials;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Utility class which provides access to standardized token names, as well as
|
||||
@@ -41,6 +42,16 @@ public class StandardTokens {
|
||||
*/
|
||||
public static final String PASSWORD_TOKEN = "GUAC_PASSWORD";
|
||||
|
||||
/**
|
||||
* The name of the client token added via addStandardTokens().
|
||||
*/
|
||||
public static final String REMHOST_TOKEN = "GUAC_CLIENT_HOSTNAME";
|
||||
|
||||
/**
|
||||
* The IP of the client token added via addStandardTokens().
|
||||
*/
|
||||
public static final String REMIP_TOKEN = "GUAC_CLIENT_ADDRESS";
|
||||
|
||||
/**
|
||||
* The name of the date token (server-local time) added via
|
||||
* addStandardTokens().
|
||||
@@ -115,6 +126,13 @@ public class StandardTokens {
|
||||
if (password != null)
|
||||
filter.setToken(PASSWORD_TOKEN, password);
|
||||
|
||||
// Add client hostname and ip tokens
|
||||
HttpServletRequest request = credentials.getRequest();
|
||||
if (request != null) {
|
||||
filter.setToken(REMHOST_TOKEN, request.getRemoteHost());
|
||||
filter.setToken(REMIP_TOKEN, request.getRemoteAddr());
|
||||
}
|
||||
|
||||
// Add any tokens which do not require credentials
|
||||
addStandardTokens(filter);
|
||||
|
||||
|
Reference in New Issue
Block a user