Example #1
0
        public static bool PassWordsCompare(string pass1, string pass2)
        {
            string temPpassword;

            try
            {
                temPpassword = DpapiWrapper.DecryptIfEncrypted(pass1);
            }
            catch (Exception)
            {
                //
                temPpassword = pass1;
            }

            string temPpassword1;

            try
            {
                temPpassword1 = DpapiWrapper.DecryptIfEncrypted(pass2);
            }
            catch (Exception)
            {
                //
                temPpassword1 = pass2;
            }

            return(string.Equals(temPpassword, temPpassword1));
        }
Example #2
0
        public override XElement ToXml()
        {
            var result           = base.ToXml();
            var connectionString = string.Join(";",
                                               $"AppServerUri={Address}",
                                               $"WebServerPort={WebServerPort}",
                                               $"AuthenticationType={AuthenticationType}"
                                               );

            if (AuthenticationType == AuthenticationType.User)
            {
                connectionString = string.Join(";",
                                               connectionString,
                                               $"UserName={UserName}",
                                               $"Password={Password}"
                                               );
            }

            result.Add(
                new XAttribute("ConnectionString", DpapiWrapper.Encrypt(connectionString)),
                new XAttribute("Type", GetType().Name),
                new XElement("TypeOf", enSourceType.Dev2Server)
                );

            return(result);
        }
        public void TriggersCatalog_LoadQueuesByResourceId_ExpectQueue()
        {
            var          mockDirectoryWrapper = new Mock <IDirectory>();
            const string fileName             = "somefile.bite";

            mockDirectoryWrapper.Setup(o => o.GetFiles(It.IsAny <string>())).Returns(new[] { fileName });

            var mockFileWrapper       = new Mock <IFile>();
            var mockSerializer        = new Mock <ISerializer>();
            var mockFileSystemWatcher = new Mock <IFileSystemWatcher>();

            var expectedResourceId = Guid.NewGuid();
            var decryptedTrigger   = "serialized queue data";
            var expected           = DpapiWrapper.Encrypt(decryptedTrigger);

            mockFileWrapper.Setup(o => o.ReadAllText("somefile.bite")).Returns(expected);
            var expectedTrigger = new TriggerQueue {
                ResourceId = expectedResourceId
            };

            mockSerializer.Setup(o => o.Deserialize <ITriggerQueue>(decryptedTrigger)).Returns(expectedTrigger);

            var catalog      = GetTriggersCatalog(mockDirectoryWrapper.Object, mockFileWrapper.Object, "some path", mockSerializer.Object, mockFileSystemWatcher.Object);
            var triggerQueue = catalog.LoadQueueTriggerFromFile("somefile.bite");

            mockSerializer.Verify(o => o.Deserialize <ITriggerQueue>(decryptedTrigger), Times.Exactly(2));
            Assert.AreEqual(expectedTrigger, triggerQueue);

            var triggerQueues = catalog.LoadQueuesByResourceId(expectedResourceId);

            Assert.AreEqual(1, triggerQueues.Count);
        }
Example #4
0
        public WebSource(XElement xml)
            : base(xml)
        {
            ResourceType       = "WebSource";
            AuthenticationType = AuthenticationType.Anonymous;

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Address", string.Empty },
                { "DefaultQuery", string.Empty },
                { "AuthenticationType", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty }
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            connectionString = connectionString.UnescapeString();
            ParseProperties(connectionString, properties);
            Address      = properties["Address"];
            DefaultQuery = properties["DefaultQuery"];
            UserName     = properties["UserName"];
            Password     = properties["Password"];

            AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out AuthenticationType authType) ? authType : AuthenticationType.Windows;
        }
