Merge branch 'master' into debian
authorSam Hartman <hartmans@painless-security.com>
Mon, 30 Sep 2013 17:38:16 +0000 (13:38 -0400)
committerSam Hartman <hartmans@painless-security.com>
Mon, 30 Sep 2013 17:38:16 +0000 (13:38 -0400)
18 files changed:
Makefile.am
configure.ac
libmoonshot/libmoonshot-dbus.c
libmoonshot/libmoonshot.h
libmoonshot/libmoonshot.vapi
moonshot-ui.spec.in
src/moonshot-add-dialog.vala
src/moonshot-id.vala
src/moonshot-idcard-store.vala
src/moonshot-identities-manager.vala
src/moonshot-identity-management-view.vala
src/moonshot-identity-manager-app.vala
src/moonshot-keyring-store.vala [new file with mode: 0644]
src/moonshot-local-flat-file-store.vala
src/moonshot-password-dialog.vala
src/moonshot-server.vala
src/moonshot-webp-parser.vala
vapi/moonshot-gnome-keyring.vapi [new file with mode: 0644]

index 0798d86..7857056 100644 (file)
@@ -40,6 +40,7 @@ src_moonshot_SOURCES = \
         src/moonshot-identity-manager-app.vala \
         src/moonshot-identity-management-view.vala \
         src/moonshot-local-flat-file-store.vala \
+        src/moonshot-keyring-store.vala \
         src/moonshot-idcard-store.vala \
         src/moonshot-id.vala \
         src/moonshot-add-dialog.vala \
@@ -65,6 +66,7 @@ src_moonshot_LDFLAGS = -g -O0
 src_moonshot_webp_VALAFLAGS = --vapidir=$(top_srcdir)/libmoonshot  --pkg gtk+-2.0 --pkg gdk-2.0 --pkg libmoonshot $(AM_VALAFLAGS)
 src_moonshot_webp_CPPFLAGS = $(moonshot_CFLAGS) $(AM_CPPFLAGS)
 src_moonshot_webp_LDADD = $(moonshot_LIBS) ${top_builddir}/libmoonshot/libmoonshot.la
+src_moonshot_webp_LDFLAGS =
 
 if OS_WIN32
 
@@ -95,6 +97,11 @@ endif
 
 if OS_LINUX
 
+AM_CPPFLAGS += -I/usr/include/gnome-keyring-1
+AM_VALAFLAGS += --pkg moonshot-gnome-keyring --define=GNOME_KEYRING
+src_moonshot_LDFLAGS += -lgnome-keyring
+src_moonshot_webp_LDFLAGS += -lgnome-keyring
+
 ## Installing mime type data
 mimedir = $(datadir)/mime/packages
 mime_DATA = webprovisioning/moonshot.xml
@@ -110,7 +117,7 @@ if IPC_MSRPC
 AM_CPPFLAGS += -Isrc
 
 AM_VALAFLAGS += \
-       --pkg moonshot-msrpc.vapi --pkg msrpc-1.0 \
+       --pkg moonshot-msrpc --pkg msrpc-1.0 \
        --define=IPC_MSRPC
 
 BUILT_SOURCES = libmoonshot/moonshot-msrpc.h \
