Beispiel #1
0
        private ConnectionTreeModel SetupConnectionTreeModel()
        {
            /*
             * Root
             * |--- con0
             * |--- folder1
             * |    L--- con1
             * L--- folder2
             *      |--- con2
             *      L--- folder3
             *           |--- con3
             *           L--- con4
             */
            BuildTreeNodes();
            var connectionTreeModel = new ConnectionTreeModel();
            var rootNode            = new RootNodeInfo(RootNodeType.Connection);

            rootNode.AddChild(_folder1);
            rootNode.AddChild(_folder2);
            rootNode.AddChild(_con0);
            _folder1.AddChild(_con1);
            _folder2.AddChild(_con2);
            _folder2.AddChild(_folder3);
            _folder3.AddChild(_con3);
            _folder3.AddChild(_con4);
            connectionTreeModel.AddRootNode(rootNode);
            return(connectionTreeModel);
        }
Beispiel #2
0
 public void Setup()
 {
     _rootNodeSerializer   = new XmlRootNodeSerializer();
     _cryptographyProvider = new AeadCryptographyProvider();
     _rootNodeInfo         = new RootNodeInfo(RootNodeType.Connection);
     _version = new Version(99, 1);
 }
        private ConnectionTreeModel CreateNodeHierarchy(List <ConnectionInfo> connectionList, DataTable dataTable)
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var rootNode            = new RootNodeInfo(RootNodeType.Connection, "0")
            {
                PasswordString = _decryptionKey.ConvertToUnsecureString()
            };

            connectionTreeModel.AddRootNode(rootNode);

            foreach (DataRow row in dataTable.Rows)
            {
                var id             = (string)row["ConstantID"];
                var connectionInfo = connectionList.First(node => node.ConstantID == id);
                var parentId       = (string)row["ParentID"];
                if (parentId == "0" || connectionList.All(node => node.ConstantID != parentId))
                {
                    rootNode.AddChild(connectionInfo);
                }
                else
                {
                    (connectionList.First(node => node.ConstantID == parentId) as ContainerInfo)?.AddChild(
                        connectionInfo);
                }
            }

            return(connectionTreeModel);
        }
Beispiel #4
0
        private ConnectionTreeModel CreateNodeHierarchy(List <ConnectionInfo> connectionList)
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var rootNode            = new RootNodeInfo(RootNodeType.Connection)
            {
                ConstantID = "0"
            };

            connectionTreeModel.AddRootNode(rootNode);

            foreach (DataRow row in _dataTable.Rows)
            {
                var id             = (string)row["ConstantID"];
                var connectionInfo = connectionList.First(node => node.ConstantID == id);
                var parentId       = (string)row["ParentID"];
                if (parentId == "0")
                {
                    rootNode.AddChild(connectionInfo);
                }
                else
                {
                    (connectionList.First(node => node.ConstantID == parentId) as ContainerInfo)?.AddChild(connectionInfo);
                }
            }
            return(connectionTreeModel);
        }
Beispiel #5
0
        public void ExpandingAllItemsUpdatesColumnWidthAppropriately()
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);

            connectionTreeModel.AddRootNode(root);
            ContainerInfo parent = root;

            foreach (var i in Enumerable.Repeat("", 8))
            {
                var newContainer = new ContainerInfo {
                    IsExpanded = false
                };
                parent.AddChild(newContainer);
                parent = newContainer;
            }

            _connectionTree.ConnectionTreeModel = connectionTreeModel;

            var widthBefore = _connectionTree.Columns[0].Width;

            _connectionTree.ExpandAll();
            var widthAfter = _connectionTree.Columns[0].Width;

            Assert.That(widthAfter, Is.GreaterThan(widthBefore));
        }
        public ConnectionTreeModel Deserialize()
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);

            connectionTreeModel.AddRootNode(root);
            var connectionInfo = new ConnectionInfo();

            foreach (var line in _fileContent)
            {
                var parts = line.Split(new[] { ':' }, 3);
                if (parts.Length < 3)
                {
                    continue;
                }

                var key   = parts[0];
                var value = parts[2];

                SetConnectionInfoParameter(connectionInfo, key, value);
            }
            root.AddChild(connectionInfo);

            return(connectionTreeModel);
        }
 private ConnectionTreeModel SetupConnectionTreeModel()
 {
     /*
      * Root
      * |--- con0
      * |--- folder1
      * |    L--- con1
      * L--- folder2
      *      |--- con2
      *      L--- folder3
      *           |--- con3
      *           L--- con4
      */
     var connectionTreeModel = new ConnectionTreeModel();
     var rootNode = new RootNodeInfo(RootNodeType.Connection);
     var folder1 = new ContainerInfo { Name = "folder1" };
     var folder2 = new ContainerInfo { Name = "folder2" };
     var folder3 = new ContainerInfo { Name = "folder3" };
     var con0 = new ConnectionInfo { Name = "con0" };
     var con1 = new ConnectionInfo { Name = "con1" };
     var con2 = new ConnectionInfo { Name = "con2" };
     var con3 = new ConnectionInfo { Name = "con3" };
     var con4 = new ConnectionInfo { Name = "con4" };
     rootNode.AddChild(folder1);
     rootNode.AddChild(folder2);
     rootNode.AddChild(con0);
     folder1.AddChild(con1);
     folder2.AddChild(con2);
     folder2.AddChild(folder3);
     folder3.AddChild(con3);
     folder3.AddChild(con4);
     connectionTreeModel.AddRootNode(rootNode);
     return connectionTreeModel;
 }
