public void ClearAnyRemnantKeys() { var keyLocation = new PasswordEncryptionKeyLocation(CatalogueRepository); if (keyLocation.GetKeyFileLocation() != null) { keyLocation.DeleteKey(); } }
public void NoKeyFileToStartWith() { var keyLocation = new PasswordEncryptionKeyLocation(CatalogueRepository); //there shouldn't already be a key Assert.IsNull(keyLocation.GetKeyFileLocation()); var e = Assert.Throws <NotSupportedException>(keyLocation.DeleteKey); Assert.AreEqual("Cannot delete key because there is no key file configured", e.Message); }
protected override void SetUp() { base.SetUp(); var keyLocation = new PasswordEncryptionKeyLocation(CatalogueRepository); if (keyLocation.GetKeyFileLocation() != null) { keyLocation.DeleteKey(); } }
protected override void SetUp() { base.SetUp(); var keyLocation = new PasswordEncryptionKeyLocation(CatalogueRepository); if (keyLocation.GetKeyFileLocation() != null) { Assert.Inconclusive(); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (VisualStudioDesignMode) //dont go looking up the key if you are visual studio in designer mode! { return; } _location = new PasswordEncryptionKeyLocation((CatalogueRepository)Activator.RepositoryLocator.CatalogueRepository); SetEnabledness(); }
public void CreateKeyFile() { var keyLocation = new PasswordEncryptionKeyLocation(CatalogueRepository); var file = keyLocation.CreateNewKeyFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "my.key")); Console.WriteLine("Key file location is:" + file.FullName); Console.WriteLine("Text put into file is:" + Environment.NewLine + File.ReadAllText(file.FullName)); Assert.IsTrue(file.FullName.EndsWith("my.key")); Assert.AreEqual(file.FullName, keyLocation.GetKeyFileLocation()); keyLocation.DeleteKey(); Assert.IsNull(keyLocation.GetKeyFileLocation()); }
public ExecuteCommandCreatePrivateKey(IBasicActivateItems activator, FileInfo keyFileToCreate) : base(activator) { _keyFileToCreate = keyFileToCreate; _encryption = activator.RepositoryLocator.CatalogueRepository.EncryptionManager as PasswordEncryptionKeyLocation; if (_encryption == null) { SetImpossible("Current Encryption manager is not based on key files"); return; } var existing = _encryption.GetKeyFileLocation(); if (existing != null) { SetImpossible($"There is already a key file at '{existing}'"); } }
public void Encrypt() { string value = "MyPieceOfText"; Console.WriteLine("String is:" + value); EncryptedString encrypter = new EncryptedString(CatalogueRepository); Assert.IsFalse(encrypter.IsStringEncrypted(value)); //should do pass through encryption encrypter.Value = value; Assert.AreNotEqual(value, encrypter.Value); Assert.AreEqual(value, encrypter.GetDecryptedValue()); Console.WriteLine("Encrypted (stock) is:" + encrypter.Value); Console.WriteLine("Decrypted (stock) is:" + encrypter.GetDecryptedValue()); var keyLocation = new PasswordEncryptionKeyLocation(CatalogueRepository); keyLocation.CreateNewKeyFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "my.key")); var p = keyLocation.OpenKeyFile(); CatalogueRepository.EncryptionManager.ClearAllInjections(); var s = CatalogueRepository.EncryptionManager.GetEncrypter(); var exception = Assert.Throws <CryptographicException>(() => s.Decrypt(encrypter.Value)); Assert.IsTrue(exception.Message.StartsWith("Could not decrypt an encrypted string, possibly you are trying to decrypt it after having changed the PrivateKey ")); string encrypted = s.Encrypt(value); Console.WriteLine("Encrypted (with key) is:" + encrypted); Console.WriteLine("Decrypted (with key) is:" + s.Decrypt(encrypted)); Assert.IsTrue(encrypter.IsStringEncrypted(encrypted)); keyLocation.DeleteKey(); }
/// <summary> /// Sets up an <see cref="IRepository"/> which connects to the database <paramref name="catalogueConnectionString"/> to fetch/create <see cref="DatabaseEntity"/> objects. /// </summary> /// <param name="catalogueConnectionString"></param> public CatalogueRepository(DbConnectionStringBuilder catalogueConnectionString) : base(null, catalogueConnectionString) { AggregateForcedJoinManager = new AggregateForcedJoin(this); GovernanceManager = new GovernanceManager(this); TableInfoCredentialsManager = new TableInfoCredentialsManager(this); JoinManager = new JoinManager(this); CohortContainerManager = new CohortContainerManager(this); MEF = new MEF(); FilterManager = new AggregateFilterManager(this); EncryptionManager = new PasswordEncryptionKeyLocation(this); PluginManager = new PluginManager(this); CommentStore = new CommentStoreWithKeywords(); ObscureDependencyFinder = new CatalogueObscureDependencyFinder(this); //Shortcuts to improve performance of ConstructEntity (avoids reflection) Constructors.Add(typeof(Catalogue), (rep, r) => new Catalogue((ICatalogueRepository)rep, r)); Constructors.Add(typeof(CohortAggregateContainer), (rep, r) => new CohortAggregateContainer((ICatalogueRepository)rep, r)); Constructors.Add(typeof(CohortIdentificationConfiguration), (rep, r) => new CohortIdentificationConfiguration((ICatalogueRepository)rep, r)); Constructors.Add(typeof(GovernanceDocument), (rep, r) => new GovernanceDocument((ICatalogueRepository)rep, r)); Constructors.Add(typeof(GovernancePeriod), (rep, r) => new GovernancePeriod((ICatalogueRepository)rep, r)); Constructors.Add(typeof(StandardRegex), (rep, r) => new StandardRegex((ICatalogueRepository)rep, r)); Constructors.Add(typeof(AnyTableSqlParameter), (rep, r) => new AnyTableSqlParameter((ICatalogueRepository)rep, r)); Constructors.Add(typeof(Curation.Data.Plugin), (rep, r) => new Curation.Data.Plugin((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ANOTable), (rep, r) => new ANOTable((ICatalogueRepository)rep, r)); Constructors.Add(typeof(AggregateConfiguration), (rep, r) => new AggregateConfiguration((ICatalogueRepository)rep, r)); Constructors.Add(typeof(AggregateContinuousDateAxis), (rep, r) => new AggregateContinuousDateAxis((ICatalogueRepository)rep, r)); Constructors.Add(typeof(AggregateDimension), (rep, r) => new AggregateDimension((ICatalogueRepository)rep, r)); Constructors.Add(typeof(AggregateFilter), (rep, r) => new AggregateFilter((ICatalogueRepository)rep, r)); Constructors.Add(typeof(AggregateFilterContainer), (rep, r) => new AggregateFilterContainer((ICatalogueRepository)rep, r)); Constructors.Add(typeof(AggregateFilterParameter), (rep, r) => new AggregateFilterParameter((ICatalogueRepository)rep, r)); Constructors.Add(typeof(CatalogueItem), (rep, r) => new CatalogueItem((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ColumnInfo), (rep, r) => new ColumnInfo((ICatalogueRepository)rep, r)); Constructors.Add(typeof(JoinableCohortAggregateConfiguration), (rep, r) => new JoinableCohortAggregateConfiguration((ICatalogueRepository)rep, r)); Constructors.Add(typeof(JoinableCohortAggregateConfigurationUse), (rep, r) => new JoinableCohortAggregateConfigurationUse((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ExternalDatabaseServer), (rep, r) => new ExternalDatabaseServer((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ExtractionFilter), (rep, r) => new ExtractionFilter((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ExtractionFilterParameter), (rep, r) => new ExtractionFilterParameter((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ExtractionInformation), (rep, r) => new ExtractionInformation((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ExtractionFilterParameterSet), (rep, r) => new ExtractionFilterParameterSet((ICatalogueRepository)rep, r)); Constructors.Add(typeof(LoadMetadata), (rep, r) => new LoadMetadata((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ExtractionFilterParameterSetValue), (rep, r) => new ExtractionFilterParameterSetValue((ICatalogueRepository)rep, r)); Constructors.Add(typeof(LoadModuleAssembly), (rep, r) => new LoadModuleAssembly((ICatalogueRepository)rep, r)); Constructors.Add(typeof(LoadProgress), (rep, r) => new LoadProgress((ICatalogueRepository)rep, r)); Constructors.Add(typeof(Favourite), (rep, r) => new Favourite((ICatalogueRepository)rep, r)); Constructors.Add(typeof(Pipeline), (rep, r) => new Pipeline((ICatalogueRepository)rep, r)); Constructors.Add(typeof(Lookup), (rep, r) => new Lookup((ICatalogueRepository)rep, r)); Constructors.Add(typeof(AggregateTopX), (rep, r) => new AggregateTopX((ICatalogueRepository)rep, r)); Constructors.Add(typeof(PipelineComponent), (rep, r) => new PipelineComponent((ICatalogueRepository)rep, r)); Constructors.Add(typeof(LookupCompositeJoinInfo), (rep, r) => new LookupCompositeJoinInfo((ICatalogueRepository)rep, r)); Constructors.Add(typeof(PipelineComponentArgument), (rep, r) => new PipelineComponentArgument((ICatalogueRepository)rep, r)); Constructors.Add(typeof(PreLoadDiscardedColumn), (rep, r) => new PreLoadDiscardedColumn((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ProcessTask), (rep, r) => new ProcessTask((ICatalogueRepository)rep, r)); Constructors.Add(typeof(DashboardLayout), (rep, r) => new DashboardLayout((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ProcessTaskArgument), (rep, r) => new ProcessTaskArgument((ICatalogueRepository)rep, r)); Constructors.Add(typeof(DashboardControl), (rep, r) => new DashboardControl((ICatalogueRepository)rep, r)); Constructors.Add(typeof(DataAccessCredentials), (rep, r) => new DataAccessCredentials((ICatalogueRepository)rep, r)); Constructors.Add(typeof(SupportingDocument), (rep, r) => new SupportingDocument((ICatalogueRepository)rep, r)); Constructors.Add(typeof(DashboardObjectUse), (rep, r) => new DashboardObjectUse((ICatalogueRepository)rep, r)); Constructors.Add(typeof(SupportingSQLTable), (rep, r) => new SupportingSQLTable((ICatalogueRepository)rep, r)); Constructors.Add(typeof(TableInfo), (rep, r) => new TableInfo((ICatalogueRepository)rep, r)); Constructors.Add(typeof(RemoteRDMP), (rep, r) => new RemoteRDMP((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ObjectImport), (rep, r) => new ObjectImport((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ObjectExport), (rep, r) => new ObjectExport((ICatalogueRepository)rep, r)); Constructors.Add(typeof(CacheProgress), (rep, r) => new CacheProgress((ICatalogueRepository)rep, r)); Constructors.Add(typeof(ConnectionStringKeyword), (rep, r) => new ConnectionStringKeyword((ICatalogueRepository)rep, r)); Constructors.Add(typeof(WindowLayout), (rep, r) => new WindowLayout((ICatalogueRepository)rep, r)); Constructors.Add(typeof(PermissionWindow), (rep, r) => new PermissionWindow((ICatalogueRepository)rep, r)); Constructors.Add(typeof(TicketingSystemConfiguration), (rep, r) => new TicketingSystemConfiguration((ICatalogueRepository)rep, r)); Constructors.Add(typeof(CacheFetchFailure), (rep, r) => new CacheFetchFailure((ICatalogueRepository)rep, r)); }