private void CopyDriverFiles(LockSmithConfigurationActivityData _activitydata)
        {
            ExecutionServices.SystemTrace.LogDebug("Copying Selenium _driver files...");
            StringBuilder exePath = new StringBuilder(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            if (_activityData.Browser == BrowserType.InternetExplorer)
            {
                exePath.Append("\\IEDriverServer.exe");
                if (!File.Exists(exePath.ToString()))
                {
                    UpdateStatus("Copying Internet explorer web driver");
                    File.WriteAllBytes(exePath.ToString(), Resource.IEDriverServer);
                }
                InternetExplorerOptions options = new InternetExplorerOptions();
                options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                options.IgnoreZoomLevel = true;
                _driver = new InternetExplorerDriver(options);
                UpdateStatus("Launching Internet explore");
            }
            else if (_activityData.Browser == BrowserType.GoogleChrome)
            {
                exePath.Append("\\chromedriver.exe");
                if (!File.Exists(exePath.ToString()))
                {
                    UpdateStatus("Copying Google chrome web driver");
                    File.WriteAllBytes(exePath.ToString(), Resource.chromedriver);
                }
                _driver = new ChromeDriver();
                UpdateStatus("Launching google chrome");
            }
            ExecutionServices.SystemTrace.LogDebug("Files copied...");
        }
예제 #2
0
 /// <summary>
 /// Initializes this configuration control to default values.
 /// </summary>
 /// <param name="environment">Information about the plugin environment.</param>
 public void Initialize(PluginEnvironment environment)
 {
     _activityData = new LockSmithConfigurationActivityData();
     lockSmith_ServerComboBox.Initialize("LockSmith");
     discoveryType_ComboBox.SelectedIndex = 0;
     browserType_ComboBox.SelectedIndex   = 0;
     toolTip.SetToolTip(user_TextBox, "Format: Domain\\Username");
 }
        public PluginExecutionResult ApplyConfiguration(PluginExecutionData executionData)
        {
            _executionData = executionData;
            _activityData  = executionData.GetMetadata <LockSmithConfigurationActivityData>();
            try
            {
                CopyDriverFiles(_activityData);
                _driver.Manage().Window.Maximize();
                PerformLogin();
                SettingEWSAdminPassword();
                CreateGroup();
                switch (_activityData.Adddevice)
                {
                case PrinterDiscovery.ManualIPAddress:
                    PrinterDiscoveryManualIPAddress();
                    break;

                case PrinterDiscovery.DeviceListFile:
                    PrinterDiscoveryDeviceListFile();
                    break;

                case PrinterDiscovery.AutomaticHops:
                    PrinterDiscoveryAutomaticHops();
                    break;

                case PrinterDiscovery.AutomaticRange:
                    PrinterDiscoveryAutomaticRange();
                    break;

                case PrinterDiscovery.AssetInventory:
                    PrinterDiscoveryAssetInventory();
                    break;
                }

                if (_activityData.PolicyConfiguration)
                {
                    ImportPolicy();
                }

                if (_activityData.ReportExtraction)
                {
                    GenerateReports();
                }

                UpdateStatus("Activities completed successfully.");

                return(new PluginExecutionResult(PluginResult.Passed));
            }
            catch (IOException exception)
            {
                ExecutionServices.SystemTrace.LogError(exception.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, "Selenium Web driver is already in use. Please close all diver instances and re-run."));
            }
            catch (NoSuchElementException exception)
            {
                ExecutionServices.SystemTrace.LogError(exception.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, "Selenium Web element does not exist."));
            }
            catch (NotFoundException exception)
            {
                ExecutionServices.SystemTrace.LogError(exception.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, "Unable to find Selenium web element."));
            }
            catch (StaleElementReferenceException exception)
            {
                ExecutionServices.SystemTrace.LogError(exception.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, "Selenium element reference does not exist."));
            }
            catch (WebDriverTimeoutException exception)
            {
                ExecutionServices.SystemTrace.LogError(exception.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, "Selenium webDriver timed out."));
            }
            catch (WebDriverException exception)
            {
                ExecutionServices.SystemTrace.LogError(exception.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, "Lost communication with the Selenium webdriver."));
            }
            catch (LocksmithConfigurationException exception)
            {
                ExecutionServices.SystemTrace.LogError(exception.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, "Locksmith configuration operation failed while performing a selenium action."));
            }
            catch (Exception exception)
            {
                ExecutionServices.SystemTrace.LogError(exception.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, "Locksmith configuration operation failed."));
            }
            finally
            {
                if (_driver != null)
                {
                    _driver.Quit();
                    _driver.Dispose();
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Initializes this configuration control with the specified <see cref="PluginConfigurationData" />.
        /// </summary>
        /// <param name="configuration">The configuration data.</param>
        /// <param name="environment">Information about the plugin environment.</param>
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            Guid _selectedServer = Guid.Empty;

            _activityData   = configuration.GetMetadata <LockSmithConfigurationActivityData>();
            _selectedServer = configuration.Servers.SelectedServers.FirstOrDefault();
            lockSmith_ServerComboBox.Initialize(_selectedServer, "Locksmith");
            user_TextBox.Text                             = _activityData.LockSmithUser;
            password_TextBox.Text                         = _activityData.LockSmithPassword;
            ewsAdminPassword_TextBox.Text                 = _activityData.EWSAdminPassword;
            validatePolicyPath_CheckBox.Checked           = _activityData.ValidatePolicyPath;
            existingPolicyName_CheckBox.Checked           = _activityData.ExisintingPolicyCheckbox;
            policyPath_TextBox.Text                       = _activityData.PolicyFilePath;
            policyPassword_TextBox.Text                   = _activityData.PolicyPassword;
            groupName_TextBox.Text                        = _activityData.GroupName;
            ipAddressFile_textBox.Text                    = _activityData.DeviceListPath;
            automaticStartIPAddress_IpAddressControl.Text = _activityData.StartIPAddress;
            automaticEndIPAddress_IpAddressControl.Text   = _activityData.EndIPAddress;
            manualIPAddress_IpAddressControl.Text         = _activityData.ManualIPAddress;
            browserType_ComboBox.SelectedItem             = _activityData.Browser;
            existingPolicyName_TextBox.Text               = _activityData.ExistingPolicyName;
            printerDiscovery_CheckBox.Checked             = _activityData.DeviceDiscovery;
            importAndApplyPolicy_CheckBox.Checked         = _activityData.PolicyConfiguration;
            generateReports_CheckBox.Checked              = _activityData.ReportExtraction;
            discoveryType_ComboBox.Text                   = _activityData.DeviceDiscovery.ToString();
            assessOnly_RadioButton.Checked                = _activityData.AssessOnly;
            assessAndRemediate_RadioButton.Checked        = _activityData.AssessandRemediate;
            assetSelectionControl.Initialize(configuration.Assets, AssetAttributes.ControlPanel);
            switch (_activityData.Adddevice)
            {
            case PrinterDiscovery.ManualIPAddress:
                printerDiscovery_CheckBox.Checked   = true;
                discoveryType_ComboBox.SelectedItem = EnumUtil.GetDescription(PrinterDiscovery.ManualIPAddress);
                break;

            case PrinterDiscovery.DeviceListFile:
                printerDiscovery_CheckBox.Checked   = true;
                discoveryType_ComboBox.SelectedItem = EnumUtil.GetDescription(PrinterDiscovery.DeviceListFile);
                break;

            case PrinterDiscovery.AssetInventory:
                assetSelectionControl.Enabled       = true;
                discoveryType_ComboBox.SelectedItem = EnumUtil.GetDescription(PrinterDiscovery.AssetInventory);
                break;

            case PrinterDiscovery.AutomaticHops:
                discoveryType_ComboBox.SelectedItem     = EnumUtil.GetDescription(PrinterDiscovery.AutomaticHops);
                printerDiscovery_CheckBox.Checked       = true;
                numberOfNetworkHops_RadioButton.Checked = true;
                ipRange_RadioButton.Checked             = false;
                break;

            case PrinterDiscovery.AutomaticRange:
                discoveryType_ComboBox.SelectedItem     = EnumUtil.GetDescription(PrinterDiscovery.AutomaticRange);
                printerDiscovery_CheckBox.Checked       = true;
                ipRange_RadioButton.Checked             = true;
                numberOfNetworkHops_RadioButton.Checked = false;
                break;
            }

            if (_activityData.PolicyConfiguration)
            {
                importAndApplyPolicy_CheckBox.Checked = true;
            }

            if (_activityData.ReportExtraction)
            {
                generateReports_CheckBox.Checked = true;
            }

            switch (_activityData.Browser)
            {
            case BrowserType.InternetExplorer:
                browserType_ComboBox.SelectedItem = EnumUtil.GetDescription(BrowserType.InternetExplorer);
                break;

            case BrowserType.GoogleChrome:
                browserType_ComboBox.SelectedItem = EnumUtil.GetDescription(BrowserType.GoogleChrome);
                break;
            }
        }