jmuehlner commented on code in PR #751:
URL: https://github.com/apache/guacamole-client/pull/751#discussion_r976870010
##########
extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/user/KsmDirectoryService.java:
##########
@@ -222,6 +231,37 @@ public void processAttributes(Attributes entity) throws
GuacamoleException {
}
+ @Override
+ public Directory<Connection> getConnectionDirectory(
+ Directory<Connection> underlyingDirectory) throws
GuacamoleException {
+
+ // A Connection directory that will decorate all connections with a
+ // KsmConnection wrapper to ensure that all defined KSM fields will
+ // be exposed in the connection group attributes.
+ return new DecoratingDirectory<Connection>(underlyingDirectory) {
+
+ @Override
+ protected Connection decorate(Connection connection) throws
GuacamoleException {
+
+ // Wrap in a KsmConnection class to ensure that all defined
KSM fields will be
+ // present
+ return new KsmConnection(
+ connection,
+
ksmAttributeService.getConnectionAttributes().stream().flatMap(
+ form -> form.getFields().stream().map(field ->
field.getName())
+ ).collect(Collectors.toList()));
Review Comment:
Yeah, that would make more sense.
##########
extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/user/KsmDirectoryService.java:
##########
@@ -269,4 +309,55 @@ protected ConnectionGroup undecorate(ConnectionGroup
connectionGroup) throws Gua
};
}
+
+ @Override
+ public Directory<User> getUserDirectory(
+ Directory<User> underlyingDirectory) throws GuacamoleException {
+
+ // A User directory that will intercept add and update calls to
+ // validate KSM configurations, and translate one-time-tokens, if
possible
+ // Additionally, this directory will will decorate all users with a
+ // KsmUser wrapper to ensure that all defined KSM fields will be
exposed
+ // in the user attributes.
+ return new DecoratingDirectory<User>(underlyingDirectory) {
+
+ @Override
+ public void add(User user) throws GuacamoleException {
+
+ // Check for the KSM config attribute and translate the
one-time token
+ // if possible before adding
+ processAttributes(user);
+ super.add(user);
+ }
+
+ @Override
+ public void update(User user) throws GuacamoleException {
+
+ // Check for the KSM config attribute and translate the
one-time token
+ // if possible before updating
+ processAttributes(user);
+ super.update(user);
+ }
+
+ @Override
+ protected User decorate(User user) throws GuacamoleException {
+
+ // Wrap in a KsmUser class to ensure that all defined KSM
fields will be
+ // present
+ return new KsmUser(
+ user,
+
ksmAttributeService.getUserAttributes().stream().flatMap(
+ form -> form.getFields().stream().map(field ->
field.getName())
+ ).collect(Collectors.toList()));
Review Comment:
Yes
--
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]