[gnome-shell/wip/smartcard: 3/3] gdm: add code to use settings-daemon smartcard service
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/smartcard: 3/3] gdm: add code to use settings-daemon smartcard service
- Date: Tue, 11 Jun 2013 14:11:52 +0000 (UTC)
commit 2a9569064aea210e41fc1b18533f0feb2c91b94b
Author: Ray Strode <rstrode redhat com>
Date: Thu May 30 10:18:51 2013 -0400
gdm: add code to use settings-daemon smartcard service
gnome-settings-daemon monitors smartcard insertion and removal
events on the system and then exports a model of the current
smartcard topology over the bus using the D-Bus ObjectManager interface.
This commit adds the support code needed in gnome-shell to talk to
the gnome-settings-daemon service.
A future commit will use this code to inform the login screen
when a user inserts a smartcard (so it can react appropriately)
js/Makefile.am | 1 +
js/gdm/loginDialog.js | 2 +
js/gdm/smartcard.js | 89 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 92 insertions(+), 0 deletions(-)
---
diff --git a/js/Makefile.am b/js/Makefile.am
index d888fb9..418940b 100644
--- a/js/Makefile.am
+++ b/js/Makefile.am
@@ -22,6 +22,7 @@ nobase_dist_js_DATA = \
gdm/loginDialog.js \
gdm/powerMenu.js \
gdm/realmd.js \
+ gdm/smartcard.js \
gdm/util.js \
extensionPrefs/main.js \
misc/config.js \
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index cbc652b..955d352 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -35,6 +35,7 @@ const Gdm = imports.gi.Gdm;
const Batch = imports.gdm.batch;
const GdmUtil = imports.gdm.util;
+const Smartcard = imports.gdm.smartcard;
const Main = imports.ui.main;
const ModalDialog = imports.ui.modalDialog;
const Tweener = imports.ui.tweener;
@@ -484,6 +485,7 @@ const LoginDialog = new Lang.Class({
this._userManager = AccountsService.UserManager.get_default()
this._greeterClient = new Gdm.Client();
+ this._smartcardManager = new Smartcard.SmartcardManager();
if (GLib.getenv('GDM_GREETER_TEST') != '1') {
this._greeter = this._greeterClient.get_greeter_sync(null);
diff --git a/js/gdm/smartcard.js b/js/gdm/smartcard.js
new file mode 100644
index 0000000..1821670
--- /dev/null
+++ b/js/gdm/smartcard.js
@@ -0,0 +1,89 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+
+const Gio = imports.gi.Gio;
+const Lang = imports.lang;
+const Shell = imports.gi.Shell;
+const Signals = imports.signals;
+
+const ObjectManager = imports.misc.objectManager;
+
+const _SMARTCARD_SERVICE_DBUS_NAME = "org.gnome.SettingsDaemon.Smartcard";
+
+const SmartcardManagerIface = <interface name="org.gnome.Smartcard.Manager">
+ <method name="GetLoginToken">
+ <arg name="token" type="o" direction="out"/>
+ </method>
+ <method name="GetInsertedTokens">
+ <arg name="tokens" type="ao" direction="out"/>
+ </method>
+</interface>;
+
+const SmartcardTokenIface = <interface name="org.gnome.Smartcard.Token">
+ <property name="Name" type="s" access="read"/>
+ <property name="Driver" type="o" access="read"/>
+ <property name="IsInserted" type="b" access="read"/>
+ <property name="UsedToLogin" type="b" access="read"/>
+</interface>;
+
+const SmartcardDriverIface = <interface name="org.gnome.Smartcard.Driver">
+ <property name="Library" type="s" access="read"/>
+ <property name="Description" type="s" access="read"/>
+</interface>;
+
+const SmartcardManager = new Lang.Class({
+ Name: 'SmartcardManager',
+ _init: function() {
+ this._objectManager = new ObjectManager.ObjectManager({ connection: Gio.DBus.session,
+ name: _SMARTCARD_SERVICE_DBUS_NAME,
+ objectPath:
'/org/gnome/SettingsDaemon/Smartcard',
+ knownInterfaces: [ SmartcardManagerIface,
+ SmartcardTokenIface,
+ SmartcardDriverIface ],
+ onLoaded: Lang.bind(this, this._onLoaded) });
+ this._tokens = {};
+ },
+
+ _onLoaded: function() {
+ let tokens = this._objectManager.getProxiesForInterface('org.gnome.Smartcard.Token');
+
+ for (let i = 0; i < tokens.length; i++)
+ this._addToken(tokens[i]);
+
+ this._objectManager.connect('interface-added', Lang.bind(this, function(interfaceName, proxy) {
+ if (interfaceName == 'org.gnome.Smartcard.Token')
+ this._addToken(proxy);
+ }));
+
+ this._objectManager.connect('interface-removed', Lang.bind(this, function(interfaceName, proxy) {
+ if (interfaceName == 'org.gnome.Smartcard.Token')
+ this._removeToken(proxy);
+ }));
+ },
+
+ _addToken: function(token) {
+ if (this._tokens[token.get_object_path()])
+ return;
+
+ this._tokens[token.get_object_path()] = token;
+
+ token.connect('g-properties-changed',
+ Lang.bind(this, function(proxy, properties) {
+ if ('IsInserted' in properties.deep_unpack()) {
+ if (token.IsInserted)
+ this.emit('token-inserted', token.Name);
+ else
+ this.emit('token-removed', token.Name);
+ }
+ }));
+ },
+
+ _removeToken: function(token) {
+ if (!this._tokens[token.get_object_path()])
+ return;
+
+ token.disconnectAll();
+ delete this._tokens[token.get_object_path()];
+ }
+});
+Signals.addSignalMethods(SmartcardManager.prototype);
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]