From a0d0e076587ec57a02dbdd90989539e659e8e749 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Fri, 15 Jun 2018 20:18:32 -0400 Subject: [PATCH] GUACAMOLE-540: Clean up style and comments in Credentials class --- .../guacamole/net/auth/Credentials.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/Credentials.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/Credentials.java index 2c3b89e5c..810e3206e 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/Credentials.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/Credentials.java @@ -123,19 +123,22 @@ public class Credentials implements Serializable { if (matcher.matches()) this.remoteAddress = matcher.group(1); } - // Header not present, just use remote address - else { - this.remoteAddress = request.getRemoteAddr(); - } + // Header not present, just use remote address + else + this.remoteAddress = request.getRemoteAddr(); + + // Get the remote hostname this.remoteHostname = request.getRemoteHost(); + // If session exists get it, but don't create a new one. this.session = request.getSession(false); } /** * Returns the password associated with this set of credentials. + * * @return The password associated with this username/password pair, or * null if no password has been set. */ @@ -145,6 +148,7 @@ public class Credentials implements Serializable { /** * Sets the password associated with this set of credentials. + * * @param password The password to associate with this username/password * pair. */ @@ -154,6 +158,7 @@ public class Credentials implements Serializable { /** * Returns the username associated with this set of credentials. + * * @return The username associated with this username/password pair, or * null if no username has been set. */ @@ -163,6 +168,7 @@ public class Credentials implements Serializable { /** * Sets the username associated with this set of credentials. + * * @param username The username to associate with this username/password * pair. */ @@ -172,6 +178,7 @@ public class Credentials implements Serializable { /** * Returns the HttpServletRequest associated with this set of credentials. + * * @return The HttpServletRequest associated with this set of credentials, * or null if no such request exists. */ @@ -181,9 +188,7 @@ public class Credentials implements Serializable { /** * Sets the HttpServletRequest associated with this set of credentials. - * Also sets the remoteAddress and remoteHostname objects, checking the - * request for X-Forwarded-For or falling back to provided remote address. - * + * * @param request The HttpServletRequest to associated with this set of * credentials. */ @@ -193,6 +198,7 @@ public class Credentials implements Serializable { /** * Returns the HttpSession associated with this set of credentials. + * * @return The HttpSession associated with this set of credentials, or null * if no such request exists. */ @@ -202,6 +208,7 @@ public class Credentials implements Serializable { /** * Sets the HttpSession associated with this set of credentials. + * * @param session The HttpSession to associated with this set of * credentials. */