Example #5
0
        public SharepointSource(XElement xml, ISharepointHelperFactory sharepointHelperFactory)
            : base(xml)
        {
            _sharepointHelperFactory = sharepointHelperFactory;
            ResourceType             = "SharepointServerSource";
            AuthenticationType       = AuthenticationType.Windows;

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Server", string.Empty },
                { "AuthenticationType", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty }
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ParseProperties(connectionString, properties);
            Server   = properties["Server"];
            UserName = properties["UserName"];
            Password = properties["Password"];
            var isSharepointSourceValue = xml.AttributeSafe("IsSharepointOnline");

            if (bool.TryParse(isSharepointSourceValue, out bool isSharepointSource))
            {
                IsSharepointOnline = isSharepointSource;
            }
            AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out AuthenticationType authType) ? authType : AuthenticationType.Windows;
        }
Example #6
0
        public ExchangeSource(XElement xml)
            : base(xml)
        {
            ResourceType = "ExchangeSource";
            Timeout      = DefaultTimeout;

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "AutoDiscoverUrl", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty },
                { "Timeout", string.Empty },
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ParseProperties(connectionString, properties);

            AutoDiscoverUrl = properties["AutoDiscoverUrl"];
            UserName        = properties["UserName"];
            Password        = properties["Password"];

            int timeout;

            Timeout = Int32.TryParse(properties["Timeout"], out timeout) ? timeout : DefaultTimeout;
        }
        /// <summary>
        /// Gets the XML representation of this resource.
        /// </summary>
        /// <returns>
        /// The XML representation of this resource.
        /// </returns>
        public override XElement ToXml()
        {
            var result           = base.ToXml();
            var connectionString = string.Join(";",
                                               $"Server={Server}",
                                               $"AuthenticationType={AuthenticationType}"
                                               );

            if (AuthenticationType == AuthenticationType.User)
            {
                connectionString = string.Join(";",
                                               connectionString,
                                               $"UserName={UserName}",
                                               $"Password={Password}"
                                               );
            }

            result.Add(
                new XAttribute("ConnectionString", DpapiWrapper.Encrypt(connectionString)),
                new XAttribute("IsSharepointOnline", IsSharepointOnline),
                new XAttribute("Type", GetType().Name),
                new XElement("TypeOf", ResourceType)
                );

            return(result);
        }
        public void EncryptDecryptFailsIfAlreadyPerformedTest()
        {
            //------------Setup for test--------------------------

            //------------Execute Test---------------------------
            string encrypted         = DpapiWrapper.Encrypt(message);
            char   x                 = encrypted.Where(o => encrypted.Where(u => u == o).Count() > 1).First(); // find first char that appears more than once
            char   y                 = encrypted.Where(o => o != x).First();                                   // find the first char not equal to x
            string tamperedEncrypted = encrypted.Replace(x, y);

            try
            {
                string decrypted = DpapiWrapper.Decrypt(tamperedEncrypted);
            }
            catch (Exception e)
            {
                e.GetType().Should().Be(typeof(System.Security.Cryptography.CryptographicException));
            }
            try
            {
                DpapiWrapper.Decrypt(message);
            }
            catch (Exception e)
            {
                e.GetType().Should().Be(typeof(ArgumentException));
            }
        }