Beispiel #8
0
 public XmlConnectionsDecryptor(BlockCipherEngines blockCipherEngine,
                                BlockCipherModes blockCipherMode,
                                RootNodeInfo rootNodeInfo)
 {
     _cryptographyProvider = new CryptoProviderFactory(blockCipherEngine, blockCipherMode).Build();
     _rootNodeInfo         = rootNodeInfo;
 }
Beispiel #9
0
        private void UpdateRootNodeTable(RootNodeInfo rootTreeNode, SqlDatabaseConnector sqlDatabaseConnector)
        {
            var    cryptographyProvider = new LegacyRijndaelCryptographyProvider();
            string strProtected;

            if (rootTreeNode != null)
            {
                if (rootTreeNode.Password)
                {
                    _password    = Convert.ToString(rootTreeNode.PasswordString).ConvertToSecureString();
                    strProtected = cryptographyProvider.Encrypt("ThisIsProtected", _password);
                }
                else
                {
                    strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", _password);
                }
            }
            else
            {
                strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", _password);
            }

            var sqlQuery = new SqlCommand("DELETE FROM tblRoot", sqlDatabaseConnector.SqlConnection);

            sqlQuery.ExecuteNonQuery();

            sqlQuery = new SqlCommand("INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES(\'" + MiscTools.PrepareValueForDB(rootTreeNode.Name) + "\', 0, \'" + strProtected + "\'," + ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture) + ")", sqlDatabaseConnector.SqlConnection);
            sqlQuery.ExecuteNonQuery();
        }
Beispiel #10
0
        private void SerializeRootNodeInfo(RootNodeInfo rootNodeInfo)
        {
            _xmlTextWriter.WriteStartElement("Connections"); // Do not localize
            _xmlTextWriter.WriteAttributeString("Name", "", rootNodeInfo.Name);
            _xmlTextWriter.WriteAttributeString("Export", "", Convert.ToString(Export));
            var cipherEngine = Enum.GetName(typeof(BlockCipherEngines), mRemoteNG.Settings.Default.EncryptionEngine);

            _xmlTextWriter.WriteAttributeString("EncryptionEngine", "", cipherEngine ?? "");
            var cipherMode = Enum.GetName(typeof(BlockCipherModes), mRemoteNG.Settings.Default.EncryptionBlockCipherMode);

            _xmlTextWriter.WriteAttributeString("BlockCipherMode", "", cipherMode ?? "");
            _xmlTextWriter.WriteAttributeString("KdfIterations", "", mRemoteNG.Settings.Default.EncryptionKeyDerivationIterations.ToString());
            _xmlTextWriter.WriteAttributeString("FullFileEncryption", "", UseFullEncryption.ToString());

            if (Export)
            {
                _xmlTextWriter.WriteAttributeString("Protected", "", _cryptographyProvider.Encrypt("ThisIsNotProtected", _password));
            }
            else
            {
                if (rootNodeInfo.Password)
                {
                    _password = rootNodeInfo.PasswordString.ConvertToSecureString();
                    _xmlTextWriter.WriteAttributeString("Protected", "", _cryptographyProvider.Encrypt("ThisIsProtected", _password));
                }
                else
                {
                    _xmlTextWriter.WriteAttributeString("Protected", "", _cryptographyProvider.Encrypt("ThisIsNotProtected", _password));
                }
            }

            _xmlTextWriter.WriteAttributeString("ConfVersion", "", ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture));
        }
        private ConnectionTreeModel SetupConnectionTreeModel()
        {
            /*
             * Tree:
             * Root
             * |--- folder1
             * |    |--- con1
             * |    L--- con2
             * |--- folder2
             * |    |--- con3
             * |    L--- con4
             * L--- con5
             *
             */
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);
            _folder1 = new ContainerInfo { Name = "folder1"};
            _con1 = new ConnectionInfo { Name = "con1"};
            _con2 = new ConnectionInfo { Name = "con2"};
            _folder2 = new ContainerInfo { Name = "folder2" };
            _con3 = new ConnectionInfo { Name = "con3" };
            _con4 = new ConnectionInfo { Name = "con4" };
            _con5 = new ConnectionInfo { Name = "con5" };

            connectionTreeModel.AddRootNode(root);
            root.AddChildRange(new [] { _folder1, _folder2, _con5 });
            _folder1.AddChildRange(new [] { _con1, _con2 });
            _folder2.AddChildRange(new[] { _con3, _con4 });

            return connectionTreeModel;
        }
