From ea4d6edd1ca12128153ef28e6f1fa0b778d8dec6 Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Fri, 20 Oct 2023 00:05:33 +0000 Subject: [PATCH] GUACAMOLE-1868: Add support for new PAM Hostname field. --- .../vault/ksm/secret/KsmRecordService.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/secret/KsmRecordService.java b/extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/secret/KsmRecordService.java index 8e363f3b96..d22f703a7c 100644 --- a/extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/secret/KsmRecordService.java +++ b/extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/secret/KsmRecordService.java @@ -30,6 +30,7 @@ import com.keepersecurity.secretsManager.core.KeyPair; import com.keepersecurity.secretsManager.core.KeyPairs; import com.keepersecurity.secretsManager.core.Login; +import com.keepersecurity.secretsManager.core.PamHostnames; import com.keepersecurity.secretsManager.core.Password; import com.keepersecurity.secretsManager.core.SecretsManager; import com.keepersecurity.secretsManager.core.Text; @@ -393,9 +394,11 @@ public Future download(final KeeperFile file) { /** * Returns the single hostname (or address) associated with the given * record. If the record has no associated hostname, or multiple hostnames, - * null is returned. Hostnames are retrieved from "Hosts" fields, as well - * as "Text" and "Hidden" fields that have the label "hostname", "address", - * or "ip address" (case-insensitive, space optional). + * null is returned. Hostnames are retrieved from "Hosts" or "PamHostnames" + * fields, as well as "Text" and "Hidden" fields that have the label + * "hostname", "address", or "ip address" (case-insensitive, space optional). + * These field types are checked in the above order, and the first matching + * field is returned. * * @param record * The record to retrieve the hostname from. @@ -411,6 +414,11 @@ public String getHostname(KeeperRecord record) { if (hostsField != null) return getSingleStringValue(hostsField.getValue(), Host::getHostName); + // Next, try a PAM hostname + PamHostnames pamHostsField = getField(record, PamHostnames.class, null); + if (pamHostsField != null) + return getSingleStringValue(pamHostsField.getValue(), Host::getHostName); + KeeperRecordData data = record.getData(); List custom = data.getCustom();