Example #9
0
        public void DsfPathCreate_TryExecuteConcreteAction_Credential_Variable()
        {
            //------------Setup for test--------------------------
            var env = new ExecutionEnvironment();

            env.Assign("[[val1]]", "demo", false, 0);
            env.Assign("[[val2]]", "password", false, 0);

            var newGuid    = Guid.NewGuid();
            var outputPath = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "test.txt");
            var act        = new TestDsfPathCreate {
                OutputPath = outputPath, Result = "CompanyName"
            };

            act.Username = "******";
            act.Password = DpapiWrapper.Encrypt("[[val2]]");

            var mockDataObject = new Mock <IDSFDataObject>();

            mockDataObject.Setup(o => o.Environment).Returns(env);
            mockDataObject.Setup(o => o.IsDebugMode()).Returns(true);

            //------------Execute Test---------------------------
            ErrorResultTO to;

            act.TestTryExecuteConcreteAction(mockDataObject.Object, out to, 0);
            var errors = to.FetchErrors();

            Assert.IsTrue(errors.FirstOrDefault()?.Contains("Failed to authenticate with user [ demo ]") ?? false);
        }
        /// <summary>
        /// Gets the XML representation of this resource.
        /// </summary>
        /// <returns>
        /// The XML representation of this resource.
        /// </returns>
        public override XElement ToXml()
        {
            var result           = base.ToXml();
            var connectionString = string.Join(";",
                                               string.Format("Server={0}", Server),
                                               string.Format("AuthenticationType={0}", AuthenticationType)
                                               );

            if (AuthenticationType == AuthenticationType.User)
            {
                connectionString = string.Join(";",
                                               connectionString,
                                               string.Format("UserName={0}", UserName),
                                               string.Format("Password={0}", Password)
                                               );
            }

            result.Add(
                new XAttribute("ConnectionString", DpapiWrapper.Encrypt(connectionString)),
                new XAttribute("Type", ResourceType),
                new XElement("TypeOf", ResourceType)
                );

            return(result);
        }
        public SharepointSource(XElement xml)
            : base(xml)
        {
            ResourceType       = ResourceType.SharepointServerSource;
            AuthenticationType = AuthenticationType.Windows;

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Server", string.Empty },
                { "AuthenticationType", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty }
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ParseProperties(connectionString, properties);
            Server   = properties["Server"];
            UserName = properties["UserName"];
            Password = properties["Password"];

            AuthenticationType authType;

            AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out authType) ? authType : AuthenticationType.Windows;
        }
Example #12
0
        public IDbConnection CreateConnection(string connectionString)
        {
            VerifyArgument.IsNotNull("connectionString", connectionString);
            if (connectionString.CanBeDecrypted())
            {
                connectionString = DpapiWrapper.Decrypt(connectionString);
            }
            _sqlConnection = new SqlConnection(connectionString);
            _sqlConnection.FireInfoMessageEventOnUserErrors = true;
            _sqlConnection.StatisticsEnabled = true;
            _sqlConnection.InfoMessage      += (sender, args) =>
            {
                Dev2Logger.Debug("SQL Server:" + args.Message + " Source:" + args.Source);
                foreach (SqlError error in args.Errors)
                {
                    var errorMessages = new StringBuilder();
                    errorMessages.Append("Index #" + error.Number + Environment.NewLine +
                                         "Message: " + error.Message + Environment.NewLine +
                                         "LineNumber: " + error.LineNumber + Environment.NewLine +
                                         "Source: " + error.Source + Environment.NewLine +
                                         "Procedure: " + error.Procedure + Environment.NewLine);

                    Dev2Logger.Error("SQL Error:" + errorMessages.ToString());
                }
            };
            return(_sqlConnection);
        }
Example #13
0
        public override XElement ToXml()
        {
            var result           = base.ToXml();
            var connectionString = string.Join(";",
                                               $"Address={Address}",
                                               $"DefaultQuery={DefaultQuery}",
                                               $"AuthenticationType={AuthenticationType}"
                                               );

            if (AuthenticationType == AuthenticationType.User)
            {
                connectionString = string.Join(";",
                                               connectionString,
                                               $"UserName={UserName}",
                                               $"Password={Password}"
                                               );
            }

            result.Add(
                new XAttribute("ConnectionString", DpapiWrapper.Encrypt(connectionString.EscapeString())),
                new XAttribute("Type", GetType().Name),
                new XElement("TypeOf", ResourceType)
                );

            return(result);
        }
Example #14
0
        public EmailSource(XElement xml)
            : base(xml)
        {
            ResourceType = "EmailSource";
            Timeout      = DefaultTimeout;
            Port         = DefaultPort;

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Host", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty },
                { "Port", string.Empty },
                { "EnableSsl", string.Empty },
                { "Timeout", string.Empty },
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ParseProperties(connectionString, properties);

            Host     = properties["Host"];
            UserName = properties["UserName"];
            Password = properties["Password"];

            Port = Int32.TryParse(properties["Port"], out int port) ? port : DefaultPort;

            EnableSsl = bool.TryParse(properties["EnableSsl"], out bool enableSsl) && enableSsl;

            Timeout = Int32.TryParse(properties["Timeout"], out int timeout) ? timeout : DefaultTimeout;
        }
