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

@@ -41,6 +41,16 @@ public class APIRequest extends HttpServletRequestWrapper {
*/
private final Map<String, String[]> parameters;
/**
* The hostname of the client that initiated the request.
*/
private final String remoteHost;
/**
* The ip address of the client that initiated the request.
*/
private final String remoteAddr;
/**
* Wraps the given HttpServletRequest, using the given MultivaluedMap to
* provide all request parameters. All HttpServletRequest functions which
@@ -58,6 +68,12 @@ public class APIRequest extends HttpServletRequestWrapper {
super(request);
// Grab the remote host info
this.remoteHost = request.getRemoteHost();
// Grab the remote ip info
this.remoteAddr = request.getRemoteAddr();
// Copy parameters from given MultivaluedMap
this.parameters = new HashMap<String, String[]>(parameters.size());
for (Map.Entry<String, List<String>> entry : parameters.entrySet()) {
@@ -101,4 +117,14 @@ public class APIRequest extends HttpServletRequestWrapper {
}
@Override
public String getRemoteHost() {
return this.remoteHost;
}
@Override
public String getRemoteAddr() {
return this.remoteAddr;
}
}