예제 #1
0
        public List <User> GetUsers(bool local)
        {
            var query = _db_main.Table <User>();

            if (local)
            {
                query = query.Where(x => x.OwnerLocalUserId == 0);
            }
            else
            {
                query = query.Where(x => x.OwnerLocalUserId != 0);
            }
            var users = query.ToList();

            foreach (var u in users)
            {
                try
                {
                    u.UserID  = UserId.Decode(DecryptAndVerify(u.UserID_encrypted, u.UserID_hmac, u.Id, EncryptedFieldIds.User_UserID));
                    u.AliasID = BinaryProcedures.DecodeString2UTF8(DecryptAndVerify(u.AliasID_encrypted, u.AliasID_hmac, u.Id, EncryptedFieldIds.User_AliasID));
                    u.LocalUserCertificate = UserCertificate.Decode(DecryptAndVerify(u.LocalUserCertificate_encrypted, u.LocalUserCertificate_hmac, u.Id, EncryptedFieldIds.User_LocalUserCertificate));
                    u.Metadata             = UserMetadata.Decode(DecryptAndVerify(u.Metadata_encrypted, u.Metadata_hmac, u.Id, EncryptedFieldIds.User_Metadata));
                    WriteToLog_deepDetail($"decrypted user '{u.AliasID}'");
                }
                catch (Exception exc)
                {
                    HandleException($"can not decrypt/verify user ID={u.UserID}: ", exc);
                }
            }
            return(users);
            //  var user = db.Get<UserId>(5); // primary key id of 5
        }