Пример #1
0
 public ActiveFile(ActiveFile activeFile, ActiveFileStatus status)
 {
     if (activeFile == null)
     {
         throw new ArgumentNullException("activeFile");
     }
     Initialize(activeFile);
     Status = status;
 }
Пример #2
0
 public ActiveFile(ActiveFile activeFile, DateTime lastEncryptionWriteTimeUtc, ActiveFileStatus status)
 {
     if (activeFile == null)
     {
         throw new ArgumentNullException("activeFile");
     }
     Initialize(activeFile);
     Properties = new ActiveFileProperties(activeFile.Properties.LastActivityTimeUtc, lastEncryptionWriteTimeUtc, activeFile.Properties.CryptoId);
     Status     = status;
 }
Пример #3
0
 private void Initialize(IDataStore encryptedFileInfo, IDataStore decryptedFileInfo, LogOnIdentity identity, SymmetricKeyThumbprint thumbprint, ActiveFileStatus status, ActiveFileProperties properties)
 {
     EncryptedFileInfo = New <IDataStore>(encryptedFileInfo.FullName);
     DecryptedFileInfo = New <IDataStore>(decryptedFileInfo.FullName);
     Identity          = identity;
     Thumbprint        = thumbprint;
     Status            = status;
     Properties        = new ActiveFileProperties(New <INow>().Utc, properties.LastEncryptionWriteTimeUtc, properties.CryptoId);
     IsShared          = EncryptedFileInfo.IsKeyShared(Identity);
 }
Пример #4
0
 public ActiveFile(ActiveFile activeFile, ActiveFileStatus status, ILauncher process)
 {
     if (activeFile == null)
     {
         throw new ArgumentNullException("activeFile");
     }
     Initialize(activeFile);
     Status = status;
     Process = process;
 }
Пример #5
0
 public ActiveFile(ActiveFile activeFile, ActiveFileStatus status, ILauncher process)
 {
     if (activeFile == null)
     {
         throw new ArgumentNullException("activeFile");
     }
     Initialize(activeFile);
     Status  = status;
     Process = process;
 }
Пример #6
0
 public ActiveFile(ActiveFile activeFile, DateTime lastEncryptionWriteTimeUtc, ActiveFileStatus status)
 {
     if (activeFile == null)
     {
         throw new ArgumentNullException("activeFile");
     }
     Initialize(activeFile);
     LastEncryptionWriteTimeUtc = lastEncryptionWriteTimeUtc;
     Status = status;
 }
Пример #7
0
        private async Task <FileOperationContext> LaunchApplicationForDocument(ActiveFile destinationActiveFile, FileLock decryptedLock)
        {
            ActiveFileStatus status = ActiveFileStatus.AssumedOpenAndDecrypted;
            ILauncher        process;

            try
            {
                if (Resolve.Log.IsInfoEnabled)
                {
                    Resolve.Log.LogInfo("Starting process for '{0}'".InvariantFormat(decryptedLock.DataStore.FullName));
                }
                process = New <ILauncher>();
                process.Launch(decryptedLock.DataStore.FullName);
                if (process.WasStarted)
                {
                    process.Exited += new EventHandler(process_Exited);
                }
                else
                {
                    status |= ActiveFileStatus.NoProcessKnown;
                    if (Resolve.Log.IsInfoEnabled)
                    {
                        Resolve.Log.LogInfo("Starting process for '{0}' did not start a process, assumed handled by the shell.".InvariantFormat(decryptedLock.DataStore.FullName));
                    }
                }
            }
            catch (Exception ex)
            {
                New <IReport>().Exception(ex);
                if (Resolve.Log.IsErrorEnabled)
                {
                    Resolve.Log.LogError("Could not launch application for '{0}', Exception was '{1}'.".InvariantFormat(decryptedLock.DataStore.FullName, ex.Message));
                }
                return(new FileOperationContext(decryptedLock.DataStore.FullName, ErrorStatus.CannotStartApplication));
            }

            if (Resolve.Log.IsWarningEnabled)
            {
                if (process.HasExited)
                {
                    Resolve.Log.LogWarning("The process seems to exit immediately for '{0}'".InvariantFormat(decryptedLock.DataStore.FullName));
                }
            }

            if (Resolve.Log.IsInfoEnabled)
            {
                Resolve.Log.LogInfo("Launched and opened '{0}'.".InvariantFormat(decryptedLock.DataStore.FullName));
            }

            destinationActiveFile = new ActiveFile(destinationActiveFile, status);
            _fileSystemState.Add(destinationActiveFile, process);
            await _fileSystemState.Save();

            return(new FileOperationContext(String.Empty, ErrorStatus.Success));
        }
Пример #8
0
 private void Initialize(IRuntimeFileInfo encryptedFileInfo, IRuntimeFileInfo decryptedFileInfo, DateTime lastWriteTimeUtc, AesKey key, AesKeyThumbprint thumbprint, ActiveFileStatus status, ILauncher process)
 {
     EncryptedFileInfo = OS.Current.FileInfo(encryptedFileInfo.FullName);
     DecryptedFileInfo = OS.Current.FileInfo(decryptedFileInfo.FullName);
     Key                        = key;
     Thumbprint                 = thumbprint;
     Status                     = status;
     LastActivityTimeUtc        = OS.Current.UtcNow;
     Process                    = process;
     LastEncryptionWriteTimeUtc = lastWriteTimeUtc;
 }