Beispiel #12
0
        private RootNodeInfo CreateTreeStructure(Dictionary <ConnectionInfo, string> parentMapping)
        {
            var root = new RootNodeInfo(RootNodeType.Connection);

            foreach (var node in parentMapping)
            {
                // no parent mapped, add to root
                if (string.IsNullOrEmpty(node.Value))
                {
                    root.AddChild(node.Key);
                    continue;
                }

                // search for parent in the list by GUID
                var parent = parentMapping
                             .Keys
                             .OfType <ContainerInfo>()
                             .FirstOrDefault(info => info.ConstantID == node.Value);

                if (parent != null)
                {
                    parent.AddChild(node.Key);
                }
                else
                {
                    root.AddChild(node.Key);
                }
            }

            return(root);
        }
Beispiel #13
0
        private XElement CompileRootNode(RootNodeInfo rootNodeInfo, bool fullFileEncryption)
        {
            var rootNodeSerializer = new XmlRootNodeSerializer();

            return(rootNodeSerializer.SerializeRootNodeInfo(rootNodeInfo, _cryptographyProvider,
                                                            _connectionNodeSerializer.Version, fullFileEncryption));
        }
        public ConnectionTreeModel Deserialize(string puttycmConnectionsXml)
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);

            connectionTreeModel.AddRootNode(root);

            var xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(puttycmConnectionsXml);

            var configurationNode = xmlDocument.SelectSingleNode("/configuration");

            var rootNodes = configurationNode?.SelectNodes("./root");

            if (rootNodes == null)
            {
                return(connectionTreeModel);
            }
            foreach (XmlNode rootNode in rootNodes)
            {
                ImportRootOrContainer(rootNode, root);
            }

            return(connectionTreeModel);
        }
