mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-1224: Migrate existing auth-related logging to global event listener.
This commit is contained in:
@@ -236,4 +236,36 @@ public class Credentials implements Serializable {
|
||||
this.remoteHostname = remoteHostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this Credentials object does not contain any specific
|
||||
* authentication parameters, including HTTP parameters and the HTTP header
|
||||
* used for the authentication token. An authentication request that
|
||||
* contains no parameters whatsoever will tend to be the first, anonymous,
|
||||
* credential-less authentication attempt that results in the initial login
|
||||
* screen rendering.
|
||||
*
|
||||
* @return
|
||||
* true if this Credentials object contains no authentication
|
||||
* parameters whatsoever, false otherwise.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
|
||||
// An authentication request that contains an explicit username or
|
||||
// password (even if blank) is non-empty, regardless of how the values
|
||||
// were passed
|
||||
if (getUsername() != null || getPassword() != null)
|
||||
return false;
|
||||
|
||||
// All further tests depend on HTTP request details
|
||||
HttpServletRequest httpRequest = getRequest();
|
||||
if (httpRequest == null)
|
||||
return true;
|
||||
|
||||
// An authentication request is non-empty if it contains any HTTP
|
||||
// parameters at all or contains an authentication token
|
||||
return !httpRequest.getParameterNames().hasMoreElements()
|
||||
&& httpRequest.getHeader("Guacamole-Token") == null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -42,17 +42,47 @@ public class AuthenticationSuccessEvent implements UserEvent, CredentialEvent,
|
||||
*/
|
||||
private final AuthenticatedUser authenticatedUser;
|
||||
|
||||
/**
|
||||
* Whether the successful authentication attempt represented by this event
|
||||
* is related to an established Guacamole session.
|
||||
*/
|
||||
private final boolean existingSession;
|
||||
|
||||
/**
|
||||
* Creates a new AuthenticationSuccessEvent which represents a successful
|
||||
* authentication attempt by the user identified by the given
|
||||
* AuthenticatedUser object.
|
||||
* AuthenticatedUser object. The authentication attempt is presumed to be
|
||||
* a fresh authentication attempt unrelated to an established session (a
|
||||
* login attempt).
|
||||
*
|
||||
* @param authenticatedUser
|
||||
* The AuthenticatedUser identifying the user that successfully
|
||||
* authenticated.
|
||||
*/
|
||||
public AuthenticationSuccessEvent(AuthenticatedUser authenticatedUser) {
|
||||
this(authenticatedUser, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AuthenticationSuccessEvent which represents a successful
|
||||
* authentication attempt by the user identified by the given
|
||||
* AuthenticatedUser object. Whether the authentication attempt is
|
||||
* related to an established session (a periodic re-authentication attempt
|
||||
* that updates session status) or not (a fresh login attempt) is
|
||||
* determined by the value of the provided flag.
|
||||
*
|
||||
* @param authenticatedUser
|
||||
* The AuthenticatedUser identifying the user that successfully
|
||||
* authenticated.
|
||||
*
|
||||
* @param existingSession
|
||||
* Whether this AuthenticationSuccessEvent represents an
|
||||
* re-authentication attempt that updates the status of an established
|
||||
* Guacamole session.
|
||||
*/
|
||||
public AuthenticationSuccessEvent(AuthenticatedUser authenticatedUser, boolean existingSession) {
|
||||
this.authenticatedUser = authenticatedUser;
|
||||
this.existingSession = existingSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,4 +100,21 @@ public class AuthenticationSuccessEvent implements UserEvent, CredentialEvent,
|
||||
return getAuthenticatedUser().getAuthenticationProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the successful authentication attempt represented by
|
||||
* this event is related to an established Guacamole session. During normal
|
||||
* operation, the Guacamole web application will periodically
|
||||
* re-authenticate with the server to verify its authentication token and
|
||||
* update the session state, in which case the value returned by this
|
||||
* function will be true. If the user was not already authenticated and has
|
||||
* just initially logged in, false is returned.
|
||||
*
|
||||
* @return
|
||||
* true if this AuthenticationSuccessEvent is related to a Guacamole
|
||||
* session that was already established, false otherwise.
|
||||
*/
|
||||
public boolean isExistingSession() {
|
||||
return existingSession;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user