mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-641: Manually extract password value from KeeperRecord.
Simply calling getPassword() does not currently work correctly, as the implementation of getPassword() assumes there will be at least one value if the field is present. This results in an ArrayIndexOutOfBoundsException for records with empty passwords: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:659) at java.util.ArrayList.get(ArrayList.java:435) at com.keepersecurity.secretsManager.core.KeeperRecord.getPassword(SecretsManager.kt:134) ...
This commit is contained in:
@@ -25,6 +25,7 @@ import com.keepersecurity.secretsManager.core.KeeperRecordData;
|
||||
import com.keepersecurity.secretsManager.core.KeyPair;
|
||||
import com.keepersecurity.secretsManager.core.KeyPairs;
|
||||
import com.keepersecurity.secretsManager.core.Login;
|
||||
import com.keepersecurity.secretsManager.core.Password;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -73,7 +74,19 @@ public class KsmRecordService {
|
||||
* has no associated password.
|
||||
*/
|
||||
public String getPassword(KeeperRecord record) {
|
||||
return record.getPassword();
|
||||
|
||||
KeeperRecordData data = record.getData();
|
||||
|
||||
Password passwordField = (Password) data.getField(Password.class);
|
||||
if (passwordField == null)
|
||||
return null;
|
||||
|
||||
List<String> values = passwordField.getValue();
|
||||
if (values.size() != 1)
|
||||
return null;
|
||||
|
||||
return values.get(0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user