コード例 #1
0
        private async Task <int> ReEncryptSharedRepositoryPasswordValues(string oldKey = null)
        {
            ShowStatusMessage("Re-Encrypting Shared Repository Password variables Values with new Key...");
            return(await Task.Run(() =>
            {
                int varReencryptedCount = 0;
                //For Shared Variables
                List <GingerCore.Variables.VariableBase> sharedRepoVarsList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <GingerCore.Variables.VariableBase>().Where(f => f is GingerCore.Variables.VariablePasswordString).ToList();
                foreach (var sharedVar in sharedRepoVarsList)
                {
                    try
                    {
                        ((GingerCore.Variables.VariablePasswordString)sharedVar).Password =
                            EncryptionHandler.ReEncryptString(((GingerCore.Variables.VariablePasswordString)sharedVar).Password, oldKey);

                        WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(sharedVar);

                        varReencryptedCount++;
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, string.Format("ReEncryptVariable- Failed to Re-encrypt shared password variable of {0}.", sharedVar.Name), ex);
                    }
                }

                //For Shared Activites
                List <Activity> sharedActivityList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>().ToList();
                foreach (var sharedAct in sharedActivityList)
                {
                    try
                    {
                        List <GingerCore.Variables.VariableBase> variables = sharedAct.Variables.Where(f => f is GingerCore.Variables.VariablePasswordString).ToList();
                        variables.ForEach(v =>
                        {
                            try
                            {
                                ((GingerCore.Variables.VariablePasswordString)v).Password =
                                    EncryptionHandler.ReEncryptString(((GingerCore.Variables.VariablePasswordString)v).Password, oldKey);
                                varReencryptedCount++;
                            }
                            catch (Exception ex)
                            {
                                Reporter.ToLog(eLogLevel.ERROR, string.Format("ReEncryptVariable- Failed to Re-encrypt password variable of shared activity {0} for {1}", sharedAct.ActivityName, v.Name), ex);
                            }
                        });

                        if (variables.Any())
                        {
                            WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(sharedAct);
                        }
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, string.Format("ReEncryptVariable- Failed to update shared activity {0}.", sharedAct.ActivityName), ex);
                    }
                }

                return varReencryptedCount;
            }));
        }
コード例 #2
0
        private async Task <int> ReEncryptGlobalVariables(string oldKey = null)
        {
            ShowStatusMessage("Re-Encrypting Global Password variables Values with new Key...");
            return(await Task.Run(() =>
            {
                // For Global Variables
                bool isSaveRequired = false;
                int varReencryptedCount = 0;
                foreach (GingerCore.Variables.VariableBase v in WorkSpace.Instance.Solution.Variables.Where(f => f is GingerCore.Variables.VariablePasswordString))
                {
                    try
                    {
                        ((GingerCore.Variables.VariablePasswordString)v).Password =
                            EncryptionHandler.ReEncryptString(((GingerCore.Variables.VariablePasswordString)v).Password, oldKey);
                        isSaveRequired = true;

                        varReencryptedCount++;
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, string.Format("ReEncryptVariable- Failed to Re-encrypt password Global variable {1}", v.Name), ex);
                    }
                }
                if (isSaveRequired)
                {
                    WorkSpace.Instance.Solution.SolutionOperations.SaveSolution(false);
                }
                return varReencryptedCount;
            }));
        }
コード例 #3
0
        private async Task <int> ReEncryptEnvironmentPasswordValues(string oldKey = null)
        {
            ShowStatusMessage("Re-Encrypting Environment paramters and DB Password Values with new Key...");
            return(await Task.Run(() =>
            {
                bool isSaveRequired = false;
                int varReencryptedCount = 0;

                //For project environment variable
                List <ProjEnvironment> projEnvironments = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ProjEnvironment>().ToList();
                projEnvironments.ForEach(pe =>
                {
                    try
                    {
                        isSaveRequired = false;
                        foreach (EnvApplication ea in pe.Applications)
                        {
                            foreach (GeneralParam gp in ea.GeneralParams.Where(f => f.Encrypt))
                            {
                                gp.Value = EncryptionHandler.ReEncryptString(gp.Value, oldKey);
                                isSaveRequired = true;
                                varReencryptedCount++;
                            }
                            foreach (Database db in ea.Dbs)
                            {
                                if (!string.IsNullOrEmpty(db.Pass))
                                {
                                    //if Pass is stored in the form of variable, encryption not required at this stage
                                    if (!db.Pass.Contains("{Var Name") && !db.Pass.Contains("{EnvParam"))
                                    {
                                        string encryptedPassWord = EncryptionHandler.ReEncryptString(db.Pass, oldKey);
                                        if (string.IsNullOrEmpty(encryptedPassWord))
                                        {
                                            encryptedPassWord = EncryptionHandler.EncryptwithKey(db.Pass);
                                        }
                                        db.Pass = encryptedPassWord;
                                    }
                                    isSaveRequired = true;
                                    varReencryptedCount++;
                                }
                            }
                        }
                        if (isSaveRequired)
                        {
                            WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(pe);
                        }
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "ReEncryptVariable- Failed to Re-encrypt password ProjEnvironment variable for " + pe.Name, ex);
                    }
                });

                return varReencryptedCount;
            }));
        }
