public void Test_Encrypt2_Int()
        {
            var key = "!mysecretkey#9^5usdk39d&dlf)03sL";

            var config = new ClientConfiguration(TestConfiguration.GetConfiguration());

            config.EnableFieldEncryption(new AesCryptoProvider(new InsecureKeyStore(
                                                                   new KeyValuePair <string, string>("mypublickey", key),
                                                                   new KeyValuePair <string, string>("myauthsecret", "myauthpassword")))
            {
                PublicKeyName  = "mypublickey",
                PrivateKeyName = "myauthsecret"
            });

            using (var cluster = new Cluster(config))
            {
                cluster.Authenticate("Administrator", "password");
                var bucket = cluster.OpenBucket();

                var poco = new PocoWithInt()
                {
                    Message = 10
                };
                var result = bucket.Upsert("thepoco2_int_", poco);

                Assert.True(result.Success);

                var get = bucket.Get <Poco2>("thepoco2");
                Assert.True(get.Success);
            }
        }
        public void Test_Encrypt_NestedObject()
        {
            var key = "!mysecretkey#9^5usdk39d&dlf)03sL";

            var config = new ClientConfiguration(TestConfiguration.GetConfiguration());

            config.EnableFieldEncryption(new AesCryptoProvider(new InsecureKeyStore(
                                                                   new KeyValuePair <string, string>("mypublickey", key),
                                                                   new KeyValuePair <string, string>("myauthsecret", "myauthpassword")))
            {
                PublicKeyName  = "mypublickey",
                PrivateKeyName = "myauthsecret"
            });

            using (var cluster = new Cluster(config))
            {
                cluster.Authenticate("Administrator", "password");
                var bucket = cluster.OpenBucket();

                var poco = new PocoWithObject
                {
                    Message = new InnerObject
                    {
                        MyInt   = 10,
                        MyValue = "The old grey goose jumped over the wrickety gate."
                    }
                };
                var result = bucket.Upsert("mypocokey", poco);

                var get = bucket.Get <PocoWithObject>("mypocokey");
            }
        }
Esempio n. 3
0
        public void Test_EnableFieldEncryption()
        {
            var config = new ClientConfiguration();

            config.EnableFieldEncryption(new AesCryptoProvider(new InsecureKeyStore("thekeyname", "thekey")));

            Assert.IsType <EncryptedFieldSerializer>(config.Serializer());
        }
Esempio n. 4
0
        public void Test_Encrypt_String()
        {
            using (var aes = Aes.Create())
            {
                aes.GenerateKey();
                var key = Encoding.Unicode.GetString(aes.Key);

                var config = new ClientConfiguration
                {
                    Servers = new List <Uri>
                    {
                        new Uri("http://10.142.171.101:8091/")
                    }
                };
                config.EnableFieldEncryption(new AesCryptoProvider(new InsecureKeyStore("mypublickey", key))
                {
                    KeyName = "mypublickey"
                });

                using (var cluster = new Cluster(config))
                {
                    cluster.Authenticate("Administrator", "password");
                    var bucket = cluster.OpenBucket();

                    var poco = new Poco
                    {
                        Bar         = "Bar",
                        Foo         = 90,
                        ChildObject = new PocoMoco
                        {
                            Bar = "Bar2"
                        },
                        Fizz = "fizz",
                        Baz  = new List <int> {
                            3, 4
                        }
                    };

                    var result = bucket.Upsert("thepoco", poco);

                    Assert.True(result.Success);

                    var get = bucket.Get <Poco>("thepoco");
                    Assert.True(get.Success);
                    Assert.Equal("Bar", get.Value.Bar);
                    Assert.Equal(90, get.Value.Foo);
                    Assert.Equal(new List <int> {
                        3, 4
                    }, get.Value.Baz);
                    Assert.Equal("Bar2", get.Value.ChildObject.Bar);
                }
            }
        }
        public void Test_Encrypt_String()
        {
            var key = "!mysecretkey#9^5usdk39d&dlf)03sL";

            var config = new ClientConfiguration(TestConfiguration.GetConfiguration());

            config.EnableFieldEncryption(new AesCryptoProvider(new InsecureKeyStore(
                                                                   new KeyValuePair <string, string>("publickey", key),
                                                                   new KeyValuePair <string, string>("mysecret", "myauthpassword")))
            {
                PublicKeyName  = "publickey",
                PrivateKeyName = "mysecret"
            });

            using (var cluster = new Cluster(config))
            {
                cluster.Authenticate("Administrator", "password");
                var bucket = cluster.OpenBucket();
                var poco   = new Poco
                {
                    Bar         = "Bar",
                    Foo         = 90,
                    ChildObject = new PocoMoco
                    {
                        Bar = "Bar2"
                    },
                    Fizz = "fizz",
                    Baz  = new List <int> {
                        3, 4
                    }
                };

                var result = bucket.Upsert("thepoco", poco);

                Assert.True(result.Success);

                var get = bucket.Get <Poco>("thepoco");
                Assert.True(get.Success);
                Assert.Equal("Bar", get.Value.Bar);
                Assert.Equal(90, get.Value.Foo);
                Assert.Equal(new List <int> {
                    3, 4
                }, get.Value.Baz);
                Assert.Equal("Bar2", get.Value.ChildObject.Bar);
            }
        }
        public void Test_Encrypt_Array()
        {
            var key = "!mysecretkey#9^5usdk39d&dlf)03sL";

            var config = new ClientConfiguration(TestConfiguration.GetConfiguration());

            config.EnableFieldEncryption(new AesCryptoProvider(new InsecureKeyStore(
                                                                   new KeyValuePair <string, string>("mypublickey", key),
                                                                   new KeyValuePair <string, string>("myauthsecret", "myauthpassword")))
            {
                PublicKeyName  = "mypublickey",
                PrivateKeyName = "myauthsecret"
            });

            using (var cluster = new Cluster(config))
            {
                cluster.Authenticate("Administrator", "password");
                var bucket = cluster.OpenBucket();

                var poco = new PocoWithArray()
                {
                    Message = new List <string>
                    {
                        "The",
                        "Old",
                        "Grey",
                        "Goose",
                        "Jumped",
                        "over",
                        "the",
                        "wrickety",
                        "gate"
                    }
                };
                var result = bucket.Upsert("pocowitharray_", poco);

                Assert.True(result.Success);

                var get = bucket.Get <PocoWithArray>("pocowitharray");
                Assert.True(get.Success);
            }
        }