示例#1
0
        public YadWebRequestRepo(IWebProxy proxy, IBasicCredentials creds)
        {
            ServicePointManager.DefaultConnectionLimit = int.MaxValue;

            HttpSettings.Proxy = proxy;
            _creds             = creds;
        }
示例#2
0
        public OAuth(HttpCommonSettings settings, IBasicCredentials creds, AuthCodeRequiredDelegate onAuthCodeRequired)
        {
            _settings           = settings;
            _creds              = creds;
            _onAuthCodeRequired = onAuthCodeRequired;
            Cookies             = new CookieContainer();

            _authToken = new Cached <AuthTokenResult>(old =>
            {
                Logger.Debug(null == old ? "OAuth: authorizing." : "OAuth: AuthToken expired, refreshing.");

                var token = null == old || string.IsNullOrEmpty(old.RefreshToken)
                        ? Auth().Result
                        : Refresh(old.RefreshToken).Result;

                return(token);
            },
                                                      value =>
            {
                if (null == value)
                {
                    return(TimeSpan.MaxValue);
                }
                return(value.ExpiresIn.Add(-TimeSpan.FromMinutes(5)));
            });
            //value => TimeSpan.FromSeconds(20));
        }
示例#3
0
        public WebAuth(HttpCommonSettings settings, IBasicCredentials creds, AuthCodeRequiredDelegate onAuthCodeRequired)
        {
            _settings = settings;
            _creds    = creds;
            Cookies   = new CookieContainer();

            var logged = MakeLogin(onAuthCodeRequired).Result;

            if (!logged)
            {
                throw new AuthenticationException($"Cannot log in {creds.Login}");
            }


            _authToken = new Cached <AuthTokenResult>(old =>
            {
                Logger.Debug("AuthToken expired, refreshing.");
                if (!creds.IsAnonymous)
                {
                    var token = Auth().Result;
                    return(token);
                }
                return(null);
            },
                                                      value => TimeSpan.FromSeconds(AuthTokenExpiresInSec));

            _cachedDownloadToken = new Cached <string>(old => new DownloadTokenRequest(_settings, this).MakeRequestAsync().Result.ToToken(),
                                                       value => TimeSpan.FromSeconds(DownloadTokenExpiresSec));
        }
示例#4
0
        public YadWebAuth(HttpCommonSettings settings, IBasicCredentials creds)
        {
            _settings = settings;
            _creds    = creds;
            Cookies   = new CookieContainer();

            var _ = MakeLogin().Result;
        }
示例#5
0
        public WebM1RequestRepo(IWebProxy proxy, IBasicCredentials creds, AuthCodeRequiredDelegate onAuthCodeRequired)
        {
            ServicePointManager.DefaultConnectionLimit = int.MaxValue;

            HttpSettings.Proxy = proxy;
            Authent            = new OAuth(HttpSettings, creds, onAuthCodeRequired);
            _shardManager      = new ShardManager(HttpSettings, Authent);
        }
        protected MailRuBaseRepo(IBasicCredentials creds)
        {
            Credentials = creds;

            if (!AvailDomains.Any(d => creds.Login.Contains($"@{d}.")))
            {
                string domains = AvailDomains.Aggregate((c, n) => c + ", @" + n);
                Logger.Warn($"Missing domain part ({domains}) in login, file and folder deleting will be denied");
            }
        }
        public WebBinRequestRepo(IWebProxy proxy, IBasicCredentials creds, AuthCodeRequiredDelegate onAuthCodeRequired)
            : base(creds)
        {
            _onAuthCodeRequired = onAuthCodeRequired;

            ServicePointManager.DefaultConnectionLimit = int.MaxValue;

            HttpSettings.Proxy = proxy;
            Authent            = new OAuth(HttpSettings, creds, onAuthCodeRequired);
        }
        public WebV2RequestRepo(IWebProxy proxy, IBasicCredentials creds, AuthCodeRequiredDelegate onAuthCodeRequired)
        {
            HttpSettings.Proxy = proxy;

            Authent = new WebAuth(HttpSettings, creds, onAuthCodeRequired);

            _bannedShards = new Cached <List <ShardInfo> >(old => new List <ShardInfo>(),
                                                           value => TimeSpan.FromMinutes(2));

            _cachedShards = new Cached <Dictionary <ShardType, ShardInfo> >(old => new ShardInfoRequest(HttpSettings, Authent).MakeRequestAsync().Result.ToShardInfo(),
                                                                            value => TimeSpan.FromSeconds(ShardsExpiresInSec));
        }
