getConnectionCredentials method
Returns credentials for the process running the client that owns name
.
Implementation
Future<DBusProcessCredentials> getConnectionCredentials(String name) async {
var result = await callMethod(
destination: 'org.freedesktop.DBus',
path: DBusObjectPath('/org/freedesktop/DBus'),
interface: 'org.freedesktop.DBus',
name: 'GetConnectionCredentials',
values: [DBusString(name)],
replySignature: DBusSignature('a{sv}'));
var credentials = (result.returnValues[0] as DBusDict).mapStringVariant();
int? unixUserId;
List<int>? unixGroupIds;
int? processId;
String? windowsSid;
List<int>? linuxSecurityLabel;
var otherCredentials = <String, DBusValue>{};
credentials.forEach((key, value) {
switch (key) {
case 'UnixUserID':
if (value.signature != DBusSignature('u')) {
throw 'org.freedesktop.DBus.GetConnectionCredentials returned invalid signature on UnixUserID: ${value.signature.value}';
}
unixUserId = (value as DBusUint32).value;
break;
case 'UnixGroupIDs':
if (value.signature != DBusSignature('au')) {
throw 'org.freedesktop.DBus.GetConnectionCredentials returned invalid signature on UnixGroupIDs: ${value.signature.value}';
}
unixGroupIds = (value as DBusArray).mapUint32().toList();
break;
case 'ProcessID':
if (value.signature != DBusSignature('u')) {
throw 'org.freedesktop.DBus.GetConnectionCredentials returned invalid signature on ProcessID: ${value.signature.value}';
}
processId = (value as DBusUint32).value;
break;
case 'WindowsSID':
if (value.signature != DBusSignature('s')) {
throw 'org.freedesktop.DBus.GetConnectionCredentials returned invalid signature on WindowsSID: ${value.signature.value}';
}
windowsSid = (value as DBusString).value;
break;
case 'LinuxSecurityLabel':
if (value.signature != DBusSignature('ay')) {
throw 'org.freedesktop.DBus.GetConnectionCredentials returned invalid signature on LinuxSecurityLabel: ${value.signature.value}';
}
linuxSecurityLabel = (value as DBusArray).mapByte().toList();
break;
default:
otherCredentials[key] = value;
break;
}
});
return DBusProcessCredentials(
unixUserId: unixUserId,
unixGroupIds: unixGroupIds,
processId: processId,
windowsSid: windowsSid,
linuxSecurityLabel: linuxSecurityLabel,
otherCredentials: otherCredentials);
}