mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-1795: Merge support new private key field name for KSM Pam User.
This commit is contained in:
@@ -87,9 +87,16 @@ public class KsmRecordService {
|
|||||||
* Regular expression which matches the labels of custom fields containing
|
* Regular expression which matches the labels of custom fields containing
|
||||||
* private keys.
|
* private keys.
|
||||||
*/
|
*/
|
||||||
private static final Pattern PRIVATE_KEY_LABEL_PATTERN =
|
private static final Pattern PRIVATE_KEY_CUSTOM_LABEL_PATTERN =
|
||||||
Pattern.compile("private\\s*key", Pattern.CASE_INSENSITIVE);
|
Pattern.compile("private\\s*key", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regular expression which matches the labels of standard fields containing
|
||||||
|
* private keys.
|
||||||
|
*/
|
||||||
|
private static final Pattern PRIVATE_KEY_STANDARD_LABEL_PATTERN =
|
||||||
|
Pattern.compile("private\\s*pem\\s*key", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regular expression which matches the filenames of private keys attached
|
* Regular expression which matches the filenames of private keys attached
|
||||||
* to Keeper records.
|
* to Keeper records.
|
||||||
@@ -523,9 +530,11 @@ public class KsmRecordService {
|
|||||||
* has no associated private key, or multiple private keys, null is
|
* has no associated private key, or multiple private keys, null is
|
||||||
* returned. Private keys are retrieved from "KeyPairs" fields.
|
* returned. Private keys are retrieved from "KeyPairs" fields.
|
||||||
* Alternatively, private keys are retrieved from PEM-type attachments or
|
* Alternatively, private keys are retrieved from PEM-type attachments or
|
||||||
* custom fields with the label "private key" (case-insensitive, space
|
* standard "Hidden" fields with the label "private pem key", or custom
|
||||||
* optional) if they are "KeyPairs", "Password", or "Hidden" fields. If
|
* fields with the label "private key" if they are "KeyPairs", "Password",
|
||||||
* file downloads are required, they will be performed asynchronously.
|
* or "Hidden" fields. All label matching is case-insensitive, with spaces
|
||||||
|
* between words being optional. If file downloads are required, they will
|
||||||
|
* be performed asynchronously.
|
||||||
*
|
*
|
||||||
* @param record
|
* @param record
|
||||||
* The record to retrieve the private key from.
|
* The record to retrieve the private key from.
|
||||||
@@ -538,7 +547,8 @@ public class KsmRecordService {
|
|||||||
public Future<String> getPrivateKey(KeeperRecord record) {
|
public Future<String> getPrivateKey(KeeperRecord record) {
|
||||||
|
|
||||||
// Attempt to find single matching keypair field
|
// Attempt to find single matching keypair field
|
||||||
KeyPairs keyPairsField = getField(record, KeyPairs.class, PRIVATE_KEY_LABEL_PATTERN);
|
KeyPairs keyPairsField = getField(
|
||||||
|
record, KeyPairs.class, PRIVATE_KEY_CUSTOM_LABEL_PATTERN);
|
||||||
if (keyPairsField != null) {
|
if (keyPairsField != null) {
|
||||||
String privateKey = getSingleStringValue(keyPairsField.getValue(), KeyPair::getPrivateKey);
|
String privateKey = getSingleStringValue(keyPairsField.getValue(), KeyPair::getPrivateKey);
|
||||||
if (privateKey != null && !privateKey.isEmpty())
|
if (privateKey != null && !privateKey.isEmpty())
|
||||||
@@ -553,13 +563,21 @@ public class KsmRecordService {
|
|||||||
KeeperRecordData data = record.getData();
|
KeeperRecordData data = record.getData();
|
||||||
List<KeeperRecordField> custom = data.getCustom();
|
List<KeeperRecordField> custom = data.getCustom();
|
||||||
|
|
||||||
// Use password "private key" custom field as fallback ...
|
// Use a hidden "private pem key" standard field as fallback ...
|
||||||
Password passwordField = getField(custom, Password.class, PRIVATE_KEY_LABEL_PATTERN);
|
HiddenField hiddenField = getField(
|
||||||
|
data.getFields(), HiddenField.class, PRIVATE_KEY_STANDARD_LABEL_PATTERN);
|
||||||
|
if (hiddenField != null)
|
||||||
|
return CompletableFuture.completedFuture(getSingleStringValue(hiddenField.getValue()));
|
||||||
|
|
||||||
|
// ... or password "private key" custom field ...
|
||||||
|
Password passwordField = getField(
|
||||||
|
custom, Password.class, PRIVATE_KEY_CUSTOM_LABEL_PATTERN);
|
||||||
if (passwordField != null)
|
if (passwordField != null)
|
||||||
return CompletableFuture.completedFuture(getSingleStringValue(passwordField.getValue()));
|
return CompletableFuture.completedFuture(getSingleStringValue(passwordField.getValue()));
|
||||||
|
|
||||||
// ... or hidden "private key" custom field
|
// ... or hidden "private key" custom field
|
||||||
HiddenField hiddenField = getField(custom, HiddenField.class, PRIVATE_KEY_LABEL_PATTERN);
|
hiddenField = getField(
|
||||||
|
custom, HiddenField.class, PRIVATE_KEY_CUSTOM_LABEL_PATTERN);
|
||||||
if (hiddenField != null)
|
if (hiddenField != null)
|
||||||
return CompletableFuture.completedFuture(getSingleStringValue(hiddenField.getValue()));
|
return CompletableFuture.completedFuture(getSingleStringValue(hiddenField.getValue()));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user