Example #15
0
        public DbSource(XElement xml)
            : base(xml)
        {
            ResourceType = ResourceType.DbSource;

            // Setup type include default port
            switch (xml.AttributeSafe("ServerType"))
            {
            case "SqlDatabase":
                ServerType = enSourceType.SqlDatabase;
                Port       = 1433;
                break;

            case "MySqlDatabase":
                ServerType = enSourceType.MySqlDatabase;
                break;

            default:
                ServerType = enSourceType.Unknown;
                break;
            }
            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ConnectionString = connectionString;
        }
Example #16
0
        public void TriggersCatalog_FileSystemWatcher_Error()
        {
            var directory            = "some path";
            var fileName             = Guid.NewGuid().ToString() + ".bite";
            var oldName              = Guid.NewGuid().ToString() + ".bite";
            var files                = new string[] { fileName };
            var mockDirectoryWrapper = new Mock <IDirectory>();

            mockDirectoryWrapper.Setup(directoryWrapper => directoryWrapper.GetFiles("some path")).Returns(files);
            var mockFileWrapper = new Mock <IFile>();
            var mockSerializer  = new Mock <ISerializer>();

            var mockFileSystemWatcher = new Mock <IFileSystemWatcher>();

            var triggerId        = Guid.NewGuid();
            var decryptedTrigger = "serialized queue data";
            var expected         = DpapiWrapper.Encrypt(decryptedTrigger);

            mockFileWrapper.Setup(o => o.ReadAllText(fileName)).Returns(expected);
            var expectedTrigger = new TriggerQueue
            {
                TriggerId = triggerId
            };

            mockSerializer.Setup(o => o.Deserialize <ITriggerQueue>(decryptedTrigger)).Returns(expectedTrigger);

            var catalog = GetTriggersCatalog(mockDirectoryWrapper.Object, mockFileWrapper.Object, directory, mockSerializer.Object, mockFileSystemWatcher.Object);

            mockFileSystemWatcher.Raise(fileWatcher => fileWatcher.Error += null, null, new ErrorEventArgs(new Exception()));

            mockDirectoryWrapper.Verify(directoryWrapper => directoryWrapper.GetFiles(directory), Times.Exactly(1));

            Assert.AreEqual(1, catalog.Queues.Count);
            Assert.AreEqual(triggerId, catalog.Queues[0].TriggerId);
        }
Example #17
0
        public override XElement ToXml()
        {
            var result           = base.ToXml();
            var connectionString = string.Join(";",
                                               $"HostName={HostName}",
                                               $"Port={Port}",
                                               $"SearchIndex={SearchIndex}",
                                               $"AuthenticationType={AuthenticationType}"
                                               );

            if (AuthenticationType == AuthenticationType.Password)
            {
                connectionString = string.Join(";",
                                               connectionString,
                                               $"Username={Username}",
                                               $"Password={Password}"
                                               );
            }

            result.Add(
                new XAttribute("ConnectionString", DpapiWrapper.Encrypt(connectionString.EscapeString())),
                new XAttribute("Type", ResourceType),
                new XElement("TypeOf", ResourceType)
                );

            return(result);
        }
Example #18
0
        public ElasticsearchSource(XElement xml) : base(xml)
        {
            ResourceType       = nameof(ElasticsearchSource);
            AuthenticationType = AuthenticationType.Anonymous;
            Port        = DefaultPort;
            SearchIndex = DefaultSearchIndex;
            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "HostName", string.Empty },
                { "Port", string.Empty },
                { "AuthenticationType", string.Empty },
                { "Password", string.Empty },
                { "Username", string.Empty },
                { "SearchIndex", string.Empty }
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            connectionString = connectionString.UnescapeString();
            ParseProperties(connectionString, properties);
            HostName           = properties["HostName"];
            Port               = properties["Port"];
            Username           = properties["Username"];
            Password           = properties["Password"];
            SearchIndex        = properties["SearchIndex"];
            AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out AuthenticationType authType) ? authType : AuthenticationType.Windows;
        }