index 7004167..6425db2 100644 (file)
@@ -1,6 +1,6 @@
 AC_PREREQ([2.63])
 AC_INIT([Moonshot-ui],
-        [0.5],
+        [0.6],
         [moonshot-community@jiscmail.ac.uk],
         [moonshot-ui],
         [http://www.project-moonshot.org/])
index 3dffeba..97dba1e 100644 (file)
@@ -351,6 +351,7 @@ int moonshot_install_id_card (const char     *display_name,
                               const char     *subject,
                               const char     *subject_alt,
                               const char     *server_cert,
+                              int            force_flat_file_store,
                               MoonshotError **error)
 {
     GError      *g_error = NULL;
@@ -400,6 +401,7 @@ int moonshot_install_id_card (const char     *display_name,
                        G_TYPE_STRING, subject,
                        G_TYPE_STRING, subject_alt,
                        G_TYPE_STRING, server_cert,
+                       G_TYPE_INT, force_flat_file_store,
                        G_TYPE_INVALID,
                        G_TYPE_BOOLEAN, &success,
                        G_TYPE_INVALID);
index 670dd87..d7830c2 100644 (file)
@@ -184,6 +184,7 @@ int moonshot_install_id_card (const char     *display_name,
                               const char     *subject,
                               const char     *subject_alt,
                               const char     *server_cert,
+                              int             force_flat_file_store,
                               MoonshotError **error);
 
 #endif
index d927663..8662596 100644 (file)
@@ -49,5 +49,6 @@ namespace Moonshot {
                                  string? subject,
                                  string? subject_alt,
                                  string? server_cert,
+                                 int force_flat_file_store,
                                  out Moonshot.Error error);
 }
index db824f1..d4f859f 100644 (file)
@@ -1,6 +1,6 @@
 Name:           @PACKAGE@
 Version:        @VERSION@
-Release:        2%{?dist}
+Release:        1%{?dist}
 Summary:        Moonshot Federated Identity User Interface
 
 Group:          Security Tools
index 44ac597..141f788 100644 (file)
@@ -6,6 +6,7 @@ class AddIdentityDialog : Dialog
     private Entry issuer_entry;
     private Entry username_entry;
     private Entry password_entry;
+    private CheckButton remember_checkbutton;
     
     public string display_name {
         get { return displayname_entry.get_text(); }
@@ -23,6 +24,10 @@ class AddIdentityDialog : Dialog
         get { return password_entry.get_text (); }
     }
 
+    public bool store_password {
+        get { return remember_checkbutton.active; }
+    }
+
     public AddIdentityDialog ()
     {
         this.set_title (_("Add ID Card"));
@@ -52,7 +57,7 @@ class AddIdentityDialog : Dialog
         this.password_entry = new Entry ();
         password_entry.set_invisible_char ('*');
         password_entry.set_visibility (false);
-        var remember_checkbutton = new CheckButton.with_label (_("Remember password"));
+        this.remember_checkbutton = new CheckButton.with_label (_("Remember password"));
 
         set_atk_relation (displayname_label, displayname_entry, Atk.RelationType.LABEL_FOR);
         set_atk_relation (issuer_label, issuer_entry, Atk.RelationType.LABEL_FOR);
index f783810..bc121f5 100644 (file)
@@ -21,7 +21,24 @@ public class IdCard : Object
   public string display_name { get; set; default = ""; }
   
   public string username { get; set; default = ""; }
+#if GNOME_KEYRING
+  private unowned string _password;
+  public string password {
+    get {
+      return (_password!=null) ? _password : "";
+    }
+    set {
+      if (_password != null) {
+        GnomeKeyring.memory_free((void *)_password);
+        _password = null;
+      }
+      if (value != null)
+        _password = GnomeKeyring.memory_strdup(value); 
+    }
+  }
+#else
   public string password { get; set; default = null; }
+#endif
 
   public string issuer { get; set; default = ""; }
   
@@ -34,6 +51,8 @@ public class IdCard : Object
 
   public unowned string nai { get {  _nai = username + "@" + issuer; return _nai;}}
 
+  public bool store_password { get; set; default = false; }
+
   public bool IsNoIdentity() 
   {
     return (display_name == NO_IDENTITY);
@@ -45,4 +64,8 @@ public class IdCard : Object
     card.display_name = NO_IDENTITY;
     return card;
   }
+
+  ~IdCard() {
+    password = null;
+  }
 }
index 8f2f8ec..4303713 100644 (file)
@@ -1,9 +1,15 @@
 using Gee; 
 public interface IIdentityCardStore : Object {
     // Methods
+    public enum StoreType {
+        FLAT_FILE,
+        KEYRING
+    }
+
     public abstract void add_card(IdCard card);
     public abstract void remove_card(IdCard card);
     public abstract void update_card(IdCard card);
+    public abstract StoreType get_store_type();
     public abstract LinkedList<IdCard> get_card_list(); 
 }
 
index 1aa5fe7..501d065 100644 (file)
@@ -1,8 +1,62 @@
 using Gee;
 
+public class Password {
+#if GNOME_KEYRING
+    private unowned string _password;
+    public string password {
+        get {
+            return _password;
+        }
+        set {
+            if (_password != null) {
+                GnomeKeyring.memory_free((void *)_password);
+                _password = null;
+            }
+            if (value != null)
+                _password = GnomeKeyring.memory_strdup(value); 
+        }
+    }
+#else
+    public string password { get; set; default = null; }
+#endif
+
+    public Password(string in_password) {
+        password = in_password;
+    }
+
+    ~Password() {
+        password = null;
+    }
+}
+
+public class PasswordHashTable : Object {
+    private HashTable<string, Password> password_table;
+
+    private static string ComputeHashKey(IdCard card, IIdentityCardStore store) {
+        return "%s_store_%d".printf( card.display_name, store.get_store_type() );
+    }
+
+    public void CachePassword(IdCard card, IIdentityCardStore store) {
+        password_table.replace(ComputeHashKey(card, store), new Password(card.password));
+    }
+
+    public void RemovePassword(IdCard card, IIdentityCardStore store) {
+        password_table.remove(ComputeHashKey(card, store));
+    }
+    public void RetrievePassword(IdCard card, IIdentityCardStore store) {
+        weak Password password = password_table.lookup(ComputeHashKey(card, store));
+        if (password != null) {
+            card.password = password.password;
+        }
+    }
+    public PasswordHashTable() {
+        password_table = new HashTable<string, Password>(GLib.str_hash, GLib.str_equal);
+    }
+}
+
 public class IdentityManagerModel : Object {
     private const string FILE_NAME = "identities.txt";
-
+    private PasswordHashTable password_table;
     private IIdentityCardStore store;
     public LinkedList<IdCard>  get_card_list() {
          var identities = store.get_card_list();
@@ -18,6 +72,11 @@ public class IdentityManagerModel : Object {
          });
          if (identities.is_empty || !identities[0].IsNoIdentity())
              identities.insert(0, IdCard.NewNoIdentity());
+         foreach (IdCard id_card in identities) {
+             if (!id_card.store_password) {
+                 password_table.RetrievePassword(id_card, store);
+             }
+         }
          return identities;
     }
     public signal void card_list_changed();
@@ -49,32 +108,79 @@ public class IdentityManagerModel : Object {
         return true;
     }
 
-    public void add_card(IdCard card) {
+    public void add_card(IdCard card, bool force_flat_file_store) {
         string candidate;
+        IIdentityCardStore.StoreType saved_store_type = get_store_type();
+
+        if (force_flat_file_store)
+            set_store_type(IIdentityCardStore.StoreType.FLAT_FILE);
 
         if (!display_name_is_valid (card.display_name, out candidate))
         {
           card.display_name = candidate;
         }
 
+        if (!card.store_password)
+            password_table.CachePassword(card, store);
         store.add_card(card);
+        set_store_type(saved_store_type);
         card_list_changed();
      }
 
      public void update_card(IdCard card) {
+        if (!card.store_password)
+            password_table.CachePassword(card, store);
+        else
+            password_table.RemovePassword(card, store);
         store.update_card(card);
         card_list_changed();
      }
 
      public void remove_card(IdCard card) {
+        password_table.RemovePassword(card, store);
         store.remove_card(card);
         card_list_changed();
      }
 
+     public void set_store_type(IIdentityCardStore.StoreType type) {
+         if ((store != null) && (store.get_store_type() == type))
+             return;
+         switch (type) {
+#if GNOME_KEYRING
+             case IIdentityCardStore.StoreType.KEYRING:
+                 store = new KeyringStore();
+                 break;
+#endif
+             case IIdentityCardStore.StoreType.FLAT_FILE:
+             default:
+                 store = new LocalFlatFileStore();
+                 break;
+         }
+     }
+
+     public IIdentityCardStore.StoreType get_store_type() {
+         return store.get_store_type();
+     }
+
+     public bool HasNonTrivialIdentities() {
+         foreach (IdCard card in this.store.get_card_list()) {
+             // The 'NoIdentity' card is non-trivial if it has services or rules.
+             // All other cards are automatically non-trivial.
+             if ((!card.IsNoIdentity()) || 
+                 (card.services.length > 0) ||
+                 (card.rules.length > 0)) {
+                 return true;
+             }
+         }
+         return false;
+     }
+
+
     private IdentityManagerApp parent;
 
-    public IdentityManagerModel(IdentityManagerApp parent_app) {
+    public IdentityManagerModel(IdentityManagerApp parent_app, IIdentityCardStore.StoreType store_type) {
         parent = parent_app;
-        store = new LocalFlatFileStore();
+        password_table = new PasswordHashTable();
+        set_store_type(store_type);
     }
 }
index adcf8b4..a6e7955 100644 (file)
@@ -21,6 +21,7 @@ public class IdentityManagerView : Window {
     private Entry password_entry;
     private Label prompting_service;
     private Label no_identity_title;
+    private CheckButton remember_checkbutton;
 
     private ListStore* listmodel;
     private TreeModelFilter filter;
@@ -217,6 +218,7 @@ public class IdentityManagerView : Window {
            this.username_entry.set_text (id_card.username);
            this.password_entry.set_text (id_card.password ?? "");
            this.vbox_right.pack_start(login_vbox, false, true, 0);
+           this.remember_checkbutton.active = id_card.store_password;
        }
        this.vbox_right.pack_start (services_vbox, false, true, 0);
 
@@ -253,6 +255,7 @@ public class IdentityManagerView : Window {
             id_card.issuer = "Issuer";
         id_card.username = dialog.username;
         id_card.password = dialog.password;
+        id_card.store_password = dialog.store_password;
         id_card.services = {};
         id_card.set_data("pixbuf", find_icon ("avatar-default", 48));
 
@@ -306,7 +309,7 @@ public class IdentityManagerView : Window {
         id_card_widget.expanded.connect (fill_details);
     }
 
-    public bool add_identity (IdCard id_card)
+    public bool add_identity (IdCard id_card, bool force_flat_file_store)
     {
 #if OS_MACOS
         /* 
@@ -329,7 +332,7 @@ public class IdentityManagerView : Window {
 
         if (ret == Gtk.ResponseType.YES) {
             id_card.set_data ("pixbuf", find_icon ("avatar-default", 48));
-            this.identities_manager.add_card (id_card);
+            this.identities_manager.add_card (id_card, force_flat_file_store);
             return true;
         }
 
@@ -343,7 +346,7 @@ public class IdentityManagerView : Window {
 
         switch (result) {
         case ResponseType.OK:
-            this.identities_manager.add_card (get_id_card_data (dialog));
+            this.identities_manager.add_card (get_id_card_data (dialog), false);
             break;
         default:
             break;
@@ -423,23 +426,18 @@ public class IdentityManagerView : Window {
         this.request_queue.push_tail (request);
     }
 
-    public void send_identity_cb (IdCard identity)
+    public void check_add_password(IdCard identity, IdentityRequest request, IdentityManagerModel model)
     {
-        return_if_fail (request_queue.length > 0);
-
-       candidates = null;
-        var request = this.request_queue.pop_head ();
-        bool reset_password = false;
-
-        if ((identity.password == null) && !identity.IsNoIdentity())
+        if ((identity.password == "") && !identity.IsNoIdentity())
         {
-            var dialog = new AddPasswordDialog ();
+            var dialog = new AddPasswordDialog (identity, request);
             var result = dialog.run ();
 
             switch (result) {
             case ResponseType.OK:
                 identity.password = dialog.password;
-                reset_password = ! dialog.remember;
+                identity.store_password = dialog.remember;
+                model.update_card(identity);
                 break;
             default:
                 identity = null;
@@ -448,7 +446,15 @@ public class IdentityManagerView : Window {
 
             dialog.destroy ();
         }
+    }
 
+    public void send_identity_cb (IdCard identity)
+    {
+        return_if_fail (request_queue.length > 0);
+
+       candidates = null;
+        var request = this.request_queue.pop_head ();
+        check_add_password(identity, request, identities_manager);
         if (this.request_queue.is_empty())
         {
             candidates = null;
@@ -472,10 +478,6 @@ public class IdentityManagerView : Window {
             parent_app.default_id_card = identity;
 
         request.return_identity (identity);
-
-        if (reset_password)
-            identity.password = null;
-
     }
 
     private void label_make_bold (Label label)
@@ -754,7 +756,7 @@ SUCH DAMAGE.
         this.password_entry = new Entry ();
         password_entry.set_invisible_char ('*');
         password_entry.set_visibility (false);
-        var remember_checkbutton = new CheckButton.with_label (_("Remember password"));
+        this.remember_checkbutton = new CheckButton.with_label (_("Remember password"));
         var login_table = new Table (3, 3, false);
         login_table.set_col_spacings (10);
         login_table.set_row_spacings (10);
index 537ff47..d961141 100644 (file)
@@ -1,10 +1,16 @@
 using Gee;
 using Gtk;
 
+#if IPC_DBUS
 [DBus (name = "org.janet.Moonshot")]
 interface IIdentityManager : GLib.Object {
+#if IPC_DBUS_GLIB
+    public abstract bool show_ui() throws DBus.Error;
+#else
     public abstract bool show_ui() throws IOError;
+#endif
 }
+#endif
 
 public class IdentityManagerApp {
     public IdentityManagerModel model;
@@ -33,8 +39,24 @@ public class IdentityManagerApp {
         if (view != null) view.show();    
     }
        
-    public IdentityManagerApp (bool headless) {
-        model = new IdentityManagerModel(this);
+    public IdentityManagerApp (bool headless, bool use_flat_file_store) {
+#if GNOME_KEYRING
+        bool keyring_available = GnomeKeyring.is_available();
+#else
+        bool keyring_available = false;
+#endif
+        IIdentityCardStore.StoreType store_type;
+        if (headless || use_flat_file_store || !keyring_available)
+            store_type = IIdentityCardStore.StoreType.FLAT_FILE;
+        else
+            store_type = IIdentityCardStore.StoreType.KEYRING;
+
+        model = new IdentityManagerModel(this, store_type);
+        /* if headless, but we have nothing in the flat file store
+         * and keyring is available, switch to keyring */
+        if (headless && keyring_available && !use_flat_file_store && !model.HasNonTrivialIdentities())
+            model.set_store_type(IIdentityCardStore.StoreType.KEYRING);
+
         if (!headless)
             view = new IdentityManagerView(this);
         LinkedList<IdCard> card_list = model.get_card_list() ;
@@ -54,9 +76,9 @@ public class IdentityManagerApp {
 #endif
     }
 
-    public bool add_identity (IdCard id) {
-        if (view != null) return view.add_identity(id);
-        model.add_card(id);
+    public bool add_identity (IdCard id, bool force_flat_file_store) {
+        if (view != null) return view.add_identity(id, force_flat_file_store);
+        model.add_card(id, force_flat_file_store);
         return true;
     }
 
@@ -187,6 +209,9 @@ public class IdentityManagerApp {
         // callback because we may be being called from a 'yield')
         Idle.add(
             () => {
+                if (view != null) {
+                    view.check_add_password(identity, request, model);
+                }
                 request.return_identity (identity);
 // The following occasionally causes the app to exit without sending the dbus
 // reply, so for now we just don't exit
@@ -211,12 +236,11 @@ public class IdentityManagerApp {
         // obtrusive message box, on Windows
         //
         this.ipc_server = MoonshotServer.get_instance ();
-        MoonshotServer.start (this.view);
+        MoonshotServer.start (this);
     }
 #elif IPC_DBUS_GLIB
     private void init_ipc_server ()
     {
         try {
             var conn = DBus.Bus.get (DBus.BusType.SESSION);
             dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus",
@@ -225,10 +249,26 @@ public class IdentityManagerApp {
 
             // try to register service in session bus
             uint reply = bus.request_name ("org.janet.Moonshot", (uint) 0);
-            assert (reply == DBus.RequestNameReply.PRIMARY_OWNER);
-
-            this.ipc_server = new MoonshotServer (this);
-            conn.register_object ("/org/janet/moonshot", ipc_server);
+            if (reply == DBus.RequestNameReply.PRIMARY_OWNER)
+            {
+                this.ipc_server = new MoonshotServer (this);
+                conn.register_object ("/org/janet/moonshot", ipc_server);
+            } else {
+                bool shown=false;
+                GLib.Error e;
+                DBus.Object manager_proxy = conn.get_object ("org.janet.Moonshot",
+                                                             "/org/janet/moonshot",
+                                                             "org.janet.Moonshot");
+                if (manager_proxy != null)
+                    manager_proxy.call("ShowUi", out e, GLib.Type.INVALID, typeof(bool), out shown, GLib.Type.INVALID);
+
+                if (!shown) {
+                    GLib.error ("Couldn't own name org.janet.Moonshot on dbus or show previously launched identity manager.");
+                } else {
+                    stdout.printf("Showed previously launched identity manager.\n");
+                    GLib.Process.exit(0);
+                }
+            }
         }
         catch (DBus.Error e)
         {
@@ -274,9 +314,12 @@ public class IdentityManagerApp {
 }
 
 static bool explicitly_launched = true;
+static bool use_flat_file_store = false;
 const GLib.OptionEntry[] options = {
     {"DBusLaunch",0,GLib.OptionFlags.REVERSE,GLib.OptionArg.NONE,
      ref explicitly_launched,"launch for dbus rpc use",null},
+    {"FlatFileStore",0,0,GLib.OptionArg.NONE,
+     ref use_flat_file_store,"force use of flat file identity store (used by default only for headless operation)",null},
     {null}
 };
 
@@ -311,7 +354,7 @@ public static int main(string[] args){
         Intl.textdomain (Config.GETTEXT_PACKAGE);
        
           
-        var app = new IdentityManagerApp(headless);
+        var app = new IdentityManagerApp(headless, use_flat_file_store);
         app.explicitly_launched = explicitly_launched;
         
        if (app.explicitly_launched) {
diff --git a/src/moonshot-keyring-store.vala b/src/moonshot-keyring-store.vala
new file mode 100644 (file)
index 0000000..78c7af2
--- /dev/null
@@ -0,0 +1,161 @@
+using Gee;
+
+#if GNOME_KEYRING
+public class KeyringStore : Object, IIdentityCardStore {
+    private LinkedList<IdCard> id_card_list;
+    private const string keyring_store_attribute = "Moonshot";
+    private const string keyring_store_version = "1.0";
+    private const GnomeKeyring.ItemType item_type = GnomeKeyring.ItemType.GENERIC_SECRET;
+
+    public void add_card(IdCard card) {
+        id_card_list.add(card);
+        store_id_cards ();
+    }
+
+    public void update_card(IdCard card) {
+        id_card_list.remove(card);
+        id_card_list.add(card);
+        store_id_cards ();
+    }
+
+    public void remove_card(IdCard card) {
+        id_card_list.remove(card);
+        store_id_cards ();
+    }
+
+    public IIdentityCardStore.StoreType get_store_type() {
+        return IIdentityCardStore.StoreType.KEYRING;
+    }
+
+    public LinkedList<IdCard> get_card_list() {
+        return id_card_list;
+    }
+
+    /* clear all keyring-stored ids (in preparation to store current list) */
+    private void clear_keyring() {
+       GnomeKeyring.AttributeList match = new GnomeKeyring.AttributeList();
+       match.append_string(keyring_store_attribute, keyring_store_version);
+       GLib.List<GnomeKeyring.Found> items;
+        GnomeKeyring.find_items_sync(item_type, match, out items);
+        items.foreach((entry) => {
+            GnomeKeyring.Result result = GnomeKeyring.item_delete_sync(null, entry.item_id);
+            if (result != GnomeKeyring.Result.OK) {
+                stdout.printf("GnomeKeyring.item_delete_sync() failed. result: %d", result);
+            }
+        });
+    }
+     
+    private void load_id_cards() {
+        id_card_list.clear();
+
+       GnomeKeyring.AttributeList match = new GnomeKeyring.AttributeList();
+       match.append_string(keyring_store_attribute, keyring_store_version);
+       GLib.List<GnomeKeyring.Found> items;
+        GnomeKeyring.find_items_sync(item_type, match, out items);
+        items.foreach((entry) => {
+            IdCard id_card = new IdCard ();
+            int i;
+            int rules_patterns_index = -1;
+            int rules_always_confirm_index = -1;
+            string store_password = null;
+            for (i=0; i<entry.attributes.len; i++) {
+                var attribute = entry.attributes.data[i];
+               string value = attribute.string_value;
+               if (attribute.name == "Issuer") {
+                    id_card.issuer = value;
+               } else if (attribute.name == "Username") {
+                    id_card.username = value;
+               } else if (attribute.name == "DisplayName") {
+                    id_card.display_name = value;
+               } else if (attribute.name == "Services") {
+                    id_card.services = value.split(";");
+                } else if (attribute.name == "Rules-Pattern") {
+                    rules_patterns_index = i;
+                } else if (attribute.name == "Rules-AlwaysConfirm") {
+                    rules_always_confirm_index = i;
+                } else if (attribute.name == "CA-Cert") {
+                    id_card.trust_anchor.ca_cert = value;
+                } else if (attribute.name == "Server-Cert") {
+                    id_card.trust_anchor.server_cert = value;
+                } else if (attribute.name == "Subject") {
+                    id_card.trust_anchor.subject = value;
+                } else if (attribute.name == "Subject-Alt") {
+                    id_card.trust_anchor.subject_alt = value;
+                } else if (attribute.name == "StorePassword") {
+                    store_password = value;
+                }
+            }
+            if ((rules_always_confirm_index != -1) && (rules_patterns_index != -1)) {
+                string rules_patterns_all = entry.attributes.data[rules_patterns_index].string_value;
+                string rules_always_confirm_all = entry.attributes.data[rules_always_confirm_index].string_value;
+                string [] rules_always_confirm = rules_always_confirm_all.split(";");
+                string [] rules_patterns = rules_patterns_all.split(";");
+                if (rules_patterns.length == rules_always_confirm.length) {
+                   Rule[] rules = new Rule[rules_patterns.length];
+                   for (int j=0; j<rules_patterns.length; j++) {
+                       rules[j].pattern = rules_patterns[j];
+                       rules[j].always_confirm = rules_always_confirm[j];
+                   }
+                   id_card.rules = rules;
+                }
+            }
+
+            if (store_password != null)
+                id_card.store_password = (store_password == "yes");
+            else
+                id_card.store_password = ((entry.secret != null) && (entry.secret != ""));
+
+            if (id_card.store_password)
+                id_card.password = entry.secret;
+            else
+                id_card.password = null;
+            id_card_list.add(id_card);
+        });
+    }
+
+    public void store_id_cards () {
+        clear_keyring();
+        foreach (IdCard id_card in this.id_card_list) {
+            string[] rules_patterns = new string[id_card.rules.length];
+            string[] rules_always_conf = new string[id_card.rules.length];
+            
+            for (int i=0; i<id_card.rules.length; i++) {
+                rules_patterns[i] = id_card.rules[i].pattern;
+                rules_always_conf[i] = id_card.rules[i].always_confirm;
+            }
+            string patterns = string.joinv(";", rules_patterns);
+            string always_conf = string.joinv(";", rules_always_conf);
+            string services = string.joinv(";", id_card.services);
+            GnomeKeyring.AttributeList attributes = new GnomeKeyring.AttributeList();
+            uint32 item_id;
+            attributes.append_string(keyring_store_attribute, keyring_store_version);
+            attributes.append_string("Issuer", id_card.issuer);
+            attributes.append_string("Username", id_card.username);
+            attributes.append_string("DisplayName", id_card.display_name);
+            attributes.append_string("Services", services);
+            attributes.append_string("Rules-Pattern", patterns);
+            attributes.append_string("Rules-AlwaysConfirm", always_conf);
+            attributes.append_string("CA-Cert", id_card.trust_anchor.ca_cert);
+            attributes.append_string("Server-Cert", id_card.trust_anchor.server_cert);
+            attributes.append_string("Subject", id_card.trust_anchor.subject);
+            attributes.append_string("Subject-Alt", id_card.trust_anchor.subject_alt);
+            attributes.append_string("StorePassword", id_card.store_password ? "yes" : "no");
+
+            GnomeKeyring.Result result = GnomeKeyring.item_create_sync(null,
+                item_type, id_card.display_name, attributes,
+                id_card.store_password ? id_card.password : "",
+                true, out item_id);
+            if (result != GnomeKeyring.Result.OK) {
+                stdout.printf("GnomeKeyring.item_create_sync() failed. result: %d", result);
+            }
+        }
+        load_id_cards();
+    }
+
+    public KeyringStore () {
+        id_card_list = new LinkedList<IdCard>();
+        load_id_cards();
+    }
+}
+
+#endif
index 41f8273..baafa72 100644 (file)
@@ -23,6 +23,10 @@ public class LocalFlatFileStore : Object, IIdentityCardStore {
      public LinkedList<IdCard> get_card_list() {
           return id_card_list; 
      }
+
+     public IIdentityCardStore.StoreType get_store_type() {
+          return IIdentityCardStore.StoreType.FLAT_FILE;
+     }
      
      private void load_id_cards() {
         id_card_list.clear();
@@ -49,7 +53,11 @@ public class LocalFlatFileStore : Object, IIdentityCardStore {
                 id_card.services = key_file.get_string_list (identity, "Services");
                 id_card.display_name = key_file.get_string (identity, "DisplayName");
                 id_card.set_data ("pixbuf", find_icon ("avatar-default", 48));
-                
+                if (key_file.has_key (identity, "StorePassword")) {
+                    id_card.store_password = (key_file.get_string (identity, "StorePassword") == "yes");
+                } else {
+                    id_card.store_password = (id_card.password != null) && (id_card.password != "");
+                }
                 
                 if (key_file.has_key (identity, "Rules-Patterns") &&
                     key_file.has_key (identity, "Rules-AlwaysConfirm")) {
@@ -104,13 +112,17 @@ public class LocalFlatFileStore : Object, IIdentityCardStore {
             key_file.set_string (id_card.display_name, "Issuer", id_card.issuer ?? "");
             key_file.set_string (id_card.display_name, "DisplayName", id_card.display_name ?? "");
             key_file.set_string (id_card.display_name, "Username", id_card.username ?? "");
-            key_file.set_string (id_card.display_name, "Password", id_card.password ?? "");
+            if (id_card.store_password && (id_card.password != null))
+              key_file.set_string (id_card.display_name, "Password", id_card.password);
+            else
+              key_file.set_string (id_card.display_name, "Password", "");
             key_file.set_string_list (id_card.display_name, "Services", id_card.services ?? {});
 
             if (id_card.rules.length > 0) {
               key_file.set_string_list (id_card.display_name, "Rules-Patterns", rules_patterns);
               key_file.set_string_list (id_card.display_name, "Rules-AlwaysConfirm", rules_always_conf);
             }
+            key_file.set_string (id_card.display_name, "StorePassword", id_card.store_password ? "yes" : "no");
             
             // Trust anchor 
             key_file.set_string (id_card.display_name, "CA-Cert", id_card.trust_anchor.ca_cert ?? "");
index 35f239b..060959d 100644 (file)
@@ -13,9 +13,9 @@ class AddPasswordDialog : Dialog
         get { return remember_checkbutton.get_active (); }
     }
 
-    public AddPasswordDialog ()
+    public AddPasswordDialog (IdCard id_card, IdentityRequest request)
     {
-        this.set_title (_("Please enter your password"));
+        this.set_title (_("Please enter password for ") + id_card.display_name);
         this.set_modal (true);
 
         this.add_buttons (_("Send"), ResponseType.OK,
@@ -25,6 +25,16 @@ class AddPasswordDialog : Dialog
         var content_area = this.get_content_area ();
         ((Box) content_area).set_spacing (12);
 
+        var service_label = new Label (_("for use with:"));
+        service_label.set_alignment (1, (float) 0.5);
+        var service_value = new Label (request.service);
+        service_value.set_alignment (0, (float) 0.5);
+
+        var nai_label = new Label (_("Network Access Identifier:"));
+        nai_label.set_alignment (1, (float) 0.5);
+        var nai_value = new Label (id_card.nai);
+        nai_value.set_alignment (0, (float) 0.5);
+
         var password_label = new Label (_("Password:"));
         password_label.set_alignment (1, (float) 0.5);
         this.password_entry = new Entry ();
@@ -35,9 +45,13 @@ class AddPasswordDialog : Dialog
 
         set_atk_relation (password_entry, password_entry, Atk.RelationType.LABEL_FOR);
 
-        var table = new Table (2, 2, false);
+        var table = new Table (4, 2, false);
         table.set_col_spacings (10);
         table.set_row_spacings (10);
+        table.attach_defaults (service_label, 0, 1, 0, 1);
+        table.attach_defaults (service_value, 1, 2, 0, 1);
+        table.attach_defaults (nai_label, 0, 1, 1, 2);
+        table.attach_defaults (nai_value, 1, 2, 1, 2);
         table.attach_defaults (password_label, 0, 1, 2, 3);
         table.attach_defaults (password_entry, 1, 2, 2, 3);
         table.attach_defaults (remember_checkbutton,  1, 2, 3, 4);
@@ -49,7 +63,7 @@ class AddPasswordDialog : Dialog
         ((Container) content_area).add (vbox);
 
         this.set_border_width (6);
-        this.set_resizable (false);
+        //this.set_resizable (false);
         this.show_all ();
     }
 
index 2bff71d..eb881d2 100644 (file)
@@ -133,7 +133,8 @@ public class MoonshotServer : Object {
                                  string   ?ca_cert,
                                  string   ?subject,
                                  string   ?subject_alt,
-                                 string   ?server_cert)
+                                 string   ?server_cert,
+                                 int      force_flat_file_store)
     {
       IdCard idcard = new IdCard ();
 
@@ -158,7 +159,7 @@ public class MoonshotServer : Object {
         }
       }
 
-      return parent_app.add_identity (idcard);
+      return parent_app.add_identity (idcard, force_flat_file_store!=0);
     }
 
 
@@ -197,7 +198,8 @@ public class MoonshotServer : Object {
                                 card.trust_anchor.ca_cert,
                                 card.trust_anchor.subject,
                                 card.trust_anchor.subject_alt,
-                                card.trust_anchor.server_cert);
+                                card.trust_anchor.server_cert,
+                                0);
       if (result) {
         installed_cards++;
       }
@@ -221,13 +223,13 @@ using MoonshotRpcInterface;
  * process ends
  */
 public class MoonshotServer : Object {
-    private static IdentityManagerView main_window;
+    private static IdentityManagerApp parent_app;
 
     private static MoonshotServer instance = null;
 
-    public static void start (Gtk.Window window)
+    public static void start (IdentityManagerApp app)
     {
-        main_window = (IdentityManagerView) window;
+        parent_app = app;
         Rpc.server_start (MoonshotRpcInterface.spec, "/org/janet/Moonshot", Rpc.Flags.PER_USER);
     }
 
@@ -252,7 +254,7 @@ public class MoonshotServer : Object {
     {
         bool result = false;
 
-        var request = new IdentityRequest (main_window,
+        var request = new IdentityRequest (parent_app,
                                            nai,
                                            password,
                                            service);
@@ -314,7 +316,7 @@ public class MoonshotServer : Object {
     {
         bool result;
 
-        var request = new IdentityRequest.default (main_window);
+        var request = new IdentityRequest.default (parent_app);
         request.mutex = new Mutex ();
         request.cond = new Cond ();
         request.set_callback (return_identity_cb);
@@ -382,7 +384,8 @@ public class MoonshotServer : Object {
                                         string     ca_cert,
                                         string     subject,
                                         string     subject_alt,
-                                        string     server_cert)
+                                        string     server_cert,
+                                        bool       force_flat_file_store)
     {
         IdCard idcard = new IdCard ();
         bool success = false;
@@ -415,7 +418,7 @@ public class MoonshotServer : Object {
         // Defer addition to the main loop thread.
         Idle.add (() => {
             mutex.lock ();
-            success = main_window.add_identity (idcard);
+            success = parent_app.add_identity (idcard, force_flat_file_store);
             cond.signal ();
             mutex.unlock ();
             return false;
index 5d9775f..701042e 100644 (file)
@@ -6,17 +6,39 @@ namespace WebProvisioning
 
   public static int main (string[] args)
   {
-    if (args.length < 2)
+    int arg_index = -1;
+    int force_flat_file_store = 0;
+    bool bad_switch = false;
+    for (arg_index = 1; arg_index < args.length; arg_index++) {
+      int index = 0;
+      unichar c = 0;
+      string arg = args[arg_index];
+      if (arg.get_next_char(ref index, out c)) {
+        if ((c=='-') && arg.get_next_char(ref index, out c)) {
+          switch (c) {
+            case 'f':
+              force_flat_file_store = 1;
+              break;
+            default:
+              bad_switch = true;
+              break;
+          }
+        } else
+          break; // arg is not a switch; presume it's the file
+      }
+    }
+    if (bad_switch || (arg_index != args.length - 1))
     {
-      error ("Usage %s [-a] WEB_PROVISIONING_FILE", args[0]);
+      error ("Usage %s [-f] WEB_PROVISIONING_FILE\n -f: add identities to flat file store", args[0]);
     }
+    string webp_file = args[arg_index];
     
-    if (!FileUtils.test (args[1], FileTest.EXISTS | FileTest.IS_REGULAR))
+    if (!FileUtils.test (webp_file, FileTest.EXISTS | FileTest.IS_REGULAR))
     {
-      error ("%s does not exist", args[1]);
+      error ("%s does not exist", webp_file);
     }
     
-    var webp = new Parser (args[1]);
+    var webp = new Parser (webp_file);
     webp.parse();
     
     foreach (IdCard card in cards)
@@ -49,6 +71,7 @@ namespace WebProvisioning
                                 card.trust_anchor.subject,
                                 card.trust_anchor.subject_alt,
                                 card.trust_anchor.server_cert,
+                                force_flat_file_store,
                                 out error);
 
       if (error != null)
diff --git a/vapi/moonshot-gnome-keyring.vapi b/vapi/moonshot-gnome-keyring.vapi
new file mode 100644 (file)
index 0000000..690fcba
--- /dev/null
@@ -0,0 +1,327 @@
+/* Adapted from gnome-keyring-1.vapi to improve functionality */
+/* specifically: modified class Attribute to allow access to string value */
+/* also modified class PasswordSchema to appropriate use of attributes */
+
+
+/* gnome-keyring-1.vapi generated by vapigen, do not modify. */
+
+namespace GnomeKeyring {
+       [CCode (cheader_filename = "gnome-keyring.h", copy_function = "gnome_keyring_access_control_copy")]
+       [Compact]
+       public class AccessControl {
+               [CCode (has_construct_function = false)]
+               public AccessControl (GnomeKeyring.ApplicationRef application, GnomeKeyring.AccessType types_allowed);
+               public GnomeKeyring.AccessControl copy ();
+       }
+       [CCode (cheader_filename = "gnome-keyring.h", copy_function = "gnome_keyring_application_ref_copy")]
+       [Compact]
+       public class ApplicationRef {
+               [CCode (has_construct_function = false)]
+               public ApplicationRef ();
+               public GnomeKeyring.ApplicationRef copy ();
+       }
+       [CCode (cheader_filename = "gnome-keyring.h", copy_function = "gnome_keyring_attribute_list_copy", free_function = "gnome_keyring_attribute_list_free")]
+       [Compact]
+       public class AttributeList {
+               [CCode (array_length = false)]
+               public GnomeKeyring.Attribute[] data;
+               public uint len;
+               public AttributeList ();
+               public void append_string (string name, string value);
+               public void append_uint32 (string name, uint32 value);
+               public GnomeKeyring.AttributeList copy ();
+               public GnomeKeyring.Attribute index (int i);
+       }
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       [Compact]
+       public class Found {
+               public weak GnomeKeyring.AttributeList attributes;
+               public uint item_id;
+               public weak string keyring;
+               public weak string secret;
+       }
+       [CCode (cheader_filename = "gnome-keyring.h", copy_function = "gnome_keyring_info_copy")]
+       [Compact]
+       public class Info {
+               public GnomeKeyring.Info copy ();
+               public ulong get_ctime ();
+               public bool get_is_locked ();
+               public bool get_lock_on_idle ();
+               public uint32 get_lock_timeout ();
+               public ulong get_mtime ();
+               public void set_lock_on_idle (bool value);
+               public void set_lock_timeout (uint32 value);
+       }
+       [CCode (cheader_filename = "gnome-keyring.h", copy_function = "gnome_keyring_item_info_copy")]
+       [Compact]
+       public class ItemInfo {
+               [CCode (has_construct_function = false)]
+               public ItemInfo ();
+               public GnomeKeyring.ItemInfo copy ();
+               public ulong get_ctime ();
+               public unowned string get_display_name ();
+               public ulong get_mtime ();
+               public unowned string get_secret ();
+               public void set_display_name (string value);
+               public void set_secret (string value);
+               public void set_type (GnomeKeyring.ItemType type);
+       }
+       [CCode (cheader_filename = "gnome-keyring.h", free_function = "gnome_keyring_network_password_free")]
+       [Compact]
+       public class NetworkPasswordData {
+               public weak string authtype;
+               public weak string domain;
+               public uint32 item_id;
+               public weak string keyring;
+               public weak string object;
+               public weak string password;
+               public uint32 port;
+               public weak string protocol;
+               public weak string server;
+               public weak string user;
+       }
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       [Compact]
+       public class PasswordSchema {
+               public void* attributes;
+               public GnomeKeyring.ItemType item_type;
+               public void* reserved1;
+               public void* reserved2;
+               public void* reserved3;
+       }
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public struct Attribute {
+               public weak string name;
+               public GnomeKeyring.AttributeType type;
+               [CCode (cname="value.string")]
+               unowned string string_value;
+                [CCode (cname="value.integer")]
+               uint32 integer_value;
+       }
+       [CCode (cheader_filename = "gnome-keyring.h", cprefix = "GNOME_KEYRING_ACCESS_", has_type_id = false)]
+       public enum AccessRestriction {
+               ASK,
+               DENY,
+               ALLOW
+       }
+       [CCode (cheader_filename = "gnome-keyring.h", cprefix = "GNOME_KEYRING_ACCESS_", has_type_id = false)]
+       public enum AccessType {
+               READ,
+               WRITE,
+               REMOVE
+       }
+       [CCode (cheader_filename = "gnome-keyring.h", cprefix = "GNOME_KEYRING_ATTRIBUTE_TYPE_", has_type_id = false)]
+       public enum AttributeType {
+               STRING,
+               UINT32
+       }
+       [CCode (cheader_filename = "gnome-keyring.h", cprefix = "GNOME_KEYRING_ITEM_INFO_", has_type_id = false)]
+       public enum ItemInfoFlags {
+               ALL,
+               BASICS,
+               SECRET
+       }
+       [CCode (cheader_filename = "gnome-keyring.h", cprefix = "GNOME_KEYRING_ITEM_", has_type_id = false)]
+       public enum ItemType {
+               APPLICATION_SECRET,
+               ITEM_TYPE_MASK,
+               GENERIC_SECRET,
+               NETWORK_PASSWORD,
+               NOTE,
+               CHAINED_KEYRING_PASSWORD,
+               ENCRYPTION_KEY_PASSWORD,
+               PK_STORAGE,
+               LAST_TYPE
+       }
+       [CCode (cheader_filename = "gnome-keyring.h", cprefix = "GNOME_KEYRING_RESULT_", has_type_id = false)]
+       public enum Result {
+               OK,
+               DENIED,
+               NO_KEYRING_DAEMON,
+               ALREADY_UNLOCKED,
+               NO_SUCH_KEYRING,
+               BAD_ARGUMENTS,
+               IO_ERROR,
+               CANCELLED,
+               KEYRING_ALREADY_EXISTS,
+               NO_MATCH
+       }
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public delegate void OperationDoneCallback (GnomeKeyring.Result result);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public delegate void OperationGetAttributesCallback (GnomeKeyring.Result result, GnomeKeyring.AttributeList attributes);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public delegate void OperationGetIntCallback (GnomeKeyring.Result result, uint32 val);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public delegate void OperationGetItemInfoCallback (GnomeKeyring.Result result, GnomeKeyring.ItemInfo info);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public delegate void OperationGetKeyringInfoCallback (GnomeKeyring.Result result, GnomeKeyring.Info info);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public delegate void OperationGetListCallback (GnomeKeyring.Result result, GLib.List<GnomeKeyring.NetworkPasswordData> list);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public delegate void OperationGetStringCallback (GnomeKeyring.Result result, string? str);
+       [CCode (cheader_filename = "gnome-keyring.h", cname = "GNOME_KEYRING_NETWORK_PASSWORD")]
+       public static GnomeKeyring.PasswordSchema NETWORK_PASSWORD;
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public const string DEFAULT;
+       [CCode (cheader_filename = "gnome-keyring.h", cname = "GNOME_KEYRING_SESSION")]
+       public const string SESSION;
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GLib.List<GnomeKeyring.AccessControl> acl_copy (GLib.List<GnomeKeyring.AccessControl> list);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void cancel_request (void* request);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* change_password (string keyring, string? original, string? password, owned GnomeKeyring.OperationDoneCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result change_password_sync (string keyring, string? original, string? password);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* create (string keyring_name, string? password, owned GnomeKeyring.OperationDoneCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result create_sync (string keyring_name, string? password);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result daemon_prepare_environment_sync ();
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result daemon_set_display_sync (string display);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* @delete (string keyring, GnomeKeyring.OperationDoneCallback callback, void* data, GLib.DestroyNotify destroy_data);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* delete_password (GnomeKeyring.PasswordSchema schema, owned GnomeKeyring.OperationDoneCallback callback, ...);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result delete_password_sync (GnomeKeyring.PasswordSchema schema, ...);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result delete_sync (string keyring);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* find_items (GnomeKeyring.ItemType type, GnomeKeyring.AttributeList attributes, owned GnomeKeyring.OperationGetListCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result find_items_sync (GnomeKeyring.ItemType type, GnomeKeyring.AttributeList attributes, out GLib.List<GnomeKeyring.Found> found);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* find_itemsv (GnomeKeyring.ItemType type, owned GnomeKeyring.OperationGetListCallback callback, ...);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result find_itemsv_sync (GnomeKeyring.ItemType type, out GLib.List<GnomeKeyring.Found> found, ...);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* find_network_password (string? user, string? domain, string? server, string? object, string? protocol, string? authtype, uint32 port, owned GnomeKeyring.OperationGetListCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result find_network_password_sync (string? user, string? domain, string? server, string? object, string? protocol, string? authtype, uint32 port, out GLib.List<GnomeKeyring.NetworkPasswordData> results);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* find_password (GnomeKeyring.PasswordSchema schema, owned GnomeKeyring.OperationGetStringCallback callback, ...);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result find_password_sync (GnomeKeyring.PasswordSchema schema, out unowned string password, ...);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void free_password (string password);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* get_default_keyring (owned GnomeKeyring.OperationGetStringCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result get_default_keyring_sync (out unowned string keyring);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* get_info (string? keyring, owned GnomeKeyring.OperationGetKeyringInfoCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result get_info_sync (string? keyring, out unowned GnomeKeyring.Info info);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static bool is_available ();
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.AccessType item_ac_get_access_type (GnomeKeyring.AccessControl ac);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static unowned string item_ac_get_display_name (GnomeKeyring.AccessControl ac);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static unowned string item_ac_get_path_name (GnomeKeyring.AccessControl ac);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void item_ac_set_access_type (GnomeKeyring.AccessControl ac, GnomeKeyring.AccessType value);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void item_ac_set_display_name (GnomeKeyring.AccessControl ac, string value);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void item_ac_set_path_name (GnomeKeyring.AccessControl ac, string value);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* item_create (string? keyring, GnomeKeyring.ItemType type, string display_name, GnomeKeyring.AttributeList attributes, string secret, bool update_if_exists, owned GnomeKeyring.OperationGetIntCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result item_create_sync (string? keyring, GnomeKeyring.ItemType type, string display_name, GnomeKeyring.AttributeList attributes, string secret, bool update_if_exists, out uint32 item_id);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* item_delete (string? keyring, uint32 id, owned GnomeKeyring.OperationDoneCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result item_delete_sync (string? keyring, uint32 id);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* item_get_acl (string? keyring, uint32 id, owned GnomeKeyring.OperationGetListCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result item_get_acl_sync (string? keyring, uint32 id, out GLib.List<GnomeKeyring.AccessControl> acl);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* item_get_attributes (string? keyring, uint32 id, owned GnomeKeyring.OperationGetAttributesCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result item_get_attributes_sync (string? keyring, uint32 id, out unowned GnomeKeyring.AttributeList attributes);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* item_get_info (string? keyring, uint32 id, owned GnomeKeyring.OperationGetItemInfoCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* item_get_info_full (string? keyring, uint32 id, uint32 flags, owned GnomeKeyring.OperationGetItemInfoCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result item_get_info_full_sync (string? keyring, uint32 id, uint32 flags, out unowned GnomeKeyring.ItemInfo info);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result item_get_info_sync (string keyring, uint32 id, out unowned GnomeKeyring.ItemInfo info);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* item_grant_access_rights (string? keyring, string display_name, string full_path, uint32 id, GnomeKeyring.AccessType rights, owned GnomeKeyring.OperationDoneCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result item_grant_access_rights_sync (string? keyring, string display_name, string full_path, uint32 id, GnomeKeyring.AccessType rights);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* item_set_acl (string? keyring, uint32 id, GLib.List<GnomeKeyring.AccessControl> acl, owned GnomeKeyring.OperationDoneCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result item_set_acl_sync (string? keyring, uint32 id, GLib.List<GnomeKeyring.AccessControl> acl);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* item_set_attributes (string? keyring, uint32 id, GnomeKeyring.AttributeList attributes, owned GnomeKeyring.OperationDoneCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result item_set_attributes_sync (string? keyring, uint32 id, GnomeKeyring.AttributeList attributes);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* item_set_info (string? keyring, uint32 id, GnomeKeyring.ItemInfo info, owned GnomeKeyring.OperationDoneCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result item_set_info_sync (string? keyring, uint32 id, GnomeKeyring.ItemInfo info);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* list_item_ids (string? keyring, owned GnomeKeyring.OperationGetListCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result list_item_ids_sync (string? keyring, out GLib.List<uint> ids);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* list_keyring_names (owned GnomeKeyring.OperationGetListCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result list_keyring_names_sync (out GLib.List<string> keyrings);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* @lock (string keyring, GnomeKeyring.OperationDoneCallback callback, void* data, GLib.DestroyNotify destroy_data);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* lock_all (owned GnomeKeyring.OperationDoneCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result lock_all_sync ();
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result lock_sync (string? keyring);
+       [CCode (cheader_filename = "gnome-keyring-memory.h")]
+       public static void* memory_alloc (ulong sz);
+       [CCode (cheader_filename = "gnome-keyring-memory.h")]
+       public static void memory_free (void* p);
+       [CCode (cheader_filename = "gnome-keyring-memory.h")]
+       public static bool memory_is_secure (void* p);
+       [CCode (cheader_filename = "gnome-keyring-memory.h")]
+       public static void* memory_realloc (void* p, ulong sz);
+       [CCode (cheader_filename = "gnome-keyring-memory.h")]
+       public static unowned string memory_strdup (string str);
+       [CCode (cheader_filename = "gnome-keyring-memory.h")]
+       public static void* memory_try_alloc (ulong sz);
+       [CCode (cheader_filename = "gnome-keyring-memory.h")]
+       public static void* memory_try_realloc (void* p, ulong sz);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void network_password_free (GnomeKeyring.NetworkPasswordData data);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static unowned string result_to_message (GnomeKeyring.Result res);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* set_default_keyring (string keyring, owned GnomeKeyring.OperationDoneCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result set_default_keyring_sync (string keyring);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* set_info (string? keyring, GnomeKeyring.Info info, owned GnomeKeyring.OperationDoneCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result set_info_sync (string? keyring, GnomeKeyring.Info info);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* set_network_password (string? keyring, string? user, string? domain, string? server, string? object, string? protocol, string? authtype, uint32 port, string? password, owned GnomeKeyring.OperationGetIntCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result set_network_password_sync (string? keyring, string? user, string? domain, string? server, string? object, string? protocol, string? authtype, uint32 port, string? password, out uint32 item_id);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* store_password (GnomeKeyring.PasswordSchema schema, string? keyring, string display_name, string password, owned GnomeKeyring.OperationDoneCallback callback, ...);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result store_password_sync (GnomeKeyring.PasswordSchema schema, string? keyring, string display_name, string password, ...);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static void* unlock (string? keyring, string? password, owned GnomeKeyring.OperationDoneCallback callback);
+       [CCode (cheader_filename = "gnome-keyring.h")]
+       public static GnomeKeyring.Result unlock_sync (string? keyring, string? password);
+}