Beispiel #15
0
        // .rdp file schema: https://technet.microsoft.com/en-us/library/ff393699(v=ws.10).aspx

        public ConnectionTreeModel Deserialize(string rdcFileContent)
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);

            connectionTreeModel.AddRootNode(root);
            var connectionInfo = new ConnectionInfo();

            foreach (var line in rdcFileContent.Split(Environment.NewLine.ToCharArray()))
            {
                var parts = line.Split(new[] { ':' }, 3);
                if (parts.Length < 3)
                {
                    continue;
                }

                var key   = parts[0].Trim();
                var value = parts[2].Trim();

                SetConnectionInfoParameter(connectionInfo, key, value);
            }

            root.AddChild(connectionInfo);

            return(connectionTreeModel);
        }
        private void CreateDecryptor(RootNodeInfo rootNodeInfo, XmlElement connectionsRootElement = null)
        {
            if (_confVersion >= 2.6)
            {
                BlockCipherEngines engine;
                Enum.TryParse(connectionsRootElement?.Attributes["EncryptionEngine"].Value, out engine);

                BlockCipherModes mode;
                Enum.TryParse(connectionsRootElement?.Attributes["BlockCipherMode"].Value, out mode);

                int keyDerivationIterations;
                int.TryParse(connectionsRootElement?.Attributes["KdfIterations"].Value, out keyDerivationIterations);

                _decryptor = new XmlConnectionsDecryptor(engine, mode, rootNodeInfo)
                {
                    AuthenticationRequestor = AuthenticationRequestor,
                    KeyDerivationIterations = keyDerivationIterations
                };
            }
            else
            {
                _decryptor = new XmlConnectionsDecryptor(_rootNodeInfo)
                {
                    AuthenticationRequestor = AuthenticationRequestor
                };
            }
        }
        private void SerializeRootNodeInfo(RootNodeInfo rootNodeInfo)
        {
            var cryptographyProvider = new LegacyRijndaelCryptographyProvider();

            _xmlTextWriter.WriteStartElement("Connections"); // Do not localize
            _xmlTextWriter.WriteAttributeString("Name", "", rootNodeInfo.Name);
            _xmlTextWriter.WriteAttributeString("Export", "", Convert.ToString(Export));

            if (Export)
            {
                _xmlTextWriter.WriteAttributeString("Protected", "", cryptographyProvider.Encrypt("ThisIsNotProtected", _password));
            }
            else
            {
                if (rootNodeInfo.Password)
                {
                    _password = rootNodeInfo.PasswordString.ConvertToSecureString();
                    _xmlTextWriter.WriteAttributeString("Protected", "", cryptographyProvider.Encrypt("ThisIsProtected", _password));
                }
                else
                {
                    _xmlTextWriter.WriteAttributeString("Protected", "", cryptographyProvider.Encrypt("ThisIsNotProtected", _password));
                }
            }

            _xmlTextWriter.WriteAttributeString("ConfVersion", "", ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture));
        }
        public ConnectionTreeModel Deserialize(bool import)
        {
            try
            {
                if (!import)
                {
                    Runtime.IsConnectionsFileLoaded = false;
                }

                var rootXmlElement = _xmlDocument.DocumentElement;
                _rootNodeInfo = InitializeRootNode(rootXmlElement);
                CreateDecryptor(_rootNodeInfo, rootXmlElement);
                var connectionTreeModel = new ConnectionTreeModel();
                connectionTreeModel.AddRootNode(_rootNodeInfo);


                if (_confVersion > 1.3)
                {
                    var protectedString = _xmlDocument.DocumentElement?.Attributes["Protected"].Value;
                    if (!_decryptor.ConnectionsFileIsAuthentic(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString()))
                    {
                        mRemoteNG.Settings.Default.LoadConsFromCustomLocation = false;
                        mRemoteNG.Settings.Default.CustomConsPath             = "";
                        return(null);
                    }
                }

                if (_confVersion >= 2.6)
                {
                    if (rootXmlElement?.Attributes["FullFileEncryption"].Value == "True")
                    {
                        var decryptedContent = _decryptor.Decrypt(rootXmlElement.InnerText);
                        rootXmlElement.InnerXml = decryptedContent;
                    }
                }

                if (import && !IsExportFile(rootXmlElement))
                {
                    Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strCannotImportNormalSessionFile);
                    return(null);
                }

                AddNodesFromXmlRecursive(_xmlDocument.DocumentElement, _rootNodeInfo);

                if (!import)
                {
                    Runtime.IsConnectionsFileLoaded = true;
                }

                return(connectionTreeModel);
            }
            catch (Exception ex)
            {
                Runtime.IsConnectionsFileLoaded = false;
                Runtime.MessageCollector.AddExceptionStackTrace(Language.strLoadFromXmlFailed, ex);
                throw;
            }
        }
        private XAttribute CreateProtectedAttribute(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider)
        {
            var attribute          = new XAttribute(XName.Get("Protected"), "");
            var plainText          = rootNodeInfo.Password ? "ThisIsProtected" : "ThisIsNotProtected";
            var encryptionPassword = rootNodeInfo.PasswordString.ConvertToSecureString();

            attribute.Value = cryptographyProvider.Encrypt(plainText, encryptionPassword);
            return(attribute);
        }
        private static IEnumerable <TestCaseData> EveryNodeType()
        {
            var protocolTypes = typeof(ProtocolType).GetEnumValues().OfType <ProtocolType>().ToList();
            var root          = new RootNodeInfo(RootNodeType.Connection);
            var container     = new ContainerInfo();
            var connectionsWithNormalParent = protocolTypes
                                              .Select(protocolType =>
            {
                var c = new ConnectionInfo {
                    Protocol = protocolType
                };
                c.SetParent(container);
                return(new TestCaseData(c).SetName(protocolType + ", Connection, NormalParent"));
            });

            var connectionsWithRootParent = protocolTypes
                                            .Select(protocolType =>
            {
                var c = new ConnectionInfo {
                    Protocol = protocolType
                };
                c.SetParent(root);
                return(new TestCaseData(c).SetName(protocolType + ", Connection, RootParent"));
            });

            var contianersWithNormalParent = protocolTypes
                                             .Select(protocolType =>
            {
                var c = new ContainerInfo {
                    Protocol = protocolType
                };
                c.SetParent(container);
                return(new TestCaseData(c).SetName(protocolType + ", Connection, NormalParent"));
            });

            var containersWithRootParent = protocolTypes
                                           .Select(protocolType =>
            {
                var c = new ContainerInfo {
                    Protocol = protocolType
                };
                c.SetParent(root);
                return(new TestCaseData(c).SetName(protocolType + ", Connection, RootParent"));
            });

            return(connectionsWithNormalParent
                   .Concat(connectionsWithRootParent)
                   .Concat(contianersWithNormalParent)
                   .Concat(containersWithRootParent)
                   .Concat(new[]
            {
                new TestCaseData(root).SetName("RootNode"),
                new TestCaseData(new RootPuttySessionsNodeInfo()).SetName("RootPuttyNode"),
                new TestCaseData(new PuttySessionInfo()).SetName("PuttyNode"),
                new TestCaseData(null).SetName("Null"),
            }));
        }
 private XAttribute CreateProtectedAttribute(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider, bool export)
 {
     var attribute = new XAttribute(XName.Get("Protected"), "");
     var plainText = rootNodeInfo.Password && !export ? "ThisIsProtected" : "ThisIsNotProtected";
     var encryptionPassword = export
         ? rootNodeInfo.DefaultPassword.ConvertToSecureString()
         : rootNodeInfo.PasswordString.ConvertToSecureString();
     attribute.Value = cryptographyProvider.Encrypt(plainText, encryptionPassword);
     return attribute;
 }
        private RootNodeInfo InitializeRootNode(XmlElement connectionsRootElement)
        {
            var rootNodeName = connectionsRootElement?.Attributes["Name"].Value.Trim();
            var rootInfo     = new RootNodeInfo(RootNodeType.Connection)
            {
                Name = rootNodeName
            };

            return(rootInfo);
        }
        public ConnectionTreeModel Deserialize()
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);
            connectionTreeModel.AddRootNode(root);

            ImportContainers(_ldapPath, root);

            return connectionTreeModel;
        }
