Example #1
0
        public SynchPoolManager(DataBase db, String defaultSerializerName, IEnumerable <ISerializeFormatProvider> formatProvider)
        {
            DataBase               = db;
            _sPool                 = T.SPool.CreateSubTable(false);
            _formatProviders       = formatProvider;
            _defaultSerializerName = defaultSerializerName;

            KeysContainer = new KeysContainer(((DataBase.table)_sPool.Parent).EncodeType);
        }
Example #2
0
        private bool GetRSA(uint userID, out RSACryptoServiceProvider rsa)
        {
            var result = false;

            rsa = null;

            var key = KeysContainer.GetDecodeKey(userID);

            if (!String.IsNullOrEmpty(key))
            {
                rsa = new RSACryptoServiceProvider();
                rsa.FromXmlString(key);

                result = true;
            }

            return(result);
        }
Example #3
0
        /// <summary>получить шифрованое сообщение</summary>
        public unsafe byte[] GetEncrypted(uint SPoolID)
        {
            var message = new byte[0];
            var uTables = new List <DataBase.ISTable>();

            foreach (var uTable in UTables)
            {
                if (uTable.Use)
                {
                    uTable.Table.QUERRY(DataBase.State.None).SHOW.WHERE.C(uTable.Table.Parent.Columns.Count - 1, SPoolID).DO();

                    if (uTable.Table.Rows.Count > 0)
                    {
                        uTables.Add(uTable.Table);
                    }
                }
            }

            if (uTables.Any())
            {
                var date    = T.SPool.Rows.Get <DateTime>(SPoolID, C.SPool.Date);
                var aUserID = T.SPool.Rows.Get_UnShow <uint>(SPoolID, C.SPool.AUser);

                var key = KeysContainer.GetEncodeKey(aUserID);

                if (!String.IsNullOrEmpty(key))
                {
                    var rsa = new RSACryptoServiceProvider();
                    rsa.FromXmlString(key);

                    var formatProvider = GetSerializeProvider();
                    message = formatProvider.EncodeData(rsa, uTables, date, aUserID);
                }
            }

            return(message);
        }