public void TestHttpconnection() { string url = "http://m.vk.com/"; HttpWebResponseEx answer = HttpConnector.SendHttpWebRequestAndGetResponse(url, HttpMethod.GET); Assert.IsTrue(answer.HttpWebResponse.StatusCode == HttpStatusCode.OK); }
public override bool Validate() { if (UserSession == null) { ResultBean.Result = Define.LOGIN_ERROR; return(false); } if (String.IsNullOrEmpty(model.HouseholdIdx) || String.IsNullOrEmpty(model.HouseholdPdt)) { ResultBean.Result = Define.RESULT_NG; ResultBean.Error = Message.DATA_EROR; return(false); } String json = HttpConnector.GetInstance().GetDataRequest("GetHousehold.php", new Dictionary <String, Object>() { { "GID", UserSession.Id }, { "IDX", model.HouseholdIdx } }); HouseHold household = JsonConvert.DeserializeObject <HouseHold>(json); if (household == null || !String.Equals(household.Createdate.ToString(Define.PDT_FORMAT), model.HouseholdPdt)) { ResultBean.Result = Define.RESULT_NG; ResultBean.Error = Message.DATA_CHECK; return(false); } return(true); }
public static IHttpConnector GetRateConnector() { IHttpConnector connector = new HttpConnector(); connector.SetAddress("http://localhost:50820/api/rate"); return(connector); }
public static IHttpConnector GetChargeConnector() { IHttpConnector connector = new HttpConnector(); connector.SetAddress("http://localhost:59761/api/charge"); return(connector); }
public static IHttpConnector GetClientConnector() { IHttpConnector connector = new HttpConnector(); connector.SetAddress("http://localhost:51095/api/client"); return(connector); }
private static void VerifyConnectorsConfiguration(Config config) { HttpConnector httpConnector = FindConnector(config, HttpConnector.Encryption.NONE); HttpConnector httpsConnector = FindConnector(config, HttpConnector.Encryption.TLS); if (httpConnector == null && httpsConnector == null) { throw new System.ArgumentException("Either HTTP or HTTPS connector must be configured to run the server"); } }
public override ActionResult Run() { HttpConnector.GetInstance().GetDataRequest("DeleteHousehold.php", new Dictionary <String, Object>() { { "IDX", model.HouseholdIdx }, { "GID", UserSession.Id } }); ResultBean.Result = Define.RESULT_OK; return(Json(ResultBean, JsonRequestBehavior.AllowGet)); }
internal CommonRequest Create(Employee4AccessVM model) { var url = $"{this._apiUrl}/Employees/Create"; var json = HttpConnector.Post(url, JsonConvert.SerializeObject(model), Encoding.UTF8); if (json.State == StateEnum.Timeout) { return(json); } return(JsonConvert.DeserializeObject <CommonRequest>(json.Message)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldBeAbleToOverrideHttpsListenAddressWithJustOneParameter() internal virtual void ShouldBeAbleToOverrideHttpsListenAddressWithJustOneParameter() { // given Config config = Config.defaults(stringMap("dbms.connector.https.enabled", "true", "dbms.connector.https.listen_address", ":8000")); // then assertEquals(1, config.EnabledHttpConnectors().Count); HttpConnector httpConnector = config.EnabledHttpConnectors()[0]; assertEquals(new ListenSocketAddress("127.0.0.1", 8000), config.Get(httpConnector.ListenAddress)); }
internal CommonRequest Delete(int id) { var url = $"{this._apiUrl}/Employees/Delete/{id}"; var json = HttpConnector.Post(url, "", Encoding.UTF8); if (json.State == StateEnum.Success) { return(JsonConvert.DeserializeObject <CommonRequest>(json.Message)); } return(json); }
/// <summary> /// Dodaje checkboxy dla obsługi wyboru ról /// </summary> public UserEditForm() { InitializeComponent(); foreach (string roleName in HttpConnector.GetInstance().GetRoles()) { CheckBox checkBox = new CheckBox { Name = roleName, Text = GetRoleName(roleName), AutoSize = true }; _roleCheckBoxes.Add(checkBox); flowLayoutPanel.Controls.Add(checkBox); } }
public async void IsRaspberryAvailable_Async_Test() { string factualIP = await HttpConnector.RaspberryIPAdderssAsync(); if (HttpConnector.IsRaspberryAvailable) { Assert.True(new Ping().Send(factualIP).Status == IPStatus.Success); } else { Assert.Equal(string.Empty, factualIP); } }
internal CommonRequest Find(int id) { var url = $"{this._apiUrl}/Employees/Find?id={id}"; var json = HttpConnector.Get(url); if (json.State == StateEnum.Success) { return(JsonConvert.DeserializeObject <CommonRequest>(json.Message)); } else { return(json); } }
public string SignIn(string login, string password) { HttpConnector httpConnector = HttpConnector.GetInstance(); _tokenData = httpConnector.GetToken(login, password); string errorMessage = httpConnector.LastErrorMessage; if (errorMessage == null) { httpConnector.SetCredentials(_tokenData); _userRoles = httpConnector.GetCurrentRoles(); errorMessage = httpConnector.LastErrorMessage; } return(errorMessage); }
public override ActionResult Run() { String date = String.Format("{0}-{1}-{2}", model.HouseholdYear, model.HouseholdMonth, model.HouseholdDay); String json = HttpConnector.GetInstance().GetDataRequest("AddHousehold.php", new Dictionary <String, Object>() { { "GID", UserSession.Id }, { "CD", model.HouseholdCategory }, { "TP", model.HouseholdType }, { "DT", date }, { "CNTXT", model.HouseholdContent }, { "PRC", model.Householdprice } }); ResultBean.Result = Define.RESULT_OK; return(Json(ResultBean, JsonRequestBehavior.AllowGet)); }
public new ActionResult Redirect(String code) { try { base.Logger.Info("Redirect Open"); string data = HttpConnector.GetInstance().GetRequest("https://accounts.google.com/o/oauth2/token", HttpConnector.HttpMethod.POST, new Dictionary <String, Object>() { { "code", code }, { "client_id", HtmlUtil.GetClientID() }, { "client_secret", HtmlUtil.GetClientSecret() }, { "redirect_uri", HtmlUtil.GetRedirectUrl() }, { "grant_type", "authorization_code" } }); base.Logger.Info("Google account auth : " + code); LoginToken token = JsonConvert.DeserializeObject <LoginToken>(data); data = HttpConnector.GetInstance().GetRequest("https://www.googleapis.com/oauth2/v1/userinfo", HttpConnector.HttpMethod.GET, new Dictionary <String, Object>() { { "access_token", token.Access_token } }); base.Logger.Info("Google access_token : " + token.Access_token); LoginBean login = JsonConvert.DeserializeObject <LoginBean>(data); login.Token = token; String usercheck = HttpConnector.GetInstance().GetDataRequest("CheckUser.php", new Dictionary <String, Object>() { { "GID", login.Id } }); Session["USER_BUFFER"] = login; if (usercheck == null) { base.Logger.Info("usercheck == null"); return(base.Redirect("/Home/ApplyConfirm")); } base.Logger.Info("Redirect -> Apply"); return(Apply()); } catch (Exception e) { base.Logger.Error(e); return(base.Redirect("/")); } }
public override async Task Execute(Message message, TelegramBotClient botClient) { var chatId = message.Chat.Id; if (Startup.myAppSettings.LogIsEnabled) { Log.Write(@"Get Chat Id for response message: " + chatId); } var myMessage = "Here is my data: \n\n"; myMessage += "//=======\n"; myMessage += "//-------\n"; var messageForLogs = "Here is my data: "; myMessage += "BaseDir: " + SentinelMethods.GetBaseDir() + "\n"; myMessage += "//-------\n"; messageForLogs += "BaseDir: " + SentinelMethods.GetBaseDir() + " | "; myMessage += "Base EMS Url: " + SentinelMethods.UrlBuilder() + "\n"; myMessage += "//-------\n"; messageForLogs += "Base EMS Url: " + SentinelMethods.UrlBuilder() + " | "; myMessage += "Url for Login by PK: " + SentinelMethods.UrlBuilder(SentinelSettings.actionsList["loginpk"]) + "\n"; myMessage += "//-------\n"; messageForLogs += "Url for Login by PK: " + SentinelMethods.UrlBuilder(SentinelSettings.actionsList["loginpk"]) + " | "; myMessage += "Url for Get Info by PK: " + SentinelMethods.UrlBuilder(SentinelSettings.actionsList["getinfo"], SentinelSettings.testProductKey) + "\n"; messageForLogs += "Url for Get Info by PK: " + SentinelMethods.UrlBuilder(SentinelSettings.actionsList["getinfo"], SentinelSettings.testProductKey); myMessage += "//-------\n"; var myAuthData = SentinelSettings.authXmlString; myAuthData = myAuthData.Replace("{PLACEHOLDER_LOGIN}", SentinelSettings.vendorLogin).Replace("{PLACEHOLDER_PASSWORD}", SentinelSettings.vendorPassword); myHttpConnector = myHttpConnector.GetRequest("login", HttpMethod.Post, null, new KeyValuePair <string, string>("authenticationDetail", myAuthData)); // TODO vendor login XDocument response = XDocument.Parse(myHttpConnector.httpClientResponseStr); myMessage += "Test Login by Vendor - auth response: \n" + response.ToString() + "\n"; myMessage += "//-------\n"; myHttpConnector = myHttpConnector.GetRequest("logout", HttpMethod.Post, null, new KeyValuePair <string, string>("", ""), myHttpConnector); // TODO vendor logout myMessage += "Test Logout status: \n" + myHttpConnector.httpClientResponseStatus.ToString() + " (If \"204\" or \"NoContent\" - this is mean all correct!)\n"; myMessage += "//-------\n"; myMessage += "//=======\n"; if (Startup.myAppSettings.LogIsEnabled) { Log.Write(@"Try to send response message - " + messageForLogs); } await botClient.SendTextMessageAsync(chatId, myMessage, parseMode : Telegram.Bot.Types.Enums.ParseMode.Markdown); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SavePassword(object sender, FormClosingEventArgs e) { if (!_passwordForm.CloseWithoutSaving && !e.Cancel) { HttpConnector httpConnector = HttpConnector.GetInstance(); string password = _passwordForm.GetPassword(); httpConnector.ChangePassword(password); string errorMessage = httpConnector.LastErrorMessage; if (errorMessage != null) { MessageBox.Show("Zmiana hasła się nie powiodła. Hasło musi mieć co najmniej 6 liter, zawierać jedną cyfrę, jeden znak specjalny i jedną wielką literę.", "Niepowodzenie zmiany hasła"); e.Cancel = true; return; } } _passwordForm.Reset(); }
internal EmployeeCollection Read() { var url = $"{this._apiUrl}/Employees/Read"; var json = HttpConnector.Get(url); if (json.State == StateEnum.Success) { return(JsonConvert.DeserializeObject <EmployeeCollection>(json.Message)); } var error = new EmployeeCollection() { State = StateEnum.Fail, Message = json.Message, }; return(error); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); HttpConnector.CreateInstance(HtmlUtil.GetConfig("serviceUrl")); HtmlUtil.Initialize(HtmlUtil.GetConfig("clientID"), HtmlUtil.GetConfig("clientSecret"), HtmlUtil.GetConfig("redirectUrl")); FactoryMaster.CreateInstance(); XmlConfigurator.Configure(); ILog logger = LogManager.GetLogger("ApplicationStart"); logger.Info("Started up this program."); }
private FactoryMaster() { try { logger = LogManager.GetLogger(this.GetType()); String json = HttpConnector.GetInstance().GetDataRequest("GetMaster.php", new Dictionary <String, Object>() { { "a", 0 } }); Dictionary <String, Object> map = JsonConvert.DeserializeObject <Dictionary <String, Object> >(json); typemaster = JsonConvert.DeserializeObject <TypeMaster>(map["TP"].ToString()); categorymaster = JsonConvert.DeserializeObject <CategoryMaster>(map["CATEGORY"].ToString()); systemdatamaster = JsonConvert.DeserializeObject <SystemDataMaster>(map["SYSTEMDATA"].ToString()); } catch (Exception e) { logger.Error(e); logger.Error("The master is not loaded."); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAllowCustomServerAndDbConfig() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAllowCustomServerAndDbConfig() { // Given TrustAllSSLCerts(); // Get default trusted cypher suites SSLServerSocketFactory ssf = ( SSLServerSocketFactory )SSLServerSocketFactory.Default; string[] defaultCiphers = ssf.DefaultCipherSuites; // When HttpConnector httpConnector = new HttpConnector("0", HttpConnector.Encryption.NONE); HttpConnector httpsConnector = new HttpConnector("1", HttpConnector.Encryption.TLS); using (ServerControls server = GetTestServerBuilder(TestDir.directory()).withConfig(httpConnector.Type, "HTTP").withConfig(httpConnector.Enabled, "true").withConfig(httpConnector.Encryption, "NONE").withConfig(httpConnector.ListenAddress, "localhost:0").withConfig(httpsConnector.Type, "HTTP").withConfig(httpsConnector.Enabled, "true").withConfig(httpsConnector.Encryption, "TLS").withConfig(httpsConnector.ListenAddress, "localhost:0").withConfig(GraphDatabaseSettings.dense_node_threshold, "20").withConfig("https.ssl_policy", "test").withConfig("dbms.ssl.policy.test.base_directory", TestDir.directory("certificates").AbsolutePath).withConfig("dbms.ssl.policy.test.allow_key_generation", "true").withConfig("dbms.ssl.policy.test.ciphers", string.join(",", defaultCiphers)).withConfig("dbms.ssl.policy.test.tls_versions", "TLSv1.2, TLSv1.1, TLSv1").withConfig("dbms.ssl.policy.test.client_auth", ClientAuth.NONE.name()).withConfig("dbms.ssl.policy.test.trust_all", "true").newServer()) { // Then assertThat(HTTP.GET(server.HttpURI().ToString()).status(), equalTo(200)); assertThat(HTTP.GET(server.HttpsURI().get().ToString()).status(), equalTo(200)); AssertDBConfig(server, "20", GraphDatabaseSettings.dense_node_threshold.name()); } }
/// <summary> /// /// </summary> /// <param name="updateInfo"></param> private void GetUpdateInfo(VersionInfo updateInfo) { HttpConnector httpConnector = new HttpConnector(); var versionList = httpConnector.GetVersionList(updateInfo); foreach (var version in versionList.List) { } /* * static class Program * { * static void Main() * { * string v1 = "1.23.56.1487"; * string v2 = "1.24.55.487"; * * var version1 = new Version(v1); * var version2 = new Version(v2); * * var result = version1.CompareTo(version2); * if (result > 0) * Console.WriteLine("version1 is greater"); * else if (result < 0) * Console.WriteLine("version2 is greater"); * else * Console.WriteLine("versions are equal"); * return; * * } * } * */ //TODO read all version in list when version is same as local download nextversion in the list // then do this un till the end of the list }
public AbstractNeoServer(Config config, GraphFactory graphFactory, Dependencies dependencies) { this._config = config; this.UserLogProvider = dependencies.UserLogProvider(); this._log = UserLogProvider.getLog(this.GetType()); _log.info(Neo4jIsStartingMessage); VerifyConnectorsConfiguration(config); _httpConnector = FindConnector(config, HttpConnector.Encryption.NONE); _httpListenAddress = ListenAddressFor(config, _httpConnector); _httpAdvertisedAddress = AdvertisedAddressFor(config, _httpConnector); _httpsConnector = FindConnector(config, HttpConnector.Encryption.TLS); _httpsListenAddress = ListenAddressFor(config, _httpsConnector); _httpsAdvertisedAddress = AdvertisedAddressFor(config, _httpsConnector); DatabaseConflict = new LifecycleManagingDatabase(config, graphFactory, dependencies); this._availabilityGuardSupplier = (( LifecycleManagingDatabase )DatabaseConflict).getAvailabilityGuard; _life.add(DatabaseConflict); _life.add(new ServerDependenciesLifeCycleAdapter(this)); _life.add(new ServerComponentsLifecycleAdapter(this)); }
public ActionResult Apply() { try { base.Logger.Info("Apply Open"); LoginBean login = Session["USER_BUFFER"] as LoginBean; Session["USER_BUFFER"] = null; HttpConnector.GetInstance().GetDataRequest("ApplyUser.php", new Dictionary <String, Object>() { { "GID", login.Id }, { "NAME", login.Name }, { "EMAIL", "" } }); UserSession = login; FormsAuthentication.SetAuthCookie(login.Id, false); return(base.Redirect("/Home/Main")); } catch (Exception e) { base.Logger.Error(e); return(base.Redirect("/")); } }
public void SetUp() { _handlerMock = new Mock <HttpMessageHandler>(); _handlerMock .Protected() .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>() ) .ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(new SnapshotData())), }) .Verifiable(); _httpClient = new HttpClient(_handlerMock.Object) { BaseAddress = new Uri($"http://{nameof(HttpClientConnectorTest)}.com/"), }; _objectToTest = new HttpConnector <SnapshotData>(_httpClient, new Mock <ILog>().Object); }
private void Init(File workingDir) { Directory = workingDir; withConfig(auth_enabled, "false"); withConfig(pagecache_memory, "8m"); BoltConnector bolt0 = new BoltConnector("bolt"); HttpConnector http1 = new HttpConnector("http", HttpConnector.Encryption.NONE); HttpConnector http2 = new HttpConnector("https", HttpConnector.Encryption.TLS); WithConfig(http1.Type, "HTTP"); withConfig(http1.Encryption, HttpConnector.Encryption.NONE.name()); WithConfig(http1.Enabled, "true"); WithConfig(http1.Address, "localhost:0"); WithConfig(http2.Type, "HTTP"); withConfig(http2.Encryption, HttpConnector.Encryption.TLS.name()); WithConfig(http2.Enabled, "false"); WithConfig(http2.Address, "localhost:0"); WithConfig(bolt0.Type, "BOLT"); WithConfig(bolt0.Enabled, "true"); WithConfig(bolt0.Address, "localhost:0"); }
public virtual IDictionary <string, string> CreateConfiguration(File temporaryFolder) { IDictionary <string, string> properties = stringMap(ServerSettings.management_api_path.name(), _managementUri, ServerSettings.rest_api_path.name(), _restUri); ServerTestUtils.addDefaultRelativeProperties(properties, temporaryFolder); if (!string.ReferenceEquals(_dataDir, null)) { properties[GraphDatabaseSettings.data_directory.name()] = _dataDir; } if (!string.ReferenceEquals(_maxThreads, null)) { properties[ServerSettings.webserver_max_threads.name()] = _maxThreads; } if (_thirdPartyPackages.Keys.Count > 0) { properties[ServerSettings.third_party_packages.name()] = asOneLine(_thirdPartyPackages); } if (_autoIndexedNodeKeys != null && _autoIndexedNodeKeys.Length > 0) { properties["dbms.auto_index.nodes.enabled"] = "true"; string propertyKeys = org.apache.commons.lang.StringUtils.join(_autoIndexedNodeKeys, ","); properties["dbms.auto_index.nodes.keys"] = propertyKeys; } if (_autoIndexedRelationshipKeys != null && _autoIndexedRelationshipKeys.Length > 0) { properties["dbms.auto_index.relationships.enabled"] = "true"; string propertyKeys = org.apache.commons.lang.StringUtils.join(_autoIndexedRelationshipKeys, ","); properties["dbms.auto_index.relationships.keys"] = propertyKeys; } if (_securityRuleClassNames != null && _securityRuleClassNames.Length > 0) { string propertyKeys = org.apache.commons.lang.StringUtils.join(_securityRuleClassNames, ","); properties[ServerSettings.security_rules.name()] = propertyKeys; } HttpConnector httpConnector = new HttpConnector("http", HttpConnector.Encryption.NONE); HttpConnector httpsConnector = new HttpConnector("https", HttpConnector.Encryption.TLS); properties[httpConnector.Type.name()] = "HTTP"; properties[httpConnector.Enabled.name()] = _httpEnabled.ToString(); properties[httpConnector.Address.name()] = _address.ToString(); properties[httpConnector.Encryption.name()] = "NONE"; properties[httpsConnector.Type.name()] = "HTTP"; properties[httpsConnector.Enabled.name()] = _httpsEnabled.ToString(); properties[httpsConnector.Address.name()] = _httpsAddress.ToString(); properties[httpsConnector.Encryption.name()] = "TLS"; properties[GraphDatabaseSettings.auth_enabled.name()] = "false"; properties[LegacySslPolicyConfig.certificates_directory.name()] = (new File(temporaryFolder, "certificates")).AbsolutePath; properties[GraphDatabaseSettings.logs_directory.name()] = (new File(temporaryFolder, "logs")).AbsolutePath; properties[GraphDatabaseSettings.logical_logs_location.name()] = (new File(temporaryFolder, "transaction-logs")).AbsolutePath; properties[GraphDatabaseSettings.pagecache_memory.name()] = "8m"; properties[GraphDatabaseSettings.shutdown_transaction_end_timeout.name()] = "0s"; foreach (object key in _arbitraryProperties.Keys) { properties[key.ToString()] = _arbitraryProperties.get(key).ToString(); } return(properties); }
private void StartLoading() { Configuration.Instance.Deserilized = false; //Configuration.Instance.Initialized = false; #if DEBUG if (DebugMode) { Debug.Log("ConfigLoader: loading configuration."); } #endif if (AsyncMode) { var url = UnityEngine.Application.isEditor ? EditorConfigUrl : ConfigUrl; #if DEBUG if (DebugMode) { Debug.Log(string.Format("ConfigLoader: loading in Async mode [{0}]", url)); } #endif _connector = new HttpConnector { Url = url, CacheBuster = CacheBuster, FaultHandler = OnAsyncFault, ResponseMode = ResponseMode.WWW, Timeout = 30, //LogCalls = true }; _connector.Send(new Responder(OnAsyncResult)); } else { #if DEBUG if (DebugMode) { Debug.Log(string.Format("ConfigLoader: loading from Resources [{0}]", ConfigPath)); } #endif _config = Resources.Load(ConfigPath); if (null == _config) { string msg = string.Format(ConfigurationException.LoadingError); #if DEBUG if (DebugMode) { Debug.Log(msg); } #endif //Alert.Show(msg, "Configuration error"); if (null != ResultHandler) { ResultHandler(msg); } } else { Configuration.Instance.ProcessConfig(_config.ToString()); if (null != ResultHandler) { ResultHandler(Configuration.Instance.Application); } } } }
private static AdvertisedSocketAddress AdvertisedAddressFor(Config config, HttpConnector connector) { return(connector == null ? null : config.Get(connector.AdvertisedAddress)); }