示例#9
0
        public WebM1RequestRepo(IWebProxy proxy, IBasicCredentials creds, AuthCodeRequiredDelegate onAuthCodeRequired, int listDepth)
        {
            _creds = creds;
            _onAuthCodeRequired = onAuthCodeRequired;
            _listDepth          = listDepth;

            ServicePointManager.DefaultConnectionLimit = int.MaxValue;

            HttpSettings.Proxy = proxy;
            Authent            = new OAuth(HttpSettings, creds, onAuthCodeRequired);
            //ShardManager = new ShardManager(HttpSettings, Authent);
        }
        public WebBinRequestRepo(IWebProxy proxy, IBasicCredentials creds, AuthCodeRequiredDelegate onAuthCodeRequired)
            : base(creds)
        {
            _onAuthCodeRequired = onAuthCodeRequired;

            ServicePointManager.DefaultConnectionLimit = int.MaxValue;

            // required for Windows 7 breaking connection
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13 | SecurityProtocolType.Tls12;

            HttpSettings.Proxy = proxy;
            Authent            = new OAuth(HttpSettings, creds, onAuthCodeRequired);
        }
示例#11
0
        public YadWebRequestRepo(IWebProxy proxy, IBasicCredentials creds)
        {
            ServicePointManager.DefaultConnectionLimit = int.MaxValue;

            HttpSettings.Proxy = proxy;
            Authent            = new YadWebAuth(HttpSettings, creds);

            CachedSharedList = new Cached <Dictionary <string, IEnumerable <PublicLinkInfo> > >(old =>
            {
                var res = GetShareListInner().Result;
                return(res);
            },
                                                                                                value => TimeSpan.FromSeconds(30));
        }
        protected WebM1RequestRepo(IWebProxy proxy, IBasicCredentials creds, AuthCodeRequiredDelegate onAuthCodeRequired)
            : base(creds)
        {
            _onAuthCodeRequired = onAuthCodeRequired;

            ServicePointManager.DefaultConnectionLimit = int.MaxValue;

            HttpSettings.Proxy = proxy;
            Authent            = new OAuth(HttpSettings, creds, onAuthCodeRequired);

            CachedSharedList = new Cached <Dictionary <string, string> >(old =>
            {
                var z = GetShareListInner().Result;

                var res = z.Body.List.ToDictionary(fik => fik.Home, fiv => fiv.Weblink);

                return(res);
            },
                                                                         value => TimeSpan.FromSeconds(30));
        }
        public WebM1RequestRepo(IWebProxy proxy, IBasicCredentials creds, AuthCodeRequiredDelegate onAuthCodeRequired, int listDepth)
        {
            _creds = creds;
            _onAuthCodeRequired = onAuthCodeRequired;
            _listDepth          = listDepth;

            ServicePointManager.DefaultConnectionLimit = int.MaxValue;

            HttpSettings.Proxy = proxy;
            Authent            = new OAuth(HttpSettings, creds, onAuthCodeRequired);
            //ShardManager = new ShardManager(HttpSettings, Authent);


            CachedSharedList = new Cached <Dictionary <string, string> >(old =>
            {
                var z = GetShareListInner().Result;

                var res = z.body.list.ToDictionary(fik => fik.home, fiv => fiv.weblink);

                return(res);
            },
                                                                         value => TimeSpan.FromSeconds(30));
        }
示例#14
0
 public OAuthRequest(HttpCommonSettings settings, IBasicCredentials creds) : base(settings, null)
 {
     _login    = Uri.EscapeDataString(creds.Login);
     _password = Uri.EscapeDataString(creds.Password);
 }