GUACAMOLE-1868: Merge support for new PAM Hostname field in KSM extension.

This commit is contained in:
Virtually Nick
2023-10-19 21:26:29 -04:00
committed by GitHub

View File

@@ -30,6 +30,7 @@ import com.keepersecurity.secretsManager.core.KeeperRecordField;
import com.keepersecurity.secretsManager.core.KeyPair; import com.keepersecurity.secretsManager.core.KeyPair;
import com.keepersecurity.secretsManager.core.KeyPairs; import com.keepersecurity.secretsManager.core.KeyPairs;
import com.keepersecurity.secretsManager.core.Login; import com.keepersecurity.secretsManager.core.Login;
import com.keepersecurity.secretsManager.core.PamHostnames;
import com.keepersecurity.secretsManager.core.Password; import com.keepersecurity.secretsManager.core.Password;
import com.keepersecurity.secretsManager.core.SecretsManager; import com.keepersecurity.secretsManager.core.SecretsManager;
import com.keepersecurity.secretsManager.core.Text; import com.keepersecurity.secretsManager.core.Text;
@@ -393,9 +394,11 @@ public class KsmRecordService {
/** /**
* Returns the single hostname (or address) associated with the given * Returns the single hostname (or address) associated with the given
* record. If the record has no associated hostname, or multiple hostnames, * record. If the record has no associated hostname, or multiple hostnames,
* null is returned. Hostnames are retrieved from "Hosts" fields, as well * null is returned. Hostnames are retrieved from "Hosts" or "PamHostnames"
* as "Text" and "Hidden" fields that have the label "hostname", "address", * fields, as well as "Text" and "Hidden" fields that have the label
* or "ip address" (case-insensitive, space optional). * "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 * @param record
* The record to retrieve the hostname from. * The record to retrieve the hostname from.
@@ -411,6 +414,11 @@ public class KsmRecordService {
if (hostsField != null) if (hostsField != null)
return getSingleStringValue(hostsField.getValue(), Host::getHostName); 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(); KeeperRecordData data = record.getData();
List<KeeperRecordField> custom = data.getCustom(); List<KeeperRecordField> custom = data.getCustom();