mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUAC-1132: Add support for getRemoteHost() of ConnectionRecord. Store remote host within AuthenticatedUser.
This commit is contained in:
@@ -37,6 +37,14 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Java servlet API -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Guacamole Extension API -->
|
||||
<dependency>
|
||||
<groupId>org.glyptodon.guacamole</groupId>
|
||||
|
@@ -69,8 +69,7 @@ public class ModeledConnectionRecord implements ConnectionRecord {
|
||||
|
||||
@Override
|
||||
public String getRemoteHost() {
|
||||
// STUB
|
||||
return "STUB";
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -176,8 +176,7 @@ public class ActiveConnectionRecord implements ConnectionRecord {
|
||||
|
||||
@Override
|
||||
public String getRemoteHost() {
|
||||
// STUB
|
||||
return "STUB";
|
||||
return user.getRemoteHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
package org.glyptodon.guacamole.auth.jdbc.user;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.glyptodon.guacamole.net.auth.Credentials;
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,27 @@ public class AuthenticatedUser {
|
||||
*/
|
||||
private final Credentials credentials;
|
||||
|
||||
/**
|
||||
* The host from which this user authenticated.
|
||||
*/
|
||||
private final String remoteHost;
|
||||
|
||||
/**
|
||||
* Derives the remote host of the authenticating user from the given
|
||||
* credentials object.
|
||||
*
|
||||
* @param credentials
|
||||
* The credentials to derive the remote host from.
|
||||
*
|
||||
* @return
|
||||
* The remote host from which the user with the given credentials is
|
||||
* authenticating.
|
||||
*/
|
||||
private static String getRemoteHost(Credentials credentials) {
|
||||
HttpServletRequest request = credentials.getRequest();
|
||||
return request.getRemoteAddr();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AuthenticatedUser associating the given user with their
|
||||
* corresponding credentials.
|
||||
@@ -54,6 +76,7 @@ public class AuthenticatedUser {
|
||||
public AuthenticatedUser(ModeledUser user, Credentials credentials) {
|
||||
this.user = user;
|
||||
this.credentials = credentials;
|
||||
this.remoteHost = getRemoteHost(credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,4 +99,14 @@ public class AuthenticatedUser {
|
||||
return credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the host from which this user authenticated.
|
||||
*
|
||||
* @return
|
||||
* The host from which this user authenticated.
|
||||
*/
|
||||
public String getRemoteHost() {
|
||||
return remoteHost;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user