Beispiel #1
0
        public KeyValueStorage <byte[]> GetStore(string name)
        {
            if (stores.ContainsKey(name))
            {
                return(stores [name]);
            }
            KeyValueStorage <byte[]> store = new LevelDBKeyValueStorage(path.CreatePath(name));

            System.IO.MemoryStream ms = new System.IO.MemoryStream(repositoryConfigurations.Get
                                                                       (System.Text.Encoding.Unicode.GetBytes(name)));
            System.Xml.Serialization.XmlSerializer xmls = new System.Xml.Serialization.XmlSerializer(typeof(GenericUserRepositoryConfiguration));
            GenericUserRepositoryConfiguration     gurc = (GenericUserRepositoryConfiguration)xmls.Deserialize(ms);

            switch (gurc.EncryptionMehtod)
            {
            case  EncryptionMethod.AES:
                store = new AESEncryptingKeyValueStorage(store, symmetricKeys.Get(gurc.AESKeyID));
                stores.Add(name, store);
                return(store);

            case EncryptionMethod.RSA:
                store = new RSAEncryptingKeyValueStorage(store, rsa.Value);
                stores.Add(name, store);
                return(store);

            case EncryptionMethod.None:
                stores.Add(name, store);
                return(store);

            default:
                throw new NotSupportedException("Specified encryption method is not supported.");
            }
        }
Beispiel #2
0
 public void CreateRepository(string name, GenericUserRepositoryConfiguration configuration)
 {
     byte[] configName         = System.Text.Encoding.Unicode.GetBytes(name);
     System.IO.MemoryStream ms = new System.IO.MemoryStream();
     System.Xml.Serialization.XmlSerializer xmls = new System.Xml.Serialization.XmlSerializer(typeof(GenericUserRepositoryConfiguration));
     xmls.Serialize(ms, configuration);
     repositoryConfigurations.Put(configName, ms.ToArray());
 }