GUACAMOLE-2181: Merge improve readability of logs.

This commit is contained in:
Virtually Nick authored and GitHub committed 2025-12-12 19:32:46 -06:00
commit 4aa841c4f8
61 files changed
+1320 -288

No files matched your search

@@ -343,15 +343,13 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
// Translate connection limit attribute
try { getModel().setMaxConnections(NumericField.parse(attributes.get(MAX_CONNECTIONS_NAME))); }
catch (NumberFormatException e) {
logger.warn("Not setting maximum connections: {}", e.getMessage());
logger.debug("Unable to parse numeric attribute.", e);
logger.warn("Not setting maximum connections: {}", e.getMessage(), e);
}
// Translate per-user connection limit attribute
try { getModel().setMaxConnectionsPerUser(NumericField.parse(attributes.get(MAX_CONNECTIONS_PER_USER_NAME))); }
catch (NumberFormatException e) {
logger.warn("Not setting maximum connections per user: {}", e.getMessage());
logger.debug("Unable to parse numeric attribute.", e);
logger.warn("Not setting maximum connections per user: {}", e.getMessage(), e);
}
// Translate guacd hostname
@@ -360,8 +358,7 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
// Translate guacd port
try { getModel().setProxyPort(NumericField.parse(attributes.get(GUACD_PORT_NAME))); }
catch (NumberFormatException e) {
logger.warn("Not setting guacd port: {}", e.getMessage());
logger.debug("Unable to parse numeric attribute.", e);
logger.warn("Not setting guacd port: {}", e.getMessage(), e);
}
// Translate guacd encryption method
@@ -382,8 +379,7 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
// Translate connection weight attribute
try { getModel().setConnectionWeight(NumericField.parse(attributes.get(CONNECTION_WEIGHT))); }
catch (NumberFormatException e) {
logger.warn("Not setting the connection weight: {}", e.getMessage());
logger.debug("Unable to parse numeric attribute.", e);
logger.warn("Not setting the connection weight: {}", e.getMessage(), e);
}
// Translate failover-only attribute
@@ -200,15 +200,13 @@ public class ModeledConnectionGroup extends ModeledChildDirectoryObject<Connecti
// Translate connection limit attribute
try { getModel().setMaxConnections(NumericField.parse(attributes.get(MAX_CONNECTIONS_NAME))); }
catch (NumberFormatException e) {
logger.warn("Not setting maximum connections: {}", e.getMessage());
logger.debug("Unable to parse numeric attribute.", e);
logger.warn("Not setting maximum connections: {}", e.getMessage(), e);
}
// Translate per-user connection limit attribute
try { getModel().setMaxConnectionsPerUser(NumericField.parse(attributes.get(MAX_CONNECTIONS_PER_USER_NAME))); }
catch (NumberFormatException e) {
logger.warn("Not setting maximum connections per user: {}", e.getMessage());
logger.debug("Unable to parse numeric attribute.", e);
logger.warn("Not setting maximum connections per user: {}", e.getMessage(), e);
}
// Translate session affinity attribute
@@ -778,8 +778,9 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
// If connection failed due to an upstream error, retry other
// connections
catch (GuacamoleUpstreamException e) {
logger.info("Upstream error intercepted for connection \"{}\". Failing over to next connection in group...", connection.getIdentifier());
logger.debug("Upstream remote desktop reported an error during connection.", e);
logger.info("Upstream error intercepted for connection \"{}\". "
+ "Failing over to next connection in group...",
connection.getIdentifier(), e);
connections.remove(connection);
upstreamHasFailed = true;
}
@@ -442,8 +442,7 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
if (attributes.containsKey(ACCESS_WINDOW_START_ATTRIBUTE_NAME)) {
try { getModel().setAccessWindowStart(parseTime(attributes.get(ACCESS_WINDOW_START_ATTRIBUTE_NAME))); }
catch (ParseException e) {
logger.warn("Not setting start time of user access window: {}", e.getMessage());
logger.debug("Unable to parse time attribute.", e);
logger.warn("Not setting start time of user access window: {}", e.getMessage(), e);
}
}
@@ -451,8 +450,7 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
if (attributes.containsKey(ACCESS_WINDOW_END_ATTRIBUTE_NAME)) {
try { getModel().setAccessWindowEnd(parseTime(attributes.get(ACCESS_WINDOW_END_ATTRIBUTE_NAME))); }
catch (ParseException e) {
logger.warn("Not setting end time of user access window: {}", e.getMessage());
logger.debug("Unable to parse time attribute.", e);
logger.warn("Not setting end time of user access window: {}", e.getMessage(), e);
}
}
@@ -460,8 +458,7 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
if (attributes.containsKey(VALID_FROM_ATTRIBUTE_NAME)) {
try { getModel().setValidFrom(parseDate(attributes.get(VALID_FROM_ATTRIBUTE_NAME))); }
catch (ParseException e) {
logger.warn("Not setting user validity start date: {}", e.getMessage());
logger.debug("Unable to parse date attribute.", e);
logger.warn("Not setting user validity start date: {}", e.getMessage(), e);
}
}
@@ -469,8 +466,7 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
if (attributes.containsKey(VALID_UNTIL_ATTRIBUTE_NAME)) {
try { getModel().setValidUntil(parseDate(attributes.get(VALID_UNTIL_ATTRIBUTE_NAME))); }
catch (ParseException e) {
logger.warn("Not setting user validity end date: {}", e.getMessage());
logger.debug("Unable to parse date attribute.", e);
logger.warn("Not setting user validity end date: {}", e.getMessage(), e);
}
}
@@ -325,13 +325,9 @@ public class ModeledUserContext extends RestrictedObject
}
catch (GuacamoleException e) {
logger.warn(
"Unable to determine if access window enforcement is"
+ " enabled for active sessions; enforcing by default: {}"
, e.getMessage());
logger.debug("Unable to determine access window enforcement policy.", e);
logger.warn("Unable to determine if access window enforcement is"
+ " enabled for active sessions; enforcing by default: {}",
e.getMessage(), e);
}
// A user context is valid if the associated user's account is valid
@@ -78,14 +78,15 @@ public class RequestValidationService {
// Deny all requests if restrictions cannot be parsed
catch (GuacamoleException e) {
logger.warn("Authentication request from \"{}\" is DENIED due to parse error: {}", credentials.getRemoteAddress(), e.getMessage());
logger.debug("Error parsing authentication request restrictions from guacamole.properties.", e);
logger.warn("Authentication request from \"{}\" is DENIED due to "
+ "parse error: {}", credentials.getRemoteAddress(), e.getMessage(), e);
return false;
}
// All requests are allowed if no restrictions are defined
if (trustedNetworks.isEmpty()) {
logger.debug("Authentication request from \"{}\" is ALLOWED (no restrictions).", credentials.getRemoteAddress());
logger.debug("Authentication request from \"{}\" is ALLOWED (no "
+ "restrictions).", credentials.getRemoteAddress());
return true;
}
@@ -94,14 +95,16 @@ public class RequestValidationService {
// Request is allowed if any subnet matches
if (new IPAddressString(network).contains(new IPAddressString(credentials.getRemoteAddress()))) {
logger.debug("Authentication request from \"{}\" is ALLOWED (matched subnet).", credentials.getRemoteAddress());
logger.debug("Authentication request from \"{}\" is ALLOWED "
+ "(matched subnet).", credentials.getRemoteAddress());
return true;
}
}
// Otherwise request is denied - no subnets matched
logger.debug("Authentication request from \"{}\" is DENIED (did not match subnet).", credentials.getRemoteAddress());
logger.debug("Authentication request from \"{}\" is DENIED (did not "
+ "match subnet).", credentials.getRemoteAddress());
return false;
}
@@ -168,22 +168,19 @@ public class UserDataService {
// Fail if base64 data is not valid
catch (IllegalArgumentException e) {
logger.warn("Submitted data is not proper base64.");
logger.debug("Invalid base64 data.", e);
logger.warn("Submitted data is not proper base64: {}", e.getMessage(), e);
return null;
}
// Handle lack of standard UTF-8 support (should never happen)
catch (UnsupportedEncodingException e) {
logger.error("Unexpected lack of support for UTF-8: {}", e.getMessage());
logger.debug("Unable to decode base64 data as UTF-8.", e);
logger.error("Unexpected lack of support for UTF-8: {}", e.getMessage(), e);
return null;
}
// Fail if decryption or key retrieval fails for any reason
catch (GuacamoleException e) {
logger.error("Decryption of received data failed: {}", e.getMessage());
logger.debug("Unable to decrypt received data.", e);
logger.error("Decryption of received data failed: {}", e.getMessage(), e);
return null;
}
@@ -205,8 +202,7 @@ public class UserDataService {
// Fail UserData creation if JSON is invalid/unreadable
catch (IOException e) {
logger.error("Received JSON is invalid: {}", e.getMessage());
logger.debug("Error parsing UserData JSON.", e);
logger.error("Received JSON is invalid: {}", e.getMessage(), e);
return null;
}
@@ -322,8 +322,7 @@ public class LDAPConnectionService {
ldapConnection.close();
logger.error("Binding with the LDAP server at \"{}\" as user "
+ "\"{}\" failed: {}", config.getLdapHost(), bindUser,
e.getMessage());
logger.debug("Unable to bind to LDAP server.", e);
e.getMessage(), e);
return null;
}
@@ -369,8 +368,8 @@ public class LDAPConnectionService {
}
catch (LdapInvalidDnException e) {
logger.error("Credentials of existing connection cannot be used. "
+ "The username used (\"{}\") is not a valid DN.", username);
logger.debug("Cannot bind using invalid DN.", e);
+ "The username used (\"{}\") is not a valid DN.",
username, e);
ldapConnection.close();
return null;
}
@@ -265,8 +265,7 @@ public class ObjectQueryService {
+ "URL \"{}\".", url);
}
catch (GuacamoleException e) {
logger.warn("Referral to \"{}\" could not be followed: {}", url, e.getMessage());
logger.debug("Failed to follow LDAP referral.", e);
logger.warn("Referral to \"{}\" could not be followed: {}", url, e.getMessage(), e);
}
}
@@ -122,7 +122,7 @@ public class ConfigurationService {
}
catch (IOException e) {
logger.error("\"{}\" could not be read/parsed: {}", ldapServers, e.getMessage());
logger.error("\"{}\" could not be read/parsed: {}", ldapServers, e.getMessage(), e);
}
}
else
@@ -202,8 +202,7 @@ public class ConnectionService {
}
catch (LdapInvalidAttributeValueException e) {
logger.error("Invalid value for {} attribute: {}",
LDAP_ATTRIBUTE_NAME_ID, e.getMessage());
logger.debug("LDAP exception while getting CN attribute.", e);
LDAP_ATTRIBUTE_NAME_ID, e.getMessage(), e);
return null;
}
@@ -223,8 +222,7 @@ public class ConnectionService {
config.setProtocol(protocol.getString());
}
catch (LdapInvalidAttributeValueException e) {
logger.error("Invalid value of the protocol entry: {}", e.getMessage());
logger.debug("LDAP exception when getting protocol value.", e);
logger.error("Invalid value of the protocol entry: {}", e.getMessage(), e);
return null;
}
@@ -234,8 +232,7 @@ public class ConnectionService {
proxyConfig = getProxyConfiguration(entry);
}
catch (GuacamoleException e) {
logger.error("Failed to retrieve proxy configuration.", e.getMessage());
logger.debug("Guacamole Exception when retrieving proxy configuration.", e);
logger.error("Failed to retrieve proxy configuration.", e.getMessage(), e);
return null;
}
@@ -250,8 +247,7 @@ public class ConnectionService {
parameter = parameterAttribute.getString();
}
catch (LdapInvalidAttributeValueException e) {
logger.warn("Parameter value not valid for {}: {}", cnName, e.getMessage());
logger.debug("LDAP exception when getting parameter value.", e);
logger.warn("Parameter value not valid for {}: {}", cnName, e.getMessage(), e);
return null;
}
parameterAttribute.remove(parameter);
@@ -394,8 +390,7 @@ public class ConnectionService {
return new GuacamoleProxyConfiguration(proxyHostname, proxyPort, proxyEncryption);
}
catch (LdapInvalidAttributeValueException e) {
logger.error("Invalid value in proxy configuration: {}", e.getMessage());
logger.debug("LDAP exception fetching proxy attribute value.", e);
logger.error("Invalid value in proxy configuration: {}", e.getMessage(), e);
throw new GuacamoleServerException("Invalid LDAP value in proxy configuration.", e);
}
}
@@ -214,9 +214,7 @@ public class UserGroupService {
}
catch (LdapInvalidAttributeValueException e) {
logger.error("User group missing identifier: {}",
e.getMessage());
logger.debug("LDAP exception while getting "
+ "group identifier.", e);
e.getMessage(), e);
}
}
}
@@ -280,8 +278,7 @@ public class UserGroupService {
}
catch (LdapInvalidAttributeValueException e) {
logger.error("User group missing identifier: {}",
e.getMessage());
logger.debug("LDAP exception while getting group identifier.", e);
e.getMessage(), e);
}
});
@@ -10,7 +10,6 @@
],
"translations" : [
"translations/de.json",
"translations/en.json",
"translations/zh.json"
]
@@ -94,16 +94,18 @@ public class AuthenticationProviderService {
// Try to get the state attribute - if it's not there, we have a problem
RadiusAttribute stateAttr = challengePacket.findAttribute(Attr_State.TYPE);
if (stateAttr == null) {
logger.error("Something went wrong, state attribute not present.");
logger.debug("State Attribute turned up null, which shouldn't happen in AccessChallenge.");
logger.error("RADIUS server did not include the required \"{}\" "
+ "attribute in its challenge packet - cannot continue.",
Attr_State.NAME);
return null;
}
// We need to get the reply message so we know what to ask the user
RadiusAttribute replyAttr = challengePacket.findAttribute(Attr_ReplyMessage.TYPE);
if (replyAttr == null) {
logger.error("No reply message received from the server.");
logger.debug("Expecting a Attr_ReplyMessage attribute on this packet, and did not get one.");
logger.error("RADIUS server did not include the required \"{}\" "
+ "attribute in its challenge packet - cannot continue.",
Attr_ReplyMessage.NAME);
return null;
}
@@ -162,8 +164,7 @@ public class AuthenticationProviderService {
null);
}
catch (GuacamoleException e) {
logger.error("Cannot configure RADIUS server: {}", e.getMessage());
logger.debug("Error configuring RADIUS server.", e);
logger.error("Cannot configure RADIUS server: {}", e.getMessage(), e);
throw new GuacamoleInvalidCredentialsException("Authentication error.", CredentialsInfo.USERNAME_PASSWORD);
}
}
@@ -184,13 +185,11 @@ public class AuthenticationProviderService {
stateBytes);
}
catch (IllegalArgumentException e) {
logger.warn("Illegal hexadecimal value while parsing RADIUS state string: {}", e.getMessage());
logger.debug("Encountered exception while attempting to parse the hexidecimal state value.", e);
logger.warn("Illegal hexadecimal value while parsing RADIUS state string: {}", e.getMessage(), e);
throw new GuacamoleInvalidCredentialsException("Authentication error.", CredentialsInfo.USERNAME_PASSWORD);
}
catch (GuacamoleException e) {
logger.error("Cannot configure RADIUS server: {}", e.getMessage());
logger.debug("Error configuring RADIUS server.", e);
logger.error("Cannot configure RADIUS server: {}", e.getMessage(), e);
throw new GuacamoleInvalidCredentialsException("Authentication error.", CredentialsInfo.USERNAME_PASSWORD);
}
}
@@ -245,18 +245,15 @@ public class RadiusConnectionService {
}
catch (RadiusException e) {
logger.error("Unable to complete authentication.", e.getMessage());
logger.debug("Authentication with RADIUS failed.", e);
logger.error("Unable to complete authentication: {}", e.getMessage(), e);
return null;
}
catch (NoSuchAlgorithmException e) {
logger.error("No such RADIUS algorithm: {}", e.getMessage());
logger.debug("Unknown RADIUS algorithm.", e);
logger.error("No such RADIUS algorithm: {}", e.getMessage(), e);
return null;
}
catch (UnknownHostException e) {
logger.error("Could not resolve address: {}", e.getMessage());
logger.debug("Exception resolving host address.", e);
logger.error("Could not resolve address: {}", e.getMessage(), e);
return null;
}
finally {
@@ -64,8 +64,7 @@ public class HostRestrictionParser {
addressList.add(hostName);
}
catch (HostNameException e) {
LOGGER.warn("Invalid host name or IP: {}", host);
LOGGER.debug("HostNameException.", e.getMessage());
LOGGER.warn("Invalid host name or IP: {}", host, e);
}
}
@@ -122,12 +122,10 @@ public class TokenValidationService {
}
// Log any failures to validate/parse the JWT
catch (MalformedClaimException e) {
logger.info("Rejected OpenID token with malformed claim: {}", e.getMessage());
logger.debug("Malformed claim within received JWT.", e);
logger.info("Rejected OpenID token with malformed claim: {}", e.getMessage(), e);
}
catch (InvalidJwtException e) {
logger.info("Rejected invalid OpenID token: {}", e.getMessage());
logger.debug("Invalid JWT received.", e);
logger.info("Rejected invalid OpenID token: {}", e.getMessage(), e);
}
return null;
@@ -160,8 +158,7 @@ public class TokenValidationService {
return username;
}
catch (MalformedClaimException e) {
logger.info("Rejected OpenID token with malformed claim: {}", e.getMessage());
logger.debug("Malformed claim within received JWT.", e);
logger.info("Rejected OpenID token with malformed claim: {}", e.getMessage(), e);
}
// Warn if username was not present in token, as it likely means
@@ -203,8 +200,7 @@ public class TokenValidationService {
return Collections.unmodifiableSet(new HashSet<>(oidcGroups));
}
catch (MalformedClaimException e) {
logger.info("Rejected OpenID token with malformed claim: {}", e.getMessage());
logger.debug("Malformed claim within received JWT.", e);
logger.info("Rejected OpenID token with malformed claim: {}", e.getMessage(), e);
}
}
@@ -262,8 +258,7 @@ public class TokenValidationService {
return Collections.unmodifiableMap(tokens);
}
catch (MalformedClaimException e) {
logger.info("Rejected OpenID token with malformed claim: {}", e.getMessage());
logger.debug("Malformed claim within received JWT.", e);
logger.info("Rejected OpenID token with malformed claim: {}", e.getMessage(), e);
}
}
@@ -125,8 +125,7 @@ public class AssertionConsumerServiceResource extends SSOResource {
// If invalid, redirect back to main page to re-attempt authentication
catch (GuacamoleException e) {
logger.warn("Authentication attempted with an invalid SAML response: {}", e.getMessage());
logger.debug("Received SAML response failed validation.", e);
logger.warn("Authentication attempted with an invalid SAML response: {}", e.getMessage(), e);
return Response.seeOther(guacBase).build();
}
@@ -351,16 +351,16 @@ public class SSLClientAuthenticationResource extends SSOResource {
}
catch (GuacamoleClientException e) {
logger.warn("SSL/TLS client authentication attempt rejected: {}", e.getMessage());
logger.debug("SSL/TLS client authentication failed.", e);
logger.warn("SSL/TLS client authentication attempt rejected: {}",
e.getMessage(), e);
}
catch (GuacamoleException e) {
logger.error("SSL/TLS client authentication attempt could not be processed: {}", e.getMessage());
logger.debug("SSL/TLS client authentication failed.", e);
logger.error("SSL/TLS client authentication attempt could not be "
+ "processed: {}", e.getMessage(), e);
}
catch (RuntimeException | Error e) {
logger.error("SSL/TLS client authentication attempt failed internally: {}", e.getMessage());
logger.debug("Internal failure processing SSL/TLS client authentication attempt.", e);
logger.error("SSL/TLS client authentication attempt failed "
+ "internally: {}", e.getMessage(), e);
}
return sessionManager.generateInvalid();
@@ -128,8 +128,7 @@ public class UserVerificationService {
// If key is not valid base32, warn but otherwise pretend the key does
// not exist
catch (IllegalArgumentException e) {
logger.warn("TOTP key of user \"{}\" is not valid base32.", self.getIdentifier());
logger.debug("TOTP key is not valid base32.", e);
logger.warn("TOTP key of user \"{}\" is not valid base32.", self.getIdentifier(), e);
return null;
}
@@ -218,9 +217,7 @@ public class UserVerificationService {
+ "lack permission to update their own account and the "
+ "TOTP extension was unable to obtain privileged access. "
+ "TOTP will be disabled for this user.",
self.getIdentifier());
logger.debug("Permission denied to set TOTP key of user "
+ "account.", e);
self.getIdentifier(), e);
return false;
}
catch (GuacamoleUnsupportedException e) {
@@ -422,8 +419,7 @@ public class UserVerificationService {
}
catch (InvalidKeyException e) {
logger.warn("User \"{}\" is associated with an invalid TOTP key.", username);
logger.debug("TOTP key is not valid.", e);
logger.warn("User \"{}\" is associated with an invalid TOTP key.", username, e);
}
// Provided code is not valid
@@ -147,8 +147,8 @@ public class HistoryConnectionRecord extends DelegatingConnectionRecord {
}
catch (IOException e) {
logger.warn("Possible session recording \"{}\" could not be "
+ "identified as it cannot be read: {}", file, e.getMessage());
logger.debug("Possible session recording \"{}\" could not be read.", file, e);
+ "identified as it cannot be read: {}",
file, e.getMessage(), e);
}
finally {
@@ -161,9 +161,7 @@ public class HistoryConnectionRecord extends DelegatingConnectionRecord {
catch (IOException e) {
logger.warn("Unexpected error closing recording file \"{}\": {}",
file, e.getMessage());
logger.debug("Session recording file \"{}\" could not be closed.",
file, e);
file, e.getMessage(), e);
}
}
@@ -297,8 +295,9 @@ public class HistoryConnectionRecord extends DelegatingConnectionRecord {
.array());
}
catch (MalformedURLException e) {
logger.warn("Ignoring file \"{}\" as a unique URL and UUID for that file could not be generated: {}", e.getMessage());
logger.debug("URL for file \"{}\" could not be determined.", file, e);
logger.warn("Ignoring file \"{}\" as a unique URL and UUID for "
+ "that file could not be generated: {}",
e.getMessage(), e);
return;
}
@@ -155,15 +155,12 @@ public class KsmAttributeService implements VaultAttributeService {
catch (GuacamoleException e) {
logger.warn(
"Unable to determine if KSM user attributes "
+ "should be exposed due to config parsing error: {}.", e.getMessage());
logger.debug(
"Config parsing error prevented checking user attribute configuration",
e);
// If the configuration can't be parsed, default to not exposing the attributes
// If the configuration can't be parsed, default to not exposing
// the attributes
logger.warn("Unable to determine if KSM user attributes should be "
+ "exposed due to config parsing error: {}.", e.getMessage(), e);
return Collections.emptyList();
}
}
@@ -781,7 +781,7 @@ public class KsmClient {
// Show the warning only if there is no fallback function
// and this was the last attempt
logger.warn("Keeper notation \"{}\" could not be resolved "
+ "to a record: {}", notation, e.getMessage());
+ "to a record: {}", notation, e.getMessage(), e);
return CompletableFuture.completedFuture(null);
}
@@ -87,13 +87,10 @@ import com.google.inject.assistedinject.AssistedInject;
boolean userKsmConfigEnabled = false;
try {
userKsmConfigEnabled = configurationService.getAllowUserConfig();
} catch (GuacamoleException e) {
logger.warn(
"Disabling user KSM config due to exception: {}"
, e.getMessage());
logger.debug("Error looking up if user KSM config is enabled.", e);
}
catch (GuacamoleException e) {
logger.warn("Disabling user KSM config due to exception: {}",
e.getMessage(), e);
}
// If user-specific KSM configuration is not enabled, do not expose the
@@ -112,4 +109,4 @@ import com.google.inject.assistedinject.AssistedInject;
return attributes;
}
}
}