예제 #1
0
        public static ItemData GetItemInfo(string keyring, int id)
        {
            if (keyring == null)
            {
                throw new ArgumentNullException("keyring");
            }

            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.GetItemInfo, keyring, id);
            ResponseMessage resp   = SendRequest(req.Stream);
            ItemType        itype  = (ItemType)resp.GetInt32();
            ItemData        item   = ItemData.GetInstanceFromItemType(itype);
            string          name   = resp.GetString();
            string          secret = resp.GetString();
            DateTime        mtime  = resp.GetDateTime();
            DateTime        ctime  = resp.GetDateTime();

            item.Keyring = keyring;
            item.ItemID  = id;
            item.Secret  = secret;
            Hashtable tbl = new Hashtable();

            tbl ["name"]          = name;
            tbl ["keyring_ctime"] = ctime;
            tbl ["keyring_mtime"] = mtime;
            item.Attributes       = tbl;
            item.SetValuesFromAttributes();
            return(item);
        }
예제 #2
0
        public static void CreateKeyring(string name, string password)
        {
            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.CreateKeyring, name, password);
            SendRequest(req.Stream);
        }
예제 #3
0
        public static void LockAll()
        {
            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.LockAll);
            SendRequest(req.Stream);
        }
예제 #4
0
        public static string [] GetKeyrings()
        {
            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.ListKeyrings);
            ResponseMessage resp = SendRequest(req.Stream);

            return(resp.GetStringList());
        }
예제 #5
0
        public static string GetDefaultKeyring()
        {
            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.GetDefaultKeyring);
            ResponseMessage resp = SendRequest(req.Stream);

            return(resp.GetString());
        }
예제 #6
0
        public static void SetDefaultKeyring(string newKeyring)
        {
            if (newKeyring == null)
            {
                throw new ArgumentNullException("newKeyring");
            }
            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.SetDefaultKeyring, newKeyring);
            SendRequest(req.Stream);
        }
예제 #7
0
        public static void DeleteItem(string keyring, int id)
        {
            if (keyring == null)
            {
                throw new ArgumentNullException("keyring");
            }

            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.DeleteItem, keyring, id);
            SendRequest(req.Stream);
        }
예제 #8
0
        public static void Lock(string keyring)
        {
            if (keyring == null)
            {
                throw new ArgumentNullException("keyring");
            }

            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.LockKeyring, keyring);
            SendRequest(req.Stream);
        }
예제 #9
0
        public static Hashtable GetItemAttributes(string keyring, int id)
        {
            if (keyring == null)
            {
                throw new ArgumentNullException("keyring");
            }

            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.GetItemAttributes, keyring, id);
            ResponseMessage resp = SendRequest(req.Stream);
            Hashtable       tbl  = new Hashtable();

            resp.ReadAttributes(tbl);
            return(tbl);
        }
예제 #10
0
        public static KeyringInfo GetKeyringInfo(string keyring)
        {
            if (keyring == null)
            {
                throw new ArgumentNullException("keyring");
            }

            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.GetKeyringInfo, keyring);
            ResponseMessage resp = SendRequest(req.Stream);

            return(new KeyringInfo(keyring, (resp.GetInt32() != 0),
                                   resp.GetInt32(),
                                   resp.GetDateTime(),
                                   resp.GetDateTime(),
                                   (resp.GetInt32() != 0)));
        }
예제 #11
0
        public static ArrayList GetItemACL(string keyring, int id)
        {
            if (keyring == null)
            {
                throw new ArgumentNullException("keyring");
            }

            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.GetItemACL, keyring, id);
            ResponseMessage resp  = SendRequest(req.Stream);
            int             count = resp.GetInt32();
            ArrayList       list  = new ArrayList(count);

            for (int i = 0; i < count; i++)
            {
                list.Add(new ItemACL(resp.GetString(), resp.GetString(), (AccessRights)resp.GetInt32()));
            }
            return(list);
        }
예제 #12
0
        public static int [] ListItemIDs(string keyring)
        {
            if (keyring == null)
            {
                throw new ArgumentNullException("keyring");
            }

            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.ListItems, keyring);
            ResponseMessage resp = SendRequest(req.Stream);
            int             len  = resp.GetInt32();

            int [] result = new int [len];
            for (int i = 0; i < len; i++)
            {
                result [i] = resp.GetInt32();
            }

            return(result);
        }
예제 #13
0
        public static void Unlock(string keyring, string password)
        {
            if (keyring == null)
            {
                throw new ArgumentNullException("keyring");
            }

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

            RequestMessage req = new RequestMessage();

            req.CreateSimpleOperation(Operation.UnlockKeyring, keyring, password);
            try {
                SendRequest(req.Stream);
            } catch (KeyringException ke) {
                if (ke.ResultCode != ResultCode.AlreadyUnlocked)
                {
                    throw;
                }
            }
        }