Beispiel #24
0
        public void MovingAConnectionUnderRootNodeDisablesInheritance(PropertyInfo property)
        {
            var rootNode = new RootNodeInfo(RootNodeType.Connection);

            _connectionInfo.Inheritance.EverythingInherited = true;
            _connectionInfo.SetParent(rootNode);
            var propertyValue = property.GetValue(_connectionInfo.Inheritance);

            Assert.That(propertyValue, Is.False);
        }
 private XAttribute CreateProtectedAttribute(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider, bool export)
 {
     var attribute = new XAttribute(XName.Get("Protected"), "");
     var plainText = rootNodeInfo.Password && !export ? "ThisIsProtected" : "ThisIsNotProtected";
     var encryptionPassword = export
         ? rootNodeInfo.DefaultPassword.ConvertToSecureString()
         : rootNodeInfo.PasswordString.ConvertToSecureString();
     attribute.Value = cryptographyProvider.Encrypt(plainText, encryptionPassword);
     return attribute;
 }
        public void InheritanceIsDisabledForNodesDirectlyUnderRootNode()
        {
            var rootNode = new RootNodeInfo(RootNodeType.Connection);
            var con1     = new ConnectionInfo {
                Inheritance = { Password = true }
            };

            rootNode.AddChild(con1);
            Assert.That(con1.Inheritance.Password, Is.False);
        }