Example #19
0
        public RabbitMQSource(XElement xml)
            : base(xml)
        {
            ResourceType = "RabbitMQSource";
            Port         = DefaultPort;

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "HostName", string.Empty },
                { "Port", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty },
                { "VirtualHost", string.Empty },
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ParseProperties(connectionString, properties);

            HostName = properties["HostName"];
            UserName = properties["UserName"];
            Password = properties["Password"];

            int port;

            Port        = Int32.TryParse(properties["Port"], out port) ? port : DefaultPort;
            VirtualHost = !string.IsNullOrWhiteSpace(properties["VirtualHost"]) ? properties["VirtualHost"] : DefaultVirtualHost;
        }
        public void RunTripAspUser()
        {
            Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
            var entropy   = new byte[] { 24, 76, 211, 4, 255 };
            var protector = new DpapiWrapper();

            RunTrip(entropy, DataProtectionScope.CurrentUser, protector);
        }
Example #21
0
        public ITriggerQueue LoadQueueTriggerFromFile(string filename)
        {
            var fileData         = _fileWrapper.ReadAllText(filename);
            var decryptedTrigger = DpapiWrapper.Decrypt(fileData);
            var triggerQueue     = _serializer.Deserialize <ITriggerQueue>(decryptedTrigger);

            return(triggerQueue);
        }
Example #22
0
        public void WorkflowResume_Execute_WithEncryptedValues_Returns_Execution_Completed()
        {
            //------------Setup for test--------------------------
            var newexecutionEnvironment = CreateExecutionEnvironment();

            newexecutionEnvironment.Assign("[[UUID]]", "public", 0);
            newexecutionEnvironment.Assign("[[JourneyName]]", "whatever", 0);

            var resourceId       = Guid.NewGuid();
            var serializer       = new Dev2JsonSerializer();
            var identity         = new MockPrincipal(WindowsIdentity.GetCurrent().Name);
            var currentPrincipal = new GenericPrincipal(identity, new[] { "Role1", "Roll2" });

            Thread.CurrentPrincipal = currentPrincipal;
            var user   = DpapiWrapper.Encrypt(currentPrincipal.Identity.Name);
            var env    = DpapiWrapper.Encrypt(newexecutionEnvironment.ToJson());
            var values = new Dictionary <string, StringBuilder>
            {
                { "resourceID", new StringBuilder(resourceId.ToString()) },
                { "environment", new StringBuilder(env) },
                { "startActivityId", new StringBuilder("4032a11e-4fb3-4208-af48-b92a0602ab4b") },
                { "versionNumber", new StringBuilder("1") },
                { "currentuserprincipal", new StringBuilder(user) }
            };
            var resourceCatalog = new Mock <IResourceCatalog>();
            var newDs           = new DynamicService {
                Name = HandlesType(), ID = resourceId
            };
            var sa = new ServiceAction {
                Name = HandlesType(), ActionType = enActionType.InvokeManagementDynamicService, SourceMethod = HandlesType()
            };

            newDs.Actions.Add(sa);
            resourceCatalog.Setup(catalog => catalog.GetService(GlobalConstants.ServerWorkspaceID, It.IsAny <Guid>(), "")).Returns(newDs);

            var errors = new ErrorResultTO();
            var mockResumableExecutionContainer = new Mock <IResumableExecutionContainer>();

            mockResumableExecutionContainer.Setup(o => o.Execute(out errors, 0)).Verifiable();

            var mockResumableExecutionContainerFactory = new Mock <IResumableExecutionContainerFactory>();

            mockResumableExecutionContainerFactory.Setup(o => o.New(It.IsAny <Guid>(), It.IsAny <ServiceAction>(), It.IsAny <DsfDataObject>()))
            .Returns(mockResumableExecutionContainer.Object);
            CustomContainer.Register(mockResumableExecutionContainerFactory.Object);
            //------------Execute Test---------------------------

            var workflowResume = new WorkflowResume();

            workflowResume.ResourceCatalogInstance = resourceCatalog.Object;
            var jsonResult = workflowResume.Execute(values, null);

            //------------Assert Results-------------------------
            var result = serializer.Deserialize <ExecuteMessage>(jsonResult);

            Assert.IsFalse(result.HasError);
            Assert.AreEqual("Execution Completed.", result.Message.ToString());
        }