Пример #9
0
 private void SetRangeInternal(IEnumerable <ActiveFile> activeFiles, ActiveFileStatus mask)
 {
     _activeFilesByDecryptedPath = new Dictionary <string, ActiveFile>();
     _activeFilesByEncryptedPath = new Dictionary <string, ActiveFile>();
     foreach (ActiveFile activeFile in activeFiles)
     {
         ActiveFile thisActiveFile = activeFile;
         if ((activeFile.Status & mask) != 0)
         {
             thisActiveFile = new ActiveFile(activeFile, activeFile.Status & ~mask, null);
         }
         AddInternal(thisActiveFile);
     }
 }
Пример #10
0
 private void SetRangeInternal(IEnumerable <ActiveFile> activeFiles, ActiveFileStatus mask)
 {
     lock (_activeFilesByEncryptedPath)
     {
         _activeFilesByEncryptedPath.Clear();
     }
     foreach (ActiveFile activeFile in activeFiles)
     {
         ActiveFile thisActiveFile = activeFile;
         if ((activeFile.Status & mask) != 0)
         {
             thisActiveFile = new ActiveFile(activeFile, activeFile.Status & ~mask);
         }
         AddInternal(thisActiveFile);
     }
 }
Пример #11
0
 public static bool HasMask(this ActiveFileStatus status, ActiveFileStatus mask)
 {
     return((status & mask) == mask);
 }
Пример #12
0
 public ActiveFile(ActiveFile activeFile, DateTime lastEncryptionWriteTimeUtc, ActiveFileStatus status)
 {
     if (activeFile == null)
     {
         throw new ArgumentNullException("activeFile");
     }
     Initialize(activeFile);
     LastEncryptionWriteTimeUtc = lastEncryptionWriteTimeUtc;
     Status = status;
 }
Пример #13
0
 public ActiveFile(ActiveFile activeFile, ActiveFileStatus status)
 {
     if (activeFile == null)
     {
         throw new ArgumentNullException("activeFile");
     }
     Initialize(activeFile);
     Status = status;
 }
Пример #14
0
 public ActiveFile(IDataStore encryptedFileInfo, IDataStore decryptedFileInfo, LogOnIdentity key, ActiveFileStatus status, Guid cryptoId)
 {
     if (encryptedFileInfo == null)
     {
         throw new ArgumentNullException("encryptedFileInfo");
     }
     if (decryptedFileInfo == null)
     {
         throw new ArgumentNullException("decryptedFileInfo");
     }
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     Initialize(encryptedFileInfo, decryptedFileInfo, key, null, status, new ActiveFileProperties(New <INow>().Utc, encryptedFileInfo.LastWriteTimeUtc, cryptoId));
 }
Пример #15
0
 private void Initialize(IRuntimeFileInfo encryptedFileInfo, IRuntimeFileInfo decryptedFileInfo, DateTime lastWriteTimeUtc, AesKey key, AesKeyThumbprint thumbprint, ActiveFileStatus status, ILauncher process)
 {
     EncryptedFileInfo = OS.Current.FileInfo(encryptedFileInfo.FullName);
     DecryptedFileInfo = OS.Current.FileInfo(decryptedFileInfo.FullName);
     Key = key;
     Thumbprint = thumbprint;
     Status = status;
     LastActivityTimeUtc = OS.Current.UtcNow;
     Process = process;
     LastEncryptionWriteTimeUtc = lastWriteTimeUtc;
 }
Пример #16
0
 public ActiveFile(IRuntimeFileInfo encryptedFileInfo, IRuntimeFileInfo decryptedFileInfo, AesKey key, ActiveFileStatus status, ILauncher process)
 {
     if (encryptedFileInfo == null)
     {
         throw new ArgumentNullException("encryptedFileInfo");
     }
     if (decryptedFileInfo == null)
     {
         throw new ArgumentNullException("decryptedFileInfo");
     }
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     Initialize(encryptedFileInfo, decryptedFileInfo, decryptedFileInfo.LastWriteTimeUtc, key, null, status, process);
 }
Пример #17
0
 public ActiveFile(IRuntimeFileInfo encryptedFileInfo, IRuntimeFileInfo decryptedFileInfo, AesKey key, ActiveFileStatus status, ILauncher process)
 {
     if (encryptedFileInfo == null)
     {
         throw new ArgumentNullException("encryptedFileInfo");
     }
     if (decryptedFileInfo == null)
     {
         throw new ArgumentNullException("decryptedFileInfo");
     }
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     Initialize(encryptedFileInfo, decryptedFileInfo, decryptedFileInfo.LastWriteTimeUtc, key, null, status, process);
 }
Пример #18
0
 public static bool HasMask(this ActiveFileStatus status, ActiveFileStatus mask)
 {
     return (status & mask) == mask;
 }
Пример #19
0
 private void SetRangeInternal(IEnumerable<ActiveFile> activeFiles, ActiveFileStatus mask)
 {
     _activeFilesByDecryptedPath = new Dictionary<string, ActiveFile>();
     _activeFilesByEncryptedPath = new Dictionary<string, ActiveFile>();
     foreach (ActiveFile activeFile in activeFiles)
     {
         ActiveFile thisActiveFile = activeFile;
         if ((activeFile.Status & mask) != 0)
         {
             thisActiveFile = new ActiveFile(activeFile, activeFile.Status & ~mask, null);
         }
         AddInternal(thisActiveFile);
     }
 }