Beispiel #1
0
        public AppJsonEncryptionImplTest()
        {
            partition = new Partition("PARTITION", "SYSTEM", "PRODUCT");
            Dictionary <string, JObject> memoryPersistence = new Dictionary <string, JObject>();

            dataPersistence = new AdhocPersistence <JObject>(
                key => memoryPersistence.TryGetValue(key, out JObject result) ? result : Option <JObject> .None,
                (key, jsonObject) => memoryPersistence.Add(key, jsonObject));

            metastore            = new InMemoryMetastoreImpl <JObject>();
            keyManagementService = new DummyKeyManagementService();

            AeadEnvelopeCrypto aeadEnvelopeCrypto = new BouncyAes256GcmCrypto();

            // Generate a dummy systemKey document
            CryptoKey systemKey = aeadEnvelopeCrypto.GenerateKey();

            byte[] encryptedSystemKey = keyManagementService.EncryptKey(systemKey);

            EnvelopeKeyRecord systemKeyRecord = new EnvelopeKeyRecord(DateTimeOffset.UtcNow, null, encryptedSystemKey);

            // Write out the dummy systemKey record
            memoryPersistence.TryAdd(partition.SystemKeyId, systemKeyRecord.ToJson());
        }