Exemplo n.º 1
0
 public virtual void WriteXml(XmlWriter writer)
 {
     writer.WriteAttributeIfString(ATTR.server_url, ServerUrl);
     writer.WriteAttributeIfString(ATTR.username, Username);
     if (!string.IsNullOrEmpty(Password))
     {
         writer.WriteAttributeString(ATTR.password, TextUtil.EncryptString(Password));
     }
 }
Exemplo n.º 2
0
 public override void WriteXml(XmlWriter writer)
 {
     base.WriteXml(writer);
     writer.WriteAttributeIfString(ATTR.identity_server, IdentityServer);
     writer.WriteAttributeIfString(ATTR.client_scope, ClientScope);
     if (ClientSecret != null)
     {
         writer.WriteAttributeIfString(ATTR.client_secret, TextUtil.EncryptString(ClientSecret));
     }
 }
Exemplo n.º 3
0
 public void WriteXml(XmlWriter writer)
 {
     // Write tag attributes
     writer.WriteAttributeString(ATTR.username, Username);
     if (!string.IsNullOrEmpty(Password))
     {
         writer.WriteAttributeString(ATTR.password_encrypted, TextUtil.EncryptString(Password));
     }
     writer.WriteAttribute(ATTR.uri, URI);
 }
Exemplo n.º 4
0
        public void TestDecryptGarbage()
        {
            const string garbageString = "garbage";

            AssertEx.ThrowsException <FormatException>(delegate
            {
                TextUtil.DecryptString(garbageString);
            });
            AssertEx.ThrowsException <CryptographicException>(delegate
            {
                TextUtil.DecryptString(Convert.ToBase64String(Encoding.UTF8.GetBytes(garbageString)));
            });
            Assert.AreEqual(garbageString, TextUtil.DecryptString(TextUtil.EncryptString(garbageString)));
        }
Exemplo n.º 5
0
        public void TestEncryptString()
        {
            const string testString1 = "TestString1";
            const string testString2 = "TestString2";
            string       encrypted1  = TextUtil.EncryptString(testString1);

            byte[] bytes1 = Convert.FromBase64String(encrypted1);
            CollectionAssert.AreNotEqual(bytes1, Encoding.UTF8.GetBytes(testString1));

            string decrypted1 = TextUtil.DecryptString(encrypted1);

            Assert.AreEqual(testString1, decrypted1);

            string encrypted2 = TextUtil.EncryptString(testString2);

            Assert.AreNotEqual(encrypted1, encrypted2);
        }