Example #1
0
        public static void SetKeyringInfo(string keyring, KeyringInfo info)
        {
            if (keyring == null)
            {
                throw new ArgumentNullException("keyring");
            }

            if (info == null)
            {
                throw new ArgumentNullException("info");
            }


            IntPtr     keyring_info;
            ResultCode result = gnome_keyring_get_info_sync(keyring, out keyring_info);

            if (result != ResultCode.Ok)
            {
                throw new KeyringException(result);
            }

            gnome_keyring_info_set_lock_timeout(keyring_info, (uint)info.LockTimeoutSeconds);
            gnome_keyring_info_set_lock_on_idle(keyring_info, info.LockOnIdle);

            result = gnome_keyring_set_info_sync(keyring, keyring_info);

            gnome_keyring_info_free(keyring_info);

            if (result != ResultCode.Ok)
            {
                throw new KeyringException(result);
            }
        }
Example #2
0
        public static KeyringInfo GetKeyringInfo(string keyring)
        {
            if (keyring == null)
            {
                throw new ArgumentNullException("keyring");
            }

            IntPtr     keyring_info = IntPtr.Zero;
            ResultCode result       = gnome_keyring_get_info_sync(keyring, out keyring_info);

            if (result != ResultCode.Ok)
            {
                throw new KeyringException(result);
            }

            DateTime    ctime  = GLib.Marshaller.time_tToDateTime(gnome_keyring_info_get_ctime(keyring_info));
            DateTime    mtime  = GLib.Marshaller.time_tToDateTime(gnome_keyring_info_get_mtime(keyring_info));
            KeyringInfo retval = new KeyringInfo(keyring,
                                                 gnome_keyring_info_get_lock_on_idle(keyring_info),
                                                 gnome_keyring_info_get_lock_timeout(keyring_info),
                                                 mtime,
                                                 ctime,
                                                 gnome_keyring_info_get_is_locked(keyring_info)
                                                 );


            gnome_keyring_info_free(keyring_info);
            return(retval);
        }
        public void GetKeyringInfoGetsCorrectName()
        {
            string      keyringName = "login";
            KeyringInfo info        = Ring.GetKeyringInfo(keyringName);

            Assert.AreEqual(keyringName, info.Name);
        }
        public void SetKeyringLockOnIdleUpdatesInfo()
        {
            string keyringName = "theamazingtestkeyring";

            Ring.CreateKeyring(keyringName, "password");

            try {
                KeyringInfo info = Ring.GetKeyringInfo(keyringName);
                info.LockOnIdle = !info.LockOnIdle;
                Assert.AreNotEqual(info.LockOnIdle, Ring.GetKeyringInfo(keyringName).LockOnIdle);

                Ring.SetKeyringInfo(keyringName, info);
                Assert.AreEqual(info.LockOnIdle, Ring.GetKeyringInfo(keyringName).LockOnIdle);
            } finally {
                Ring.DeleteKeyring(keyringName);
            }
        }
        public void SetKeyringInfoUpdatesLockTimeout()
        {
            string keyringName = "testkeyring";

            Ring.CreateKeyring(keyringName, "password");

            try {
                KeyringInfo info = Ring.GetKeyringInfo(keyringName);
                info.LockTimeoutSeconds++;
                Assert.AreNotEqual(info.LockTimeoutSeconds, Ring.GetKeyringInfo(keyringName).LockTimeoutSeconds);

                Ring.Unlock(keyringName, null);
                Ring.SetKeyringInfo(keyringName, info);
                Assert.AreEqual(info.LockTimeoutSeconds, Ring.GetKeyringInfo(keyringName).LockTimeoutSeconds);
            } finally {
                Ring.DeleteKeyring(keyringName);
            }
        }
Example #6
0
        public static void SetKeyringInfo(string keyring, KeyringInfo info)
        {
            if (keyring == null)
            {
                throw new ArgumentNullException("keyring");
            }

            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            RequestMessage req = new RequestMessage();

            req.StartOperation(Operation.SetKeyringInfo);
            req.Write(keyring);
            req.Write(info.LockOnIdle ? 1 : 0);
            req.Write(info.LockTimeoutSeconds);
            req.EndOperation();
            SendRequest(req.Stream);
        }
