private void DeleteSecureInformation(DatabaseConnection connection)
        {
            _passwordManager.DeleteSecret(SecretType.DatabasePassword.ToString() + "_" + connection.DatabaseConnectionID);

            if (connection.UseSsh && connection.UseSshKey == false)
            {
                _passwordManager.DeleteSecret(SecretType.SSHPassword.ToString() + "_" + connection.DatabaseConnectionID);
            }
        }
Exemple #2
0
        private void ClearOldFiles()
        {
            DateTime threshold = DateTime.Now.AddMinutes(-5);

            var filesToDelete = db.SshKeyFiles
                                .GroupJoin(db.DatabaseConnections, k => k.Id, d => d.SshKeyFileID, (k, ds) => new { SshKeyFile = k, InUse = ds.DefaultIfEmpty().Any() })
                                .Where(_ => _.InUse == false && _.SshKeyFile.CreatedOn < threshold)
                                .Select(_ => _.SshKeyFile)
                                .ToList();

            foreach (var keyFile in filesToDelete)
            {
                _passwordManager.DeleteSecret(SecretType.SshKeyFile.ToString() + "_" + keyFile.Id);
            }

            db.SshKeyFiles.RemoveRange(filesToDelete);
            db.SaveChanges();
        }