예제 #14
0
		public static Hashtable GetItemAttributes (string keyring, int id)
		{
			if (keyring == null)
				throw new ArgumentNullException ("keyring");

			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.GetItemAttributes, keyring, id);
			ResponseMessage resp = SendRequest (req.Stream);
			Hashtable tbl = new Hashtable ();
			resp.ReadAttributes (tbl);
			return tbl;
		}
예제 #15
0
		public static ItemData GetItemInfo (string keyring, int id)
		{
			if (keyring == null)
				throw new ArgumentNullException ("keyring");

			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.GetItemInfo, keyring, id);
			ResponseMessage resp = SendRequest (req.Stream);
			ItemType itype = (ItemType) resp.GetInt32 ();
			ItemData item = ItemData.GetInstanceFromItemType (itype);
			string name = resp.GetString ();
			string secret = resp.GetString ();
			DateTime mtime = resp.GetDateTime ();
			DateTime ctime =  resp.GetDateTime ();
			item.Keyring = keyring;
			item.ItemID = id;
			item.Secret = secret;
			Hashtable tbl = new Hashtable ();
			tbl ["name"] = name;
			tbl ["keyring_ctime"] = ctime;
			tbl ["keyring_mtime"] = mtime;
			item.Attributes = tbl;
			item.SetValuesFromAttributes ();
			return item;
		}
예제 #16
0
		public static void DeleteItem (string keyring, int id)
		{
			if (keyring == null)
				throw new ArgumentNullException ("keyring");

			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.DeleteItem, keyring, id);
			SendRequest (req.Stream);
		}
예제 #17
0
		public static int [] ListItemIDs (string keyring)
		{
			if (keyring == null)
				throw new ArgumentNullException ("keyring");

			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.ListItems, keyring);
			ResponseMessage resp = SendRequest (req.Stream);
			int len = resp.GetInt32 ();
			int [] result = new int [len];
			for (int i = 0; i < len; i++) {
				result [i] = resp.GetInt32 ();
			}

			return result;
		}
예제 #18
0
		public static void Unlock (string keyring, string password)
		{
			if (keyring == null)
				throw new ArgumentNullException ("keyring");

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

			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.UnlockKeyring, keyring, password);
			try {
				SendRequest (req.Stream);
			} catch (KeyringException ke) {
				if (ke.ResultCode != ResultCode.AlreadyUnlocked)
					throw;
			}
		}
예제 #19
0
		public static void Lock (string keyring)
		{
			if (keyring == null)
				throw new ArgumentNullException ("keyring");

			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.LockKeyring, keyring);
			SendRequest (req.Stream);
		}
예제 #20
0
		public static void CreateKeyring (string name, string password)
		{
			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.CreateKeyring, name, password);
			SendRequest (req.Stream);
		}
예제 #21
0
		public static string [] GetKeyrings ()
		{
			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.ListKeyrings);
			ResponseMessage resp = SendRequest (req.Stream);
			return resp.GetStringList ();
		}
예제 #22
0
		public static string GetDefaultKeyring ()
		{
			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.GetDefaultKeyring);
			ResponseMessage resp = SendRequest (req.Stream);
			return resp.GetString ();
		}
예제 #23
0
		public static void SetDefaultKeyring (string newKeyring)
		{
			if (newKeyring == null)
				throw new ArgumentNullException ("newKeyring");
			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.SetDefaultKeyring, newKeyring);
			SendRequest (req.Stream);
		}
예제 #24
0
		public static KeyringInfo GetKeyringInfo (string keyring)
		{
			if (keyring == null)
				throw new ArgumentNullException ("keyring");

			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.GetKeyringInfo, keyring);
			ResponseMessage resp = SendRequest (req.Stream);
			return new KeyringInfo (keyring, (resp.GetInt32 () != 0),
							resp.GetInt32 (),
							resp.GetDateTime (),
							resp.GetDateTime (),
							(resp.GetInt32 () != 0));
		}
예제 #25
0
		public static ArrayList GetItemACL (string keyring, int id)
		{
			if (keyring == null)
				throw new ArgumentNullException ("keyring");

			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.GetItemACL, keyring, id);
			ResponseMessage resp = SendRequest (req.Stream);
			int count = resp.GetInt32 ();
			ArrayList list = new ArrayList (count);
			for (int i = 0; i < count; i++) {
				list.Add (new ItemACL (resp.GetString (), resp.GetString (), (AccessRights) resp.GetInt32 ()));
			}
			return list;
		}
예제 #26
0
		public static void LockAll ()
		{
			RequestMessage req = new RequestMessage ();
			req.CreateSimpleOperation (Operation.LockAll);
			SendRequest (req.Stream);
		}