Example #7
0
		public static void SetKeyringInfo (string keyring, KeyringInfo info)
		{
			if (keyring == null)
				throw new ArgumentNullException ("keyring");

			if (info == null)
				throw new ArgumentNullException ("info");

			RequestMessage req = new RequestMessage ();
			req.StartOperation (Operation.SetKeyringInfo);
			req.Write (keyring);
			req.Write (info.LockOnIdle ? 1 : 0);
			req.Write (info.LockTimeoutSeconds);
			req.EndOperation ();
			SendRequest (req.Stream);
		}
		static void Main ()
		{
			if (!Ring.Available) {
				Console.WriteLine ("The gnome-keyring-daemon cannot be reached.");
				return;
			}

			string deflt = Ring.GetDefaultKeyring ();
			Console.WriteLine ("The default keyring is '{0}'", deflt);
			Console.Write ("Other rings available: ");

			foreach (string s in Ring.GetKeyrings ()) {
				if (s != deflt)
					Console.Write ("'{0}' ", s);
			}
			Console.WriteLine ();

			// This is equivalent to...
			foreach (ItemData s in Ring.FindNetworkPassword ("gonzalo", null, null, null, null, null, 0)) {
				Console.WriteLine ("HERE");
				Console.WriteLine (s);
			}

			// ... this other search.
			Hashtable tbl = new Hashtable ();
			tbl ["user"] = "******";
			foreach (ItemData s in Ring.Find (ItemType.NetworkPassword, tbl)) {
				Console.WriteLine (s);
			}

			tbl = new Hashtable ();
			tbl ["user"] = "******";
			tbl ["domain"] = "MiDomain";
			Console.WriteLine ("Creating item");
			int i = Ring.CreateItem (null, ItemType.NetworkPassword, "*****@*****.**", tbl, "laclave", true);
			ItemData d2 = Ring.GetItemInfo (deflt, i);
			Ring.SetItemInfo (deflt, d2.ItemID, ItemType.NetworkPassword, "cambioesto@lalala", "otraclave");
			Hashtable atts = Ring.GetItemAttributes (deflt, i);
			foreach (string key in atts.Keys) {
				Console.WriteLine ("{0}: {1}", key, atts [key]);
			}

			atts ["object"] = "new attributes";
			Ring.SetItemAttributes (deflt, i, atts);
			Console.WriteLine ("Press any key to continue...");
			Console.ReadLine ();

			Console.WriteLine ("Deleting it (ID = {0})", i);
			Ring.DeleteItem (Ring.GetDefaultKeyring (), i);
			Console.WriteLine ("Existing IDs...");
			foreach (int nn in Ring.ListItemIDs (deflt)) {
				Console.WriteLine (nn);
			}

			KeyringInfo info = new KeyringInfo (true, 15);
			Ring.SetKeyringInfo (deflt, info);

			info = Ring.GetKeyringInfo (deflt);
			Console.WriteLine (info);
			ArrayList acl_list = Ring.GetItemACL (deflt, 3);
			foreach (ItemACL acl in acl_list)
				Console.WriteLine (acl);

			ArrayList list2 = new ArrayList (acl_list);
			list2.Add (new ItemACL ("test", "/test", AccessRights.Read));
			Ring.SetItemACL (deflt, 3, list2);
			Console.WriteLine ("Press any key to continue...");
			Console.ReadLine ();
			Ring.SetItemACL (deflt, 3, acl_list);
		}
		public static void SetKeyringInfo (string keyring, KeyringInfo info)
		{
			if (keyring == null)
				throw new ArgumentNullException ("keyring");

			if (info == null)
				throw new ArgumentNullException ("info");

		
			IntPtr keyring_info;
			ResultCode result = gnome_keyring_get_info_sync (keyring, out keyring_info);
			
			if (result != ResultCode.Ok) {
				throw new KeyringException (result);
			}
			
			gnome_keyring_info_set_lock_timeout (keyring_info, (uint)info.LockTimeoutSeconds);
			gnome_keyring_info_set_lock_on_idle (keyring_info, info.LockOnIdle);
			
			result = gnome_keyring_set_info_sync (keyring, keyring_info);

			gnome_keyring_info_free (keyring_info);
			
			if (result != ResultCode.Ok) {
				throw new KeyringException (result);
			}
		}