コード例 #4
0
        private async Task <int> ReEncryptRunsetOperationsPassowrdValues(string oldKey = null)
        {
            ShowStatusMessage("Re-Encrypting Runset Operations SMTP Password Values with new Key...");
            return(await Task.Run(() =>
            {
                bool isSaveRequired = false;
                int varReencryptedCount = 0;
                //Email Passwords
                var runSetConfigs = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <RunSetConfig>();

                foreach (var rsc in runSetConfigs)
                {
                    try
                    {
                        isSaveRequired = false;
                        foreach (var ra in rsc.RunSetActions)
                        {
                            if (ra is RunSetActionHTMLReportSendEmail && ((RunSetActionHTMLReportSendEmail)ra).Email != null &&
                                !string.IsNullOrEmpty(((RunSetActionHTMLReportSendEmail)ra).Email.SMTPPass))
                            {
                                ((RunSetActionHTMLReportSendEmail)ra).Email.SMTPPass =
                                    EncryptionHandler.ReEncryptString(((RunSetActionHTMLReportSendEmail)ra).Email.SMTPPass, oldKey);
                                isSaveRequired = true;
                                varReencryptedCount++;
                            }
                            else if (ra is RunSetActionSendFreeEmail && ((RunSetActionSendFreeEmail)ra).Email != null &&
                                     !string.IsNullOrEmpty(((RunSetActionSendFreeEmail)ra).Email.SMTPPass))
                            {
                                ((RunSetActionSendFreeEmail)ra).Email.SMTPPass =
                                    EncryptionHandler.ReEncryptString(((RunSetActionSendFreeEmail)ra).Email.SMTPPass, oldKey);
                                isSaveRequired = true;
                                varReencryptedCount++;
                            }
                            else if (ra is RunSetActionSendSMS && ((RunSetActionSendSMS)ra).SMSEmail != null &&
                                     !string.IsNullOrEmpty(((RunSetActionSendSMS)ra).SMSEmail.SMTPPass))
                            {
                                ((RunSetActionSendSMS)ra).SMSEmail.SMTPPass =
                                    EncryptionHandler.ReEncryptString(((RunSetActionSendSMS)ra).SMSEmail.SMTPPass, oldKey);
                                isSaveRequired = true;
                                varReencryptedCount++;
                            }
                        }
                        if (isSaveRequired)
                        {
                            WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(rsc);
                        }
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Encrypting Email SMTP password of " + rsc.Name, ex);
                    }
                }
                return varReencryptedCount;
            }));
        }
コード例 #5
0
        private async Task <int> ReEncryptBFAndACtivityVariable(string oldKey = null)
        {
            ShowStatusMessage("Re-Encrypting Business flow and activity Password variables Values with new Key...");
            return(await Task.Run(() =>
            {
                int varReencryptedCount = 0;
                List <BusinessFlow> Bfs = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <BusinessFlow>().ToList();
                // For BF and Activity
                Parallel.ForEach(Bfs, Bf =>
                {
                    try
                    {
                        // Get all variables from BF
                        List <GingerCore.Variables.VariableBase> variables = Bf.GetBFandActivitiesVariabeles(false).Where(f => f is GingerCore.Variables.VariablePasswordString).ToList();
                        variables.ForEach(v =>
                        {
                            try
                            {
                                ((GingerCore.Variables.VariablePasswordString)v).Password =
                                    EncryptionHandler.ReEncryptString(((GingerCore.Variables.VariablePasswordString)v).Password, oldKey);

                                varReencryptedCount++;
                            }
                            catch (Exception ex)
                            {
                                Reporter.ToLog(eLogLevel.ERROR, string.Format("ReEncryptVariable- Failed to Re-encrypt password variable of {0} for {1}", Bf.Name, v.Name), ex);
                            }
                        });

                        if (variables.Any())
                        {
                            WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(Bf);
                        }
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, string.Format("ReEncryptVariable- Failed to Re encrypt password variable of {0}.", Bf.Name), ex);
                    }
                });
                return varReencryptedCount;
            }));
        }