Beispiel #27
0
        public ConnectionTreeModel Deserialize()
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);

            connectionTreeModel.AddRootNode(root);

            ImportContainers(_ldapPath, root);

            return(connectionTreeModel);
        }
        private RootNodeInfo InitializeRootNode()
        {
            var rootNodeName = _xmlDocument.DocumentElement?.Attributes["Name"].Value.Trim();

            var rootInfo = new RootNodeInfo(RootNodeType.Connection)
            {
                Name = rootNodeName
            };

            return(rootInfo);
        }
        public ConnectionTreeModel Deserialize()
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);
            connectionTreeModel.AddRootNode(root);

            foreach (var host in _scannedHosts)
                ImportScannedHost(host, root);

            return connectionTreeModel;
        }
        private ConnectionTreeModel SetupConnectionTreeModel()
        {
            /*
             * Tree:
             * Root
             * |--- folder1 (description1, hostname1)
             * |    |--- con1 (description2, hostname2)
             * |    L--- con2 (description3, hostname3)
             * |--- folder2 (description4, hostname4)
             * |    |--- con3 (description5, hostname5)
             * |    L--- con4 (description6, hostname6)
             * L--- con5 (description7, hostname7)
             *
             */
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);

            _folder1 = new ContainerInfo {
                Name = "folder1", Description = "description1", Hostname = "hostname1"
            };
            _con1 = new ConnectionInfo {
                Name = "con1", Description = "description2", Hostname = "hostname2"
            };
            _con2 = new ConnectionInfo {
                Name = "con2", Description = "description3", Hostname = "hostname3"
            };
            _folder2 = new ContainerInfo {
                Name = "folder2", Description = "description4", Hostname = "hostname4"
            };
            _con3 = new ConnectionInfo {
                Name = "con3", Description = "description5", Hostname = "hostname5"
            };
            _con4 = new ConnectionInfo {
                Name = "con4", Description = "description6", Hostname = "hostname6"
            };
            _con5 = new ConnectionInfo {
                Name = "con5", Description = "description7", Hostname = "hostname7"
            };

            _folder1.Inheritance.TurnOffInheritanceCompletely();
            _con1.Inheritance.TurnOffInheritanceCompletely();
            _con2.Inheritance.TurnOffInheritanceCompletely();
            _folder2.Inheritance.TurnOffInheritanceCompletely();
            _con3.Inheritance.TurnOffInheritanceCompletely();
            _con4.Inheritance.TurnOffInheritanceCompletely();
            _con5.Inheritance.TurnOffInheritanceCompletely();

            connectionTreeModel.AddRootNode(root);
            root.AddChildRange(new [] { _folder1, _folder2, _con5 });
            _folder1.AddChildRange(new [] { _con1, _con2 });
            _folder2.AddChildRange(new[] { _con3, _con4 });

            return(connectionTreeModel);
        }
Beispiel #31
0
        public void MovingAConnectionFromUnderRootNodeToUnderADifferentNodeEnablesInheritance(PropertyInfo property)
        {
            var rootNode       = new RootNodeInfo(RootNodeType.Connection);
            var otherContainer = new ContainerInfo();

            _connectionInfo.Inheritance.EverythingInherited = true;
            _connectionInfo.SetParent(rootNode);
            _connectionInfo.SetParent(otherContainer);
            var propertyValue = property.GetValue(_connectionInfo.Inheritance);

            Assert.That(propertyValue, Is.True);
        }
Beispiel #32
0
 private void InitializeNodes()
 {
     _rootNode    = new RootNodeInfo(RootNodeType.Connection);
     _container1  = new ContainerInfo();
     _container2  = new ContainerInfo();
     _container3  = new ContainerInfo();
     _connection1 = new ConnectionInfo();
     _connection2 = new ConnectionInfo();
     _connection3 = new ConnectionInfo();
     _connection4 = new ConnectionInfo();
     _connection5 = new ConnectionInfo();
 }
