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;
 }
Example #2
0
        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;
        }
 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 ConnectionTreeModel Deserialize()
        {
            var connectionTreeModel = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);
            connectionTreeModel.AddRootNode(root);

            ImportContainers(_ldapPath, root);

            return connectionTreeModel;
        }
        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;
        }
 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 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;
        }
        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);
            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;
        }
 private void DestroyNodes()
 {
     _rootNode = null;
     _container1 = null;
     _container2 = null;
     _container3 = null;
     _connection1 = null;
     _connection2 = null;
     _connection3 = null;
     _connection4 = null;
     _connection5 = null;
 }
 public void Teardown()
 {
     _rootNode = null;
 }
 public void Setup()
 {
     _rootNodeSerializer = new XmlRootNodeSerializer();
     _cryptographyProvider = new AeadCryptographyProvider();
     _rootNodeInfo = new RootNodeInfo(RootNodeType.Connection);
 }
        private ConnectionTreeModel CreateConnectionTreeModel()
        {
            var model = new ConnectionTreeModel();
            var root = new RootNodeInfo(RootNodeType.Connection);
            var folder1 = new ContainerInfo {Name = "folder1", Username = "user1", Domain = "domain1", Password = "password1"};
            var con1 = new ConnectionInfo {Name = "Con1", Username = "user1", Domain = "domain1", Password = "password1" };
            var con2 = new ConnectionInfo {Name = "Con2", Username = "user2", Domain = "domain2", Password = "password2" };

            root.AddChild(folder1);
            root.AddChild(con2);
            folder1.AddChild(con1);
            model.AddRootNode(root);
            return model;
        }
 private XElement CompileRootNode(RootNodeInfo rootNodeInfo, bool fullFileEncryption, bool export)
 {
     var rootNodeSerializer = new XmlRootNodeSerializer();
     return rootNodeSerializer.SerializeRootNodeInfo(rootNodeInfo, _cryptographyProvider, fullFileEncryption, export);
 }
Example #16
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 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 };
            }
        }
 public XmlConnectionsDecryptor(BlockCipherEngines blockCipherEngine, BlockCipherModes blockCipherMode, RootNodeInfo rootNodeInfo)
 {
     _cryptographyProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(blockCipherEngine, blockCipherMode);
     _rootNodeInfo = rootNodeInfo;
 }
 public XmlConnectionsDecryptor(RootNodeInfo rootNodeInfo)
 {
     _cryptographyProvider = new LegacyRijndaelCryptographyProvider();
     _rootNodeInfo = rootNodeInfo;
 }
 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();
 }
Example #21
0
 public void Setup()
 {
     _rootNodeInfo = new RootNodeInfo(RootNodeType.Connection);
 }
 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;
 }