Esempio n. 1
0
 public void SetCaptchaSolver(ReCaptchaSettings settings)
 {
     if (settings != null)
     {
         CaptchaSolver = CreateReCaptchaSolver(settings);
     }
 }
Esempio n. 2
0
 public ReCaptchaTagHelper(IOptions <ReCaptchaSettings> optionsAccessor, IResourceManager resourceManager, IHttpContextAccessor httpContextAccessor, ILogger <ReCaptchaTagHelper> logger)
 {
     _resourceManager     = resourceManager;
     _httpContextAccessor = httpContextAccessor;
     _settings            = optionsAccessor.Value;
     Mode    = ReCaptchaMode.PreventRobots;
     _logger = logger;
 }
Esempio n. 3
0
 public ReCaptchaService(ReCaptchaClient reCaptchaClient, IOptions <ReCaptchaSettings> optionsAccessor, IEnumerable <IDetectRobots> robotDetectors, IHttpContextAccessor httpContextAccessor, ILogger <ReCaptchaService> logger, IStringLocalizer <ReCaptchaService> stringLocalizer)
 {
     _reCaptchaClient     = reCaptchaClient;
     _settings            = optionsAccessor.Value;
     _robotDetectors      = robotDetectors;
     _httpContextAccessor = httpContextAccessor;
     _logger = logger;
     T       = stringLocalizer;
 }
Esempio n. 4
0
        public ReCaptchaService(ReCaptchaSettings settings)
        {
            ReCaptchaSettings = settings;

            if (Client == null)
            {
                Client = new HttpClient();
            }
        }
Esempio n. 5
0
        private ISolver CreateReCaptchaSolver(ReCaptchaSettings settings)
        {
            try
            {
                if (settings.IsValid() == false)
                {
                    return(null);
                }
                ISolver solver = new ReCaptchaV2(settings);

                return(solver);
            }
            catch (Exception ex)
            {
                App.LogWriter.WriteLog($"Can't Create Captcha Solver {ex.Message}");
                return(null);
            }
        }
Esempio n. 6
0
        private ReCaptchaService CreateService(HttpClient httpClient = null, Mock <IOptions <ReCaptchaSettings> > reCaptchaSettingsMock = null)
        {
            httpClient ??= new HttpClient();

            if (reCaptchaSettingsMock == null)
            {
                var reCaptchaSettings = new ReCaptchaSettings()
                {
                    SecretKey = "123",
                    SiteKey   = "123",
                    Version   = ReCaptchaVersion.V2
                };

                reCaptchaSettingsMock = new Mock <IOptions <ReCaptchaSettings> >();
                reCaptchaSettingsMock.Setup(x => x.Value).Returns(reCaptchaSettings);
            }

            return(new ReCaptchaService(httpClient, reCaptchaSettingsMock.Object));
        }
Esempio n. 7
0
 public IpAddressRobotDetector(IHttpContextAccessor httpContextAccessor, IMemoryCache memoryCache, IOptions <ReCaptchaSettings> settingsAccessor)
 {
     _httpContext = httpContextAccessor.HttpContext;
     _memoryCache = memoryCache;
     _settings    = settingsAccessor.Value;
 }
Esempio n. 8
0
 public ReCaptchaController(IOptions <ReCaptchaSettings> settings)
 {
     this.settings = settings.Value;
 }
Esempio n. 9
0
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            //Validate

            if (!IsValidUrl())
            {
                MessageBox.Show("Incorrect url. Try Again", Title, MessageBoxButton.OK, MessageBoxImage.Information);
                TargetUrl.Focus();
                TargetUrl.SelectAll();
                return;
            }

            if (StartPosition.Value > EndPosition.Value)
            {
                MessageBox.Show("Incorrect users range. Try Again", Title, MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            if (manager.UserCount == 0)
            {
                MessageBox.Show("No users in file. Try Again", Title, MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            //Initialize

            StartButton.IsEnabled   = false;
            TargetUrl.IsReadOnly    = true;
            StartPosition.IsEnabled = false;
            EndPosition.IsEnabled   = false;

            manager.FirstWatcher = (StartPosition.Value != null) ? (int)(StartPosition.Value - 1) : 0;
            manager.LastWatcher  = EndPosition.Value ?? manager.UserCount;
            manager.Channel      = TargetUrl.Text.Trim();

            if (CaptchaCheckBox.IsChecked == true)
            {
                ReCaptchaSettings settings = new ReCaptchaSettings
                {
                    ApiKey      = RuCaptchaApiKey.Text.Trim(),
                    FirstDelay  = FirstCaptchaWait.Value.HasValue ? (int)FirstCaptchaWait.Value : -1,
                    SecondDelay = FirstCaptchaWait.Value.HasValue ? (int)SecongCaptchaWait.Value : -1,
                    Attempts    = CaptchaRequest.Value.HasValue ? (int)CaptchaRequest.Value : -1
                };
                manager.SetCaptchaSolver(settings);
            }

            //Start

            Overlay overLay = new Overlay()
            {
                Owner = this, MyMessage = "Starting..."
            };
            bool isOverlayClosed = false;

            manager.WatcherManagerCreatedEvent += (s, arg) => {
                overLay.Dispatcher.Invoke(() => overLay.Close());
                isOverlayClosed = true;
                EnablePreview.Dispatcher.Invoke(() => EnablePreview.IsEnabled   = true);
                SaveButton.Dispatcher.Invoke(() => SaveButton.IsEnabled         = true);
                mainTabControl.Dispatcher.Invoke(() => OptionsTabItem.IsEnabled = false);
            };
            manager.StartAsync();
            if (!isOverlayClosed)
            {
                overLay.ShowDialog();
            }
        }
 public ReCaptchaService(IOptions <ReCaptchaSettings> settings)
 {
     this.settings = settings.Value;
 }
 public GoogleReCaptchaService(IOptions <ReCaptchaSettings> options)
 {
     _settings = options.Value;
 }
Esempio n. 12
0
 public ReCaptchaService(ReCaptchaSettings settings, HttpClient client)
 {
     ReCaptchaSettings = settings;
     Client            = client;
 }
Esempio n. 13
0
 public CaptchaService(IConfiguration configuration)
 {
     this._recaptchaSettings = new ReCaptchaSettings();
     configuration.GetSection(ReCaptchaSettings.ReCaptcha).Bind(this._recaptchaSettings);
 }