Beispiel #1
0
        /// <summary>
        /// Sets the database.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="details">The details.</param>
        public void SetDatabase(Stream data, DatabaseDetails details)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }

            using (var store = IsolatedStorageFile
                               .GetUserStoreForApplication())
            {
                if (!store.DirectoryExists(Folder))
                {
                    store.CreateDirectory(Folder);
                }

                ClearPassword(store);

                Details = details;
                SaveDetails(store);

                using (var fs = store.CreateFile(DatabasePath))
                    BufferEx.CopyStream(data, fs);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sets the database.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="details">The details.</param>
        public void SetDatabase(Stream data, DatabaseDetails details)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }

            using (var store = IsolatedStorageFile
                               .GetUserStoreForApplication())
            {
                if (!store.DirectoryExists(Folder))
                {
                    store.CreateDirectory(Folder);
                }

                // Clear password if it was not marked as "save"
                var p = GetSavedPassword(store);
                if (p.MasterKey == null || p.MasterKey.Length == 0)
                {
                    ClearPassword(store);
                }

                Details = details;
                SaveDetails(store);

                using (var fs = store.CreateFile(DatabasePath))
                    BufferEx.CopyStream(data, fs);
            }
        }
Beispiel #3
0
        private static void Upgrade(IsolatedStorageFile store)
        {
            var files = new List <string>(
                store.GetFileNames());

            if (!files.Contains("Database.kdbx"))
            {
                return;
            }

            var appSettings = IsolatedStorageSettings
                              .ApplicationSettings;

            string url;

            if (!appSettings.TryGetValue("Url", out url))
            {
                url = null;
            }

            var info = new DatabaseInfo();

            using (var fs = store.OpenFile("Database.kdbx", FileMode.Open))
            {
                var source = string.IsNullOrEmpty(url)
                    ? "7Pass" : DatabaseUpdater.WEB_UPDATER;

                var details = new DatabaseDetails
                {
                    Url    = url,
                    Source = source,
                    Type   = SourceTypes.OneTime,
                    Name   = "7Pass 1.x database",
                };

                info.SetDatabase(fs, details);
            }

            store.DeleteFile("Database.kdbx");
            store.DeleteFile("Protection.bin");
            store.DeleteFile("Decrypted.xml");
        }
Beispiel #4
0
        private static void Upgrade(IsolatedStorageFile store)
        {
            var files = new List<string>(
                store.GetFileNames());

            if (!files.Contains("Database.kdbx"))
                return;

            var appSettings = IsolatedStorageSettings
                .ApplicationSettings;

            string url;
            if (!appSettings.TryGetValue("Url", out url))
                url = null;

            var info = new DatabaseInfo();

            using (var fs = store.OpenFile("Database.kdbx", FileMode.Open))
            {
                var source = string.IsNullOrEmpty(url)
                    ? "WinPass" : DatabaseUpdater.WEB_UPDATER;

                var details = new DatabaseDetails
                {
                    Url = url,
                    Source = source,
                    Type = SourceTypes.OneTime,
                    Name = "WinPass 1.x database",
                };

                info.SetDatabase(fs, details);
            }

            store.DeleteFile("Database.kdbx");
            store.DeleteFile("Protection.bin");
            store.DeleteFile("Decrypted.xml");
        }
Beispiel #5
0
        /// <summary>
        /// Sets the database.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="details">The details.</param>
        public void SetDatabase(Stream data, DatabaseDetails details)
        {
            if (data == null) throw new ArgumentNullException("data");
            if (details == null) throw new ArgumentNullException("details");

            using (var store = IsolatedStorageFile
                .GetUserStoreForApplication())
            {
                if (!store.DirectoryExists(Folder))
                    store.CreateDirectory(Folder);
                ClearPassword(store);
                Details = details;
                SaveDetails(store);
                using (var fs = store.CreateFile(DatabasePath))
                    BufferEx.CopyStream(data, fs);
            }
            
        }
Beispiel #6
0
        /// <summary>
        /// Sets the database.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="details">The details.</param>
        public void SetDatabase(Stream data, DatabaseDetails details)
        {
            if (data == null) throw new ArgumentNullException("data");
            if (details == null) throw new ArgumentNullException("details");

            using (var store = IsolatedStorageFile
                .GetUserStoreForApplication())
            {
                if (!store.DirectoryExists(Folder))
                    store.CreateDirectory(Folder);

                // Clear password if it was not marked as "save"
                var p = GetSavedPassword(store);
                if (p.MasterKey == null || p.MasterKey.Length == 0)
                    ClearPassword(store);

                Details = details;
                SaveDetails(store);

                using (var fs = store.CreateFile(DatabasePath))
                    BufferEx.CopyStream(data, fs);
            }
        }