public SlackIntegration(IEventAggregator eventAggregator, IHttpForm httpForm, string uniqueUrl) : base(eventAggregator) { Check.Argument.IsNotEmpty(uniqueUrl, "uniqueUrl"); Check.Argument.IsNotNull(httpForm, "httpForm"); _httpForm = httpForm; _uniqueUrl = uniqueUrl; }
public PageGlimpseThumbnail(string key, string baseUrl, IHttpForm httpForm) { Check.Argument.IsNotEmpty(key, "key"); Check.Argument.IsNotEmpty(baseUrl, "baseUrl"); Check.Argument.IsNotNull(httpForm, "httpForm"); _key = key; _baseUrl = baseUrl; _httpForm = httpForm; }
public ContentService(IHttpForm httpForm, IHtmlToStoryContentConverter converter, string shortUrlProviderFormat) { Check.Argument.IsNotNull(httpForm, "httpForm"); Check.Argument.IsNotNull(converter, "converter"); Check.Argument.IsNotEmpty(shortUrlProviderFormat, "shortUrlProviderFormat"); _httpForm = httpForm; _converter = converter; _shortUrlProviderFormat = shortUrlProviderFormat; }
public PingStory(IConfigurationSettings settings, IEventAggregator eventAggregator, IHttpForm httpForm, IContentService contentService, string textFormat) : base(eventAggregator) { Check.Argument.IsNotNull(settings, "settings"); Check.Argument.IsNotNull(httpForm, "httpForm"); Check.Argument.IsNotNull(contentService, "contentService"); Check.Argument.IsNotEmpty(textFormat, "textFormat"); _settings = settings; _httpForm = httpForm; _contentService = contentService; _textFormat = textFormat; }
public PingServer(IConfigurationSettings settings, IEventAggregator eventAggregator, IHttpForm httpForm, string url, float intervalInMinutes) : base(eventAggregator) { Check.Argument.IsNotNull(settings, "settings"); Check.Argument.IsNotNull(httpForm, "httpForm"); Check.Argument.IsNotEmpty(url, "url"); Check.Argument.IsNotNegative(intervalInMinutes, "intervalInMinutes"); _settings = settings; _httpForm = httpForm; _url = url; _intervalInMinutes = intervalInMinutes; }
public DefensioSpamProtection(string apiKey, string version, IConfigurationSettings settings, IHttpForm httpForm) { Check.Argument.IsNotEmpty(apiKey, "apiKey"); Check.Argument.IsNotEmpty(apiKey, "version"); Check.Argument.IsNotNull(settings, "settings"); Check.Argument.IsNotNull(httpForm, "httpForm"); _apiKey = apiKey; _version = version; _settings = settings; _httpForm = httpForm; }
public BrowshotThumbnail(string key, string baseUrl, int instanceId, IHttpForm httpForm, IEncoder encoder) { Check.Argument.IsNotEmpty(key, "key"); Check.Argument.IsNotEmpty(baseUrl, "baseUrl"); Check.Argument.IsNotNull(httpForm, "httpForm"); Check.Argument.IsNotNull(encoder, "encoder"); _key = key; _baseUrl = baseUrl; _instanceId = instanceId; _httpForm = httpForm; _encoder = encoder; }
/// <summary> /// v1.3.17 2011-12-15 /// </summary> private CookieContainer Login(string name, string pass) { IHttpForm http = HttpFormFactory.DefaultHttpForm(); name = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(name)); pass = HttpUtility.UrlEncode(pass); var preloginUrl = string.Format("http://login.sina.com.cn/sso/prelogin.php?entry=weibo&callback=sinaSSOController.preloginCallBack&su={0}&client=ssologin.js(v1.3.17)&_={1}", name, DateTimeHelper.GetTimestamp()); HttpFormResponse response = http.Get(preloginUrl); Match m = Regex.Match(response.Response, "\"retcode\":(?<retcode>\\d),\"servertime\":(?<servertime>\\d+),\"pcid\":\"[\\w]+\",\"nonce\":\"(?<nonce>[0-9a-zA-Z]+)\"", RegexOptions.IgnoreCase); var servertime = m.Groups["servertime"].Value; var nonce = m.Groups["nonce"].Value; JSSha1Util jsMD5 = new JSSha1Util(); var password = jsMD5.Hex_sha1("" + jsMD5.Hex_sha1(jsMD5.Hex_sha1(pass)) + servertime + nonce); var postData = string.Format("entry=weibo&gateway=1&from=&savestate=7&useticket=1&ssosimplelogin=1&vsnf=1&vsnval=&su={0}&service=miniblog&servertime={1}&nonce={2}&pwencode=wsse&sp={3}&encoding=UTF-8&url=http%3A%2F%2Fweibo.com%2Fajaxlogin.php%3Fframelogin%3D1%26callback%3Dparent.sinaSSOController.feedBackUrlCallBack&returntype=META", name, servertime, nonce, password); HttpFormPostRawRequest postRequest = new HttpFormPostRawRequest(); postRequest.Data = postData; postRequest.Url = "http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.3.17)"; postRequest.Referer = "http://weibo.com/"; postRequest.Cookies = new CookieContainer(); response = http.Post(postRequest); var content = response.Response; m = Regex.Match(content, "location\\.replace\\(['\"](?<url>.*?)['\"]\\)", RegexOptions.IgnoreCase); var nextUrl = m.Groups["url"].Value; response.Cookies = CookieHelper.UpdateDomain(response.Cookies, "weibo.com"); HttpFormGetRequest request = new HttpFormGetRequest(); request.Cookies = response.Cookies; request.Referer = "http://weibo.com/"; request.Url = nextUrl; response = http.Get(request); bool isLogin = response.Response.Contains("\"result\":true,\""); return(response.Cookies); }
public DefaultSpamProtection(IConfigurationSettings settings, IHttpForm httpForm, int storyThreshold, ISpamWeightCalculator[] storyLocalCalculators, ISpamWeightCalculator[] storyRemoteCalculators, int commentThreshold, ISpamWeightCalculator[] commentCalculators) { Check.Argument.IsNotNull(settings, "settings"); Check.Argument.IsNotNull(httpForm, "httpForm"); _settings = settings; _httpForm = httpForm; _storyThreshold = storyThreshold; _storyLocalCalculators = storyLocalCalculators; _storyRemoteCalculators = storyRemoteCalculators; _commentThreshold = commentThreshold; _commentCalculators = commentCalculators; }
public ContentService(IHttpForm httpForm, IHtmlToStoryContentConverter converter, IFile fileReader, string blockedUrlPrefixFilePath, string shortUrlProviderFormat) { Check.Argument.IsNotNull(httpForm, "httpForm"); Check.Argument.IsNotNull(converter, "converter"); Check.Argument.IsNotNull(fileReader, "fileReader"); Check.Argument.IsNotNullOrEmpty(blockedUrlPrefixFilePath, "blockedUrlPrefixFilePath"); Check.Argument.IsNotNullOrEmpty(shortUrlProviderFormat, "shortUrlProviderFormat"); _httpForm = httpForm; _converter = converter; _fileReader = fileReader; _shortUrlProviderFormat = shortUrlProviderFormat; _blockedUrlPrefixFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, blockedUrlPrefixFilePath); ReadUrlPrefexes(); }
public ContentService(IHttpForm httpForm, IHtmlToStoryContentConverter converter, IFile fileReader, string blockedUrlPrefixFilePath, string shortUrlProviderFormat) { Check.Argument.IsNotNull(httpForm, "httpForm"); Check.Argument.IsNotNull(converter, "converter"); Check.Argument.IsNotNull(fileReader, "fileReader"); Check.Argument.IsNotEmpty(blockedUrlPrefixFilePath, "blockedUrlPrefixFilePath"); Check.Argument.IsNotEmpty(shortUrlProviderFormat, "shortUrlProviderFormat"); _httpForm = httpForm; _converter = converter; _fileReader = fileReader; _shortUrlProviderFormat = shortUrlProviderFormat; _blockedUrlPrefixFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, blockedUrlPrefixFilePath); ReadUrlPrefexes(); }
public GenericExternalSpamProtection(string name, string baseUrl, string apiKey, string version, IConfigurationSettings settings, IHttpForm httpForm) { Check.Argument.IsNotEmpty(name, "name"); Check.Argument.IsNotEmpty(baseUrl, "baseUrl"); Check.Argument.IsNotEmpty(apiKey, "apiKey"); Check.Argument.IsNotEmpty(version, "version"); Check.Argument.IsNotNull(settings, "settings"); Check.Argument.IsNotNull(httpForm, "httpForm"); _name = name; _baseUrl = baseUrl; _apiKey = apiKey; _version = version; _settings = settings; _httpForm = httpForm; }
public BrowshotThumbnail( IConfigurationManager configuration, string baseUrl, int instanceId, IHttpForm httpForm, IEncoder encoder) { var key = configuration.AppSettings["browshotApiKey"]; Check.Argument.IsNotEmpty(key, "key"); Check.Argument.IsNotEmpty(baseUrl, "baseUrl"); Check.Argument.IsNotNull(httpForm, "httpForm"); Check.Argument.IsNotNull(encoder, "encoder"); _key = key; _baseUrl = baseUrl; _instanceId = instanceId; _httpForm = httpForm; _encoder = encoder; }
public reCAPTCHAValidator(string verifyUrl, string insecureHost, string secureHost, string privateKey, string publicKey, string challengeInputName, string responseInputName, IHttpForm httpFrom) { Check.Argument.IsNotInvalidWebUrl(verifyUrl, "verifyUrl"); Check.Argument.IsNotInvalidWebUrl(insecureHost, "insecureHost"); Check.Argument.IsNotInvalidWebUrl(secureHost, "secureHost"); Check.Argument.IsNotEmpty(privateKey, "privateKey"); Check.Argument.IsNotEmpty(publicKey, "publicKey"); Check.Argument.IsNotEmpty(challengeInputName, "challengeInputName"); Check.Argument.IsNotEmpty(responseInputName, "responseInputName"); Check.Argument.IsNotNull(httpFrom, "httpFrom"); _verifyUrl = verifyUrl; _insecureHost = insecureHost; _secureHost = secureHost; _privateKey = privateKey; _publicKey = publicKey; _challengeInputName = challengeInputName; _responseInputName = responseInputName; _httpForm = httpFrom; }
public SendTwitterMessage(IEventAggregator eventAggregator, IContentService contentService, IHttpForm httpForm, string userName, string password, string source, string statusUrl, bool useOriginalUrlOfStory, string directMessageUrl, string directMessageRecipients) : base(eventAggregator) { Check.Argument.IsNotNull(contentService, "contentService"); Check.Argument.IsNotNull(httpForm, "httpForm"); Check.Argument.IsNotNull(userName, "userName"); Check.Argument.IsNotNull(password, "password"); Check.Argument.IsNotNull(source, "source"); Check.Argument.IsNotEmpty(statusUrl, "statusUrl"); Check.Argument.IsNotEmpty(directMessageUrl, "directMessageUrl"); Check.Argument.IsNotEmpty(directMessageRecipients, "directMessageRecipients"); _contentService = contentService; _httpForm = httpForm; _userName = userName; _password = password; _source = source; _statusUrl = statusUrl; _useOriginalUrlOfStory = useOriginalUrlOfStory; _directMessageUrl = directMessageUrl; _directMessageRecipients = directMessageRecipients.Split('|'); }
protected DecoratedHttpForm(IHttpForm innerHttpForm) { Check.Argument.IsNotNull(innerHttpForm, "innerHttpForm"); _innerHttpForm = innerHttpForm; }
protected void btnGo_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtAppKey.Text) || string.IsNullOrEmpty(txtAppSecret.Text)) { lblErrorMsg.Text = "请输入appkey和appsecret"; return; } Session.Clear(); var site = int.Parse(drpSite.SelectedValue); if (site == 5) { site = 0; } OAuthAPIEntity entity = OAuthAPIDAL.Load(txtAppKey.Text, txtUserName.Text, site); if (entity != null) { lblErrorMsg.Text = "已经存在"; txtToken.Text = entity.Token; txtTokenSecret.Text = entity.TokenSecret; IOAuthAPI oauthAPI2 = OAuthAPIFactory.CreateOAuthAPI(); oauthAPI2.RequestTokenUrl = entity.RequestTokenUrl; oauthAPI2.AuthorizeUrl = entity.AuthorizeUrl; oauthAPI2.AccessTokenUrl = entity.AccessTokenUrl; oauthAPI2.AppKey = entity.AppKey; oauthAPI2.AppSecret = entity.AppSecret; oauthAPI2.Token = entity.Token; oauthAPI2.TokenSecret = entity.TokenSecret; Session["oauthAPI"] = oauthAPI2; return; } OAuthAPIEntity oauthAPIEntity = GetOAuthAPI(site); oauthAPIEntity.AppKey = txtAppKey.Text; oauthAPIEntity.AppSecret = txtAppSecret.Text; oauthAPIEntity.UserName = txtUserName.Text; oauthAPIEntity.Password = txtPassword.Text; oauthAPIEntity.Site = site; Session["oauthAPIObj"] = oauthAPIEntity; if (int.Parse(drpSite.SelectedValue) >= 5) { IHttpForm http = HttpFormFactory.DefaultHttpForm(); string authorizeFormat = "https://api.weibo.com/oauth2/authorize?client_id={0}&redirect_uri={1}&response_type=code"; string authorize = string.Format(authorizeFormat, oauthAPIEntity.AppKey, "http://barefoot.3322.org/queryservice.svc/query"); HttpFormGetRequest getRequest = new HttpFormGetRequest(); getRequest.Cookies = Login(oauthAPIEntity.UserName, oauthAPIEntity.Password); getRequest.Url = authorize; HttpFormResponse response = http.Get(getRequest); Match m = null; if (!response.Response.StartsWith("\"code=")) { m = Regex.Match(response.Response, "<input\\stype=\"hidden\"\\sname=\"regCallback\"\\svalue=\"(?<regCallback>[^\"]+)\"/>", RegexOptions.IgnoreCase | RegexOptions.Multiline); string regCallback = m.Groups["regCallback"].Value; string regPostData = "action=submit&response_type=code®Callback=" + regCallback + "&redirect_uri=http://barefoot.3322.org/queryservice.svc/query&client_id=" + oauthAPIEntity.AppKey + "&state=&from="; HttpFormPostRawRequest regRequest = new HttpFormPostRawRequest(); regRequest.Data = regPostData; regRequest.Url = "https://api.weibo.com/oauth2/authorize"; regRequest.Cookies = response.Cookies; response = http.Post(regRequest); } string code = response.Response.Trim('\"').Substring(5); HttpFormPostRawRequest request = new HttpFormPostRawRequest(); request.Url = "https://api.weibo.com/oauth2/access_token"; string postDataFormat = "client_id={0}&client_secret={1}&grant_type=authorization_code&code={2}&redirect_uri=http://barefoot.3322.org/queryservice.svc/query"; string postData = string.Format(postDataFormat, oauthAPIEntity.AppKey, oauthAPIEntity.AppSecret, code); request.Data = postData; response = http.Post(request); m = Regex.Match(response.Response, "{\"access_token\":\"(?<token>[^\"]+)\","); string token = m.Groups["token"].Value; txtToken.Text = token; txtTokenSecret.Text = code; this.lblErrorMsg.Text = "授权成功"; oauthAPIEntity.Token = token; oauthAPIEntity.TokenSecret = code; oauthAPIEntity.Version = 2; Session["oauthAPIObj"] = oauthAPIEntity; } else { IOAuthAPI oauthAPI = OAuthAPIFactory.CreateOAuthAPI(); oauthAPI.RequestTokenUrl = oauthAPIEntity.RequestTokenUrl; oauthAPI.AuthorizeUrl = oauthAPIEntity.AuthorizeUrl; oauthAPI.AccessTokenUrl = oauthAPIEntity.AccessTokenUrl; if (oauthAPI.GetRequestToken(oauthAPIEntity.AppKey, oauthAPIEntity.AppSecret, Config.CallbackUrl)) { var authorizationUrl = oauthAPI.GetAuthorize(Config.CallbackUrl); Session["oauthAPI"] = oauthAPI; if (!string.IsNullOrEmpty(authorizationUrl)) { Response.Redirect(authorizationUrl); } } } }
public CachingHttpForm(IHttpForm innerHttpForm, float cacheDurationInMinutes) : base(innerHttpForm) { Check.Argument.IsNotNegativeOrZero(cacheDurationInMinutes, "cacheDurationInMinutes"); _cacheDurationInMinutes = cacheDurationInMinutes; }
public DecoratedHttpFormTestDouble(IHttpForm innerHttpForm) : base(innerHttpForm) { }
public HttpRequest() { http = HttpFormFactory.DefaultHttpForm(); }