jmuehlner commented on code in PR #739:
URL: https://github.com/apache/guacamole-client/pull/739#discussion_r911410099
##########
extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/secret/KsmSecretService.java:
##########
@@ -153,24 +180,82 @@ private void addRecordTokens(Map<String, Future<String>>
tokens, String prefix,
}
+ /**
+ * Search for a KSM configuration attribute, recursing up the connection
group tree
+ * until a connection group with the appropriate attribute is found. If
the KSM config
+ * is found, it will be returned. If not, null will be returned.
+ *
+ * @param userContext
+ * The userContext associated with the connection or connection group.
+ *
+ * @param connectable
+ * A connection or connection group for which the tokens are being
replaced.
+ *
+ * @return
+ * The value of the KSM configuration attribute if found in the tree,
null otherwise.
+ *
+ * @throws GuacamoleException
+ * If an error occurs while attempting to retrieve the KSM config
attribute.
+ */
+ private String getConnectionGroupKsmConfig(
+ UserContext userContext, Connectable connectable) throws
GuacamoleException {
+
+ // Check to make sure it's a usable type before proceeding
+ if (
+ !(connectable instanceof Connection)
+ && !(connectable instanceof ConnectionGroup)) {
+ logger.warn(
+ "Unsupported Connectable type: {}; skipping KSM config
lookup.",
+ connectable.getClass());
+ return null;
+ }
+
+ // For connections, start searching the parent group for the KSM config
+ // For connection groups, start searching the group directly
+ String parentIdentifier = (connectable instanceof Connection)
+ ? ((Connection) connectable).getParentIdentifier()
+ : ((ConnectionGroup) connectable).getIdentifier();
+
+ Directory<ConnectionGroup> connectionGroupDirectory =
userContext.getConnectionGroupDirectory();
+ while
(connectionGroupDirectory.getIdentifiers().contains(parentIdentifier)) {
+
+ // Fetch the parent group
+ ConnectionGroup group =
connectionGroupDirectory.get(parentIdentifier);
Review Comment:
Good call - will do.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]