Example #23
0
 public IDbConnection CreateConnection(string connectionString)
 {
     VerifyArgument.IsNotNull("connectionString", connectionString);
     if (connectionString.CanBeDecrypted())
     {
         connectionString = DpapiWrapper.Decrypt(connectionString);
     }
     return(new OracleConnection(connectionString));
 }
Example #24
0
        public IDbConnection CreateConnection(string connectionString)
        {
            var connectionStr = connectionString;

            VerifyArgument.IsNotNull("connectionString", connectionStr);
            if (connectionStr.CanBeDecrypted())
            {
                connectionStr = DpapiWrapper.Decrypt(connectionStr);
            }
            return(new SQLiteConnection(connectionStr));
        }
Example #25
0
        public override XElement ToXml()
        {
            var result           = base.ToXml();
            var connectionString = GetConnectionString();

            result.Add(
                new XAttribute("ConnectionString", DpapiWrapper.Encrypt(connectionString)),
                new XAttribute("Type", GetType().Name),
                new XElement("TypeOf", ResourceType)
                );

            return(result);
        }
        public void EncryptDecryptTest()
        {
            //------------Setup for test--------------------------

            //------------Execute Test---------------------------
            string encrypted = DpapiWrapper.Encrypt(message);

            encrypted.Should().NotBeNullOrEmpty();
            encrypted.Should().NotBeNullOrWhiteSpace();
            encrypted.Should().NotBeSameAs(message);
            encrypted.Should().NotContain(message);
            DpapiWrapper.Decrypt(encrypted).Should().Be(message);
        }
Example #27
0
        public void SaveTriggerQueue(ITriggerQueue triggerQueue)
        {
            if (triggerQueue.TriggerId == Guid.Empty)
            {
                triggerQueue.TriggerId = Guid.NewGuid();
            }

            var serializedData = _serializer.Serialize(triggerQueue);
            var saveData       = DpapiWrapper.Encrypt(serializedData);

            var queueFilePath = GetQueueFilePath(triggerQueue);

            _fileWrapper.WriteAllText(queueFilePath, saveData);
        }
Example #28
0
 private IAuditQueryable GetAuditQueryable()
 {
     if (Config.Server.Sink == nameof(AuditingSettingsData))
     {
         var payload             = Config.Auditing.LoggingDataSource.Payload;
         var decryptedPayload    = payload.CanBeDecrypted() ? DpapiWrapper.Decrypt(payload) : payload;
         var elasticsearchSource = new Dev2JsonSerializer().Deserialize <ElasticsearchSource>(decryptedPayload);
         return(new AuditQueryableElastic(elasticsearchSource.HostName, elasticsearchSource.Port, elasticsearchSource.SearchIndex, elasticsearchSource.AuthenticationType, elasticsearchSource.Username, elasticsearchSource.Password));
     }
     else
     {
         return(new AuditQueryableSqlite());
     }
 }
Example #29
0
        public override XElement ToXml()
        {
            var result           = base.ToXml();
            var connectionString = string.Join(";",
                                               string.Format("EndpointUrl={0}", EndpointUrl)
                                               );

            result.Add(
                new XAttribute("ConnectionString", DpapiWrapper.Encrypt(connectionString)),
                new XAttribute("Type", ResourceType),
                new XElement("TypeOf", ResourceType)
                );

            return(result);
        }
        public void DsfAbstractFileActivity_DecryptForShowPassword_ShouldShowDecryptedType()
        {
            //------------Setup for test--------------------------
            const string password = "******";
            var          encrypt  = DpapiWrapper.Encrypt(password);
            var          act      = new TestActivity("TestActivity")
            {
                Password = encrypt
            };
            var privateObject     = new Warewolf.Testing.PrivateObject(act);
            var decryptedPassword = privateObject.GetProperty("DecryptedPassword");

            //------------Execute Test---------------------------
            //------------Assert Results-------------------------
            Assert.AreEqual(password, decryptedPassword);
        }