GUACAMOLE-47: Merge support for GUAC_CLIENT_HOSTNAME and GUAC_CLIENT_ADDRESS parameter tokens.

This commit is contained in:
Michael Jumper
2017-01-28 10:50:26 -08:00
2 changed files with 44 additions and 0 deletions

View File

@@ -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);