Example #10
0
		public static KeyringInfo GetKeyringInfo (string keyring)
		{
			if (keyring == null)
				throw new ArgumentNullException ("keyring");

			IntPtr keyring_info = IntPtr.Zero;
			ResultCode result = gnome_keyring_get_info_sync (keyring, out keyring_info);
			
			if (result != ResultCode.Ok) {
				throw new KeyringException (result);
			}
			
			DateTime ctime = GLib.Marshaller.time_tToDateTime (gnome_keyring_info_get_ctime (keyring_info));
			DateTime mtime = GLib.Marshaller.time_tToDateTime (gnome_keyring_info_get_mtime (keyring_info));
			KeyringInfo retval = new KeyringInfo (keyring,
				gnome_keyring_info_get_lock_on_idle (keyring_info),
				gnome_keyring_info_get_lock_timeout (keyring_info),
				mtime,
				ctime,
				gnome_keyring_info_get_is_locked (keyring_info)
				);
			
			
			gnome_keyring_info_free (keyring_info);
			return retval;
		}
Example #11
0
        static void Main()
        {
            if (!Ring.Available)
            {
                Console.WriteLine("The gnome-keyring-daemon cannot be reached.");
                return;
            }

            string deflt = Ring.GetDefaultKeyring();

            Console.WriteLine("The default keyring is '{0}'", deflt);
            Console.Write("Other rings available: ");

            foreach (string s in Ring.GetKeyrings())
            {
                if (s != deflt)
                {
                    Console.Write("'{0}' ", s);
                }
            }
            Console.WriteLine();

            // This is equivalent to...
            foreach (ItemData s in Ring.FindNetworkPassword("gonzalo", null, null, null, null, null, 0))
            {
                Console.WriteLine("HERE");
                Console.WriteLine(s);
            }

            // ... this other search.
            Hashtable tbl = new Hashtable();

            tbl ["user"] = "******";
            foreach (ItemData s in Ring.Find(ItemType.NetworkPassword, tbl))
            {
                Console.WriteLine(s);
            }

            tbl            = new Hashtable();
            tbl ["user"]   = "******";
            tbl ["domain"] = "MiDomain";
            Console.WriteLine("Creating item");
            int      i  = Ring.CreateItem(null, ItemType.NetworkPassword, "*****@*****.**", tbl, "laclave", true);
            ItemData d2 = Ring.GetItemInfo(deflt, i);

            Ring.SetItemInfo(deflt, d2.ItemID, ItemType.NetworkPassword, "cambioesto@lalala", "otraclave");
            Hashtable atts = Ring.GetItemAttributes(deflt, i);

            foreach (string key in atts.Keys)
            {
                Console.WriteLine("{0}: {1}", key, atts [key]);
            }

            atts ["object"] = "new attributes";
            Ring.SetItemAttributes(deflt, i, atts);
            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();

            Console.WriteLine("Deleting it (ID = {0})", i);
            Ring.DeleteItem(Ring.GetDefaultKeyring(), i);
            Console.WriteLine("Existing IDs...");
            foreach (int nn in Ring.ListItemIDs(deflt))
            {
                Console.WriteLine(nn);
            }

            KeyringInfo info = new KeyringInfo(true, 15);

            Ring.SetKeyringInfo(deflt, info);

            info = Ring.GetKeyringInfo(deflt);
            Console.WriteLine(info);
            ArrayList acl_list = Ring.GetItemACL(deflt, 3);

            foreach (ItemACL acl in acl_list)
            {
                Console.WriteLine(acl);
            }

            ArrayList list2 = new ArrayList(acl_list);

            list2.Add(new ItemACL("test", "/test", AccessRights.Read));
            Ring.SetItemACL(deflt, 3, list2);
            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();
            Ring.SetItemACL(deflt, 3, acl_list);
        }