public void TestMicrosoftAesStrategyFactory() { var options = new FileSystemOptions("", StreamEncryptionType.MicrosoftAes, StreamCompressionType.None); var encryptionOptions = GetEncryptionOptions(); options.EncryptionKey = encryptionOptions.Key; options.EncryptionInitializationVector = encryptionOptions.InitializationVector; var res = new StramStrategyResolver(options); var s = res.ResolveStrategy(); using (var ms = new MemoryStream()) { var a = s.DecorateToVFS(ms); var b = s.DecorateToHost(ms); Assert.AreNotSame(ms, a); Assert.AreNotSame(ms, b); Assert.IsTrue(a is CryptoStream); Assert.IsTrue(b is CryptoStream); var c = a as CryptoStream; var d = b as CryptoStream; Assert.AreEqual(false, c.CanRead); Assert.AreEqual(true, c.CanWrite); Assert.AreEqual(true, d.CanRead); Assert.AreEqual(false, d.CanWrite); } }
// NOTE: long parameter smell. Are they all needed? If yes: refactoring "introduce parameter object". public BlockList(IIndexNode node, BlockAllocation blockAllocation, FileSystemOptions options, BlockParser blockParser, BlockManipulator blockManipulator, Persistence persistence) { _node = node; _blockAllocation = blockAllocation; _options = options; _blockParser = blockParser; _blockManipulator = blockManipulator; _persistence = persistence; }
public VFSFileStream(VFSFile file, BlockParser blockParser, FileSystemOptions options, BlockAllocation blockAllocation, BlockManipulator blockManipulator, Persistence.Persistence persistence) { _file = file; _blockParser = blockParser; _options = options; _blockAllocation = blockAllocation; _blockManipulator = blockManipulator; _persistence = persistence; _writeBuffer = new byte[_options.BlockSize]; }
internal FileSystem(FileSystemOptions options) { _options = options; _blockManipulator = new BlockManipulator(_options.Location, _options.BlockSize, _options.MasterBlockSize); _blockParser = new BlockParser(_options); _persistence = new Persistence.Persistence(_blockParser, _blockManipulator); _blockAllocation = _options.BlockAllocation; InitializeFileSystem(); }
public void TestApplyEncryptionSettings() { var o = TestHelper.CreateFileSystemOptions(""); var o2 = new FileSystemOptions(o.Location, StreamEncryptionType.None, StreamCompressionType.None); o.EncryptionKey = new byte[] { 1, 2, 3 }; Assert.IsNotNull(o.EncryptionKey); Assert.IsNull(o2.EncryptionKey); o2.ApplyEncryptionSettings(o); Assert.AreEqual(o.EncryptionKey, o2.EncryptionKey); Assert.AreEqual(1, o2.EncryptionKey[0]); Assert.AreEqual(2, o2.EncryptionKey[1]); Assert.AreEqual(3, o2.EncryptionKey[2]); }
internal static IFileSystem Create(FileSystemOptions options, string password) { if (File.Exists(options.Location)) throw new VFSException("File already exists"); using (var file = File.Open(options.Location, FileMode.CreateNew, FileAccess.Write)) { options.InitializePassword(password); IFormatter formatter = new BinaryFormatter(); formatter.Serialize(file, options); } return new ThreadSafeFileSystem(options); }
public BlockParser(FileSystemOptions options) { _options = options; }
public void ApplyEncryptionSettings(FileSystemOptions oldOptions) { if (oldOptions == null) throw new ArgumentNullException("oldOptions"); _encryptedEncryptionKey = oldOptions._encryptedEncryptionKey; EncryptionKey = oldOptions.EncryptionKey; _streamCodingStrategy = oldOptions._streamCodingStrategy; }
public void Reload(FileSystemOptions newOptions) { _lock.EnterWriteLock(); try { _fileSystem.Reload(newOptions); } finally { _lock.ExitWriteLock(); } }
internal ThreadSafeFileSystem(FileSystemOptions options) { _fileSystem = new FileSystem(options); _lock = _fileSystem.GetReadWriteLock(); }
public void TestApplyEncryptionSettingFail() { var o2 = new FileSystemOptions("", StreamEncryptionType.None, StreamCompressionType.None); o2.ApplyEncryptionSettings(null); }
public ConsoleApplication(IConsoleApplicationSettings consoleApplicationSettings, FileSystemOptions options, IFileSystemTextManipulatorFactory factory) : this(consoleApplicationSettings, File.Exists(options.Location) ? factory.Open(options.Location, "console") : factory.Create(options, "console")) { }
public StramStrategyResolver(FileSystemOptions options) { _options = options; }
private void NewVfs(object parameter) { var pathToVFS = ViewModelHelper.ChoosePlaceForNewVFSFile(); if (pathToVFS == null) return; // Close last vfs DisposeManipulator(); var vm = new NewVFSViewModel(); if (vm.ShowDialog() != true) return; try { var fileSystemData = new FileSystemOptions(pathToVFS, vm.EncryptionType, vm.CompressionType); _manipulator = _container.Resolve<IFileSystemTextManipulatorFactory>().Create(fileSystemData, vm.Password); _manipulator.FileSystemChanged += FileSystemChanged; CurrentPath = new DirectoryPath(); OnPropertyChanged("FileSystemName"); } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } UpdateVersion(); }
public IFileSystemTextManipulator Create(FileSystemOptions options, string password) { var fileSystem = FileSystemFactory.Create(options, password); fileSystem.TestEncryptionKey(); return new ThreadSafeFileSystemTextManipulator(fileSystem); }
public void Reload(FileSystemOptions newOptions) { newOptions.ApplyEncryptionSettings(_options); _options = newOptions; _blockAllocation = _options.BlockAllocation; // TODO: reload indexing service // SearchService.StartIndexing(_searchService, this); Root = LatestRoot = ImportRootFolder(); }