Skip to content

Commit 5f5a056

Browse files
authored
GUACAMOLE-2030: Merge changes showing KSM warnings only if all retrieval attempts fail.
2 parents 1b73d49 + ffa8b2c commit 5f5a056

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/secret/KsmClient.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,14 +656,17 @@ public Future<String> getSecret(
656656
// There is no way to differentiate if an error is caused by
657657
// a non-existing record or a pure parse failure.
658658
catch (Error | Exception e) {
659-
logger.warn("Keeper notation \"{}\" could not be resolved "
660-
+ "to a record: {}", notation, e.getMessage());
661659
logger.debug("Retrieval of record by Keeper notation failed.", e);
662660

663661
// If the secret is not found, invoke the fallback function
664662
if (fallbackFunction != null)
665663
return fallbackFunction.get();
666664

665+
// Show the warning only if there is no fallback function
666+
// and this was the last attempt
667+
logger.warn("Keeper notation \"{}\" could not be resolved "
668+
+ "to a record: {}", notation, e.getMessage());
669+
667670
return CompletableFuture.completedFuture(null);
668671
}
669672
finally {

extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/secret/KsmSecretService.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,21 @@ public Future<String> getValue(UserContext userContext, Connectable connectable,
152152
// Attempt to find a KSM config for this connection or group
153153
String ksmConfig = getConnectionGroupKsmConfig(userContext, connectable);
154154

155+
// Get the user-supplied KSM config, if allowed by config and
156+
// set by the user
157+
String userKsmConfig = getUserKSMConfig(userContext, connectable);
158+
159+
// If the user config is not defined or happens to be the same
160+
// as admin-defined one, resolve without the fallback
161+
if (userKsmConfig == null || Objects.equal(userKsmConfig, ksmConfig)) {
162+
return getClient(ksmConfig).getSecret(name);
163+
}
164+
155165
return getClient(ksmConfig).getSecret(name, new GuacamoleExceptionSupplier<Future<String>>() {
156166

157167
@Override
158168
public Future<String> get() throws GuacamoleException {
159-
160-
// Get the user-supplied KSM config, if allowed by config and
161-
// set by the user
162-
String userKsmConfig = getUserKSMConfig(userContext, connectable);
163-
164-
// If the user config happens to be the same as admin-defined one,
165-
// don't bother trying again
166-
if (userKsmConfig != null && !Objects.equal(userKsmConfig, ksmConfig))
167-
return getClient(userKsmConfig).getSecret(name);
168-
169-
return CompletableFuture.completedFuture(null);
169+
return getClient(userKsmConfig).getSecret(name);
170170
}
171171

172172
});

0 commit comments

Comments
 (0)