Beispiel #33
0
 private void DestroyNodes()
 {
     _rootNode    = null;
     _container1  = null;
     _container2  = null;
     _container3  = null;
     _connection1 = null;
     _connection2 = null;
     _connection3 = null;
     _connection4 = null;
     _connection5 = null;
 }
        public void RenamingNodeWithNothingSelectedDoesNothing()
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);

            connectionTreeModel.AddRootNode(root);

            _connectionTree.ConnectionTreeModel = connectionTreeModel;
            _connectionTree.SelectedObject      = null;

            Assert.DoesNotThrow(() => _connectionTree.RenameSelectedNode());
        }
 public XElement SerializeRootNodeInfo(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider, bool fullFileEncryption = false, bool export = false)
 {
     var element = new XElement("Connections");
     element.Add(new XAttribute(XName.Get("Name"), rootNodeInfo.Name));
     element.Add(new XAttribute(XName.Get("Export"), export.ToString()));
     element.Add(new XAttribute(XName.Get("EncryptionEngine"), cryptographyProvider.CipherEngine));
     element.Add(new XAttribute(XName.Get("BlockCipherMode"), cryptographyProvider.CipherMode));
     element.Add(new XAttribute(XName.Get("KdfIterations"), cryptographyProvider.KeyDerivationIterations));
     element.Add(new XAttribute(XName.Get("FullFileEncryption"), fullFileEncryption.ToString()));
     element.Add(CreateProtectedAttribute(rootNodeInfo, cryptographyProvider, export));
     element.Add(new XAttribute(XName.Get("ConfVersion"), "2.6"));
     return element;
 }
 public XElement SerializeRootNodeInfo(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider, bool fullFileEncryption = false, bool export = false)
 {
     var element = new XElement("Connections");
     element.Add(new XAttribute(XName.Get("Name"), rootNodeInfo.Name));
     element.Add(new XAttribute(XName.Get("Export"), export.ToString()));
     element.Add(new XAttribute(XName.Get("EncryptionEngine"), cryptographyProvider.CipherEngine));
     element.Add(new XAttribute(XName.Get("BlockCipherMode"), cryptographyProvider.CipherMode));
     element.Add(new XAttribute(XName.Get("KdfIterations"), cryptographyProvider.KeyDerivationIterations));
     element.Add(new XAttribute(XName.Get("FullFileEncryption"), fullFileEncryption.ToString()));
     element.Add(CreateProtectedAttribute(rootNodeInfo, cryptographyProvider, export));
     element.Add(new XAttribute(XName.Get("ConfVersion"), "2.6"));
     return element;
 }
        private ConnectionTreeModel CreateNodeHierarchy(List<ConnectionInfo> connectionList)
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var rootNode = new RootNodeInfo(RootNodeType.Connection) {ConstantID = "0"};
            connectionTreeModel.AddRootNode(rootNode);

            foreach (DataRow row in _dataTable.Rows)
            {
                var id = (string) row["ConstantID"];
                var connectionInfo = connectionList.First(node => node.ConstantID == id);
                var parentId = (string) row["ParentID"];
                if (parentId == "0")
                    rootNode.AddChild(connectionInfo);
                else
                    (connectionList.First(node => node.ConstantID == parentId) as ContainerInfo)?.AddChild(connectionInfo);
            }
            return connectionTreeModel;
        }
        public ConnectionTreeModel Deserialize()
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);

            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(_rdcmConnectionsXml);

            var rdcManNode = xmlDocument.SelectSingleNode("/RDCMan");
            VerifySchemaVersion(rdcManNode);
            VerifyFileVersion(rdcManNode);

            var fileNode = rdcManNode?.SelectSingleNode("./file");
            ImportFileOrGroup(fileNode, root);

            connectionTreeModel.AddRootNode(root);
            return connectionTreeModel;
        }
        public ConnectionTreeModel Deserialize()
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);
            connectionTreeModel.AddRootNode(root);

            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(_puttycmConnectionsXml);

            var configurationNode = xmlDocument.SelectSingleNode("/configuration");

            var rootNodes = configurationNode?.SelectNodes("./root");
            if (rootNodes == null) return connectionTreeModel;
            foreach (XmlNode rootNode in rootNodes)
            {
                ImportRootOrContainer(rootNode, root);
            }

            return connectionTreeModel;
        }
        public ConnectionTreeModel Deserialize()
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);
            connectionTreeModel.AddRootNode(root);
            var connectionInfo = new ConnectionInfo();
            foreach (var line in _fileContent)
            {
                var parts = line.Split(new[] { ':' }, 3);
                if (parts.Length < 3)
                {
                    continue;
                }

                var key = parts[0];
                var value = parts[2];

                SetConnectionInfoParameter(connectionInfo, key, value);
            }
            root.AddChild(connectionInfo);

            return connectionTreeModel;
        }
 public XmlConnectionsDecryptor(RootNodeInfo rootNodeInfo)
 {
     _cryptographyProvider = new LegacyRijndaelCryptographyProvider();
     _rootNodeInfo = rootNodeInfo;
 }
        private ConnectionTreeModel CreateConnectionTreeModel()
        {
            var model = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);
            var folder1 = new ContainerInfo {Name = "folder1", Username = "******", Domain = "domain1", Password = "******"};
            var con1 = new ConnectionInfo {Name = "Con1", Username = "******", Domain = "domain1", Password = "******" };
            var con2 = new ConnectionInfo {Name = "Con2", Username = "******", Domain = "domain2", Password = "******" };

            root.AddChild(folder1);
            root.AddChild(con2);
            folder1.AddChild(con1);
            model.AddRootNode(root);
            return model;
        }
 public void Teardown()
 {
     _rootNode = null;
 }
 public void Setup()
 {
     _rootNodeSerializer = new XmlRootNodeSerializer();
     _cryptographyProvider = new AeadCryptographyProvider();
     _rootNodeInfo = new RootNodeInfo(RootNodeType.Connection);
 }
        private void CreateDecryptor(RootNodeInfo rootNodeInfo, XmlElement connectionsRootElement = null)
        {
            if (_confVersion >= 2.6)
            {
                BlockCipherEngines engine;
                Enum.TryParse(connectionsRootElement?.Attributes["EncryptionEngine"].Value, out engine);

                BlockCipherModes mode;
                Enum.TryParse(connectionsRootElement?.Attributes["BlockCipherMode"].Value, out mode);

                int keyDerivationIterations;
                int.TryParse(connectionsRootElement?.Attributes["KdfIterations"].Value, out keyDerivationIterations);

                _decryptor = new XmlConnectionsDecryptor(engine, mode, rootNodeInfo)
                {
                    AuthenticationRequestor = AuthenticationRequestor,
                    KeyDerivationIterations = keyDerivationIterations
                };
            }
            else
            {
                _decryptor = new XmlConnectionsDecryptor(_rootNodeInfo) { AuthenticationRequestor = AuthenticationRequestor };
            }
        }
 private void InitializeNodes()
 {
     _rootNode = new RootNodeInfo(RootNodeType.Connection);
     _container1 = new ContainerInfo();
     _container2 = new ContainerInfo();
     _container3 = new ContainerInfo();
     _connection1 = new ConnectionInfo();
     _connection2 = new ConnectionInfo();
     _connection3 = new ConnectionInfo();
     _connection4 = new ConnectionInfo();
     _connection5 = new ConnectionInfo();
 }
 public void Setup()
 {
     _rootNodeInfo = new RootNodeInfo(RootNodeType.Connection);
 }
Beispiel #48
0
        private void UpdateRootNodeTable(RootNodeInfo rootTreeNode, SqlDatabaseConnector sqlDatabaseConnector)
        {
            var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
            string strProtected;
            if (rootTreeNode != null)
            {
                if (rootTreeNode.Password)
                {
                    _password = Convert.ToString(rootTreeNode.PasswordString).ConvertToSecureString();
                    strProtected = cryptographyProvider.Encrypt("ThisIsProtected", _password);
                }
                else
                {
                    strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", _password);
                }
            }
            else
            {
                strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", _password);
            }

            var sqlQuery = new SqlCommand("DELETE FROM tblRoot", sqlDatabaseConnector.SqlConnection);
            sqlQuery.ExecuteNonQuery();

            if (rootTreeNode != null)
            {
                sqlQuery =
                    new SqlCommand(
                        "INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES(\'" +
                        MiscTools.PrepareValueForDB(rootTreeNode.Name) + "\', 0, \'" + strProtected + "\'," +
                        ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture) + ")",
                        sqlDatabaseConnector.SqlConnection);
                sqlQuery.ExecuteNonQuery();
            }
            else
            {
                Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"UpdateRootNodeTable: rootTreeNode was null. Could not insert!");
            }
        }
 private void DestroyNodes()
 {
     _rootNode = null;
     _container1 = null;
     _container2 = null;
     _container3 = null;
     _connection1 = null;
     _connection2 = null;
     _connection3 = null;
     _connection4 = null;
     _connection5 = null;
 }
 public XmlConnectionsDecryptor(BlockCipherEngines blockCipherEngine, BlockCipherModes blockCipherMode, RootNodeInfo rootNodeInfo)
 {
     _cryptographyProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(blockCipherEngine, blockCipherMode);
     _rootNodeInfo = rootNodeInfo;
 }
 private ConnectionTreeModel SetupConnectionTreeModel()
 {
     /*
      * Root
      * |--- con0
      * |--- folder1
      * |    L--- con1
      * L--- folder2
      *      |--- con2
      *      L--- folder3
      *           |--- con3
      *           L--- con4
      */
     BuildTreeNodes();
     var connectionTreeModel = new ConnectionTreeModel();
     var rootNode = new RootNodeInfo(RootNodeType.Connection);
     rootNode.AddChild(_folder1);
     rootNode.AddChild(_folder2);
     rootNode.AddChild(_con0);
     _folder1.AddChild(_con1);
     _folder2.AddChild(_con2);
     _folder2.AddChild(_folder3);
     _folder3.AddChild(_con3);
     _folder3.AddChild(_con4);
     connectionTreeModel.AddRootNode(rootNode);
     return connectionTreeModel;
 }
 private XElement CompileRootNode(RootNodeInfo rootNodeInfo, bool fullFileEncryption, bool export)
 {
     var rootNodeSerializer = new XmlRootNodeSerializer();
     return rootNodeSerializer.SerializeRootNodeInfo(rootNodeInfo, _cryptographyProvider, fullFileEncryption, export);
 }