public static int Main(string[] args) { /* * We expect command line arguments such as: * SmartFileTest.exe <method> <endpoint> [ <id> <name>=<value> ] */ if (args.Length < 3) { Console.WriteLine("You must provide an HTTP method and endpoint."); return 1; } String method = args[0]; String endpoint = args[1]; BasicClient api = new BasicClient(); /* SmartFileTest.exe POST path/data file0= */ if (method == "POST" && endpoint == "path/data") { Hashtable p = new Hashtable(); for (int i = 2; i < args.Length; i++) { String argPair = args[i]; String[] parts = argPair.Split('='); if (File.Exists(parts[1])) p.Add(parts[0], new FileInfo(parts[1])); else p.Add(parts[0], parts[1]); } HttpWebResponse r = api.Post("path/data", null, p); } return 0; }
public Form1() { InitializeComponent(); String HostName = Dns.GetHostName(); IPHostEntry ipEntry = Dns.GetHostByName(HostName); IPAddress[] addresses = ipEntry.AddressList; IPAddress addr = IPAddress.Parse("127.0.0.1"); foreach (IPAddress a in addresses){ if (a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { addr = a; break; } } Basic = new BasicClient(19999, 9587, addr); client = new TCPClient(Basic); serv = new TCPServer(Basic); //serv = new SelectServer(Managers.ROUTING_TYPE.onion, DateTime.Parse("00:00:05"), 19999, 1456, addr); udp_serv = new UDPServer(Basic, HostName, serv.getpublickey()); serv.Run(); //Запускаем TCP сервер обработки udp_serv.Run(); //Запускаем UDP сервер рассылки IP //MessageBox.Show("UDP Run"); //MessageBox.Show("Server Run"); serv.NewMessageEvent += new NewMessageDelegate(Handler); client.ScanHosts(1); //Поиск доступных хостов //MessageBox.Show("Scanhosts Run"); HostsToPictures(); //client.SendString("Приветик", new Workstation(serv.CurrentIP, serv.getpublickey())); //client.SendString("Ты тут?", new Workstation(serv.CurrentIP, serv.getpublickey())); }
/// <summary> /// Simple example of how to create a new store, insert some simple data in the Ntriples (link) format, and then query /// using SPARQL. /// </summary> public static void UsingBasicClientToInsertAndQueryData() { var bc = new BasicClient(); // create a store var storeUri = bc.CreateStore(new Uri("http://*****:*****@" # data in Ntriple format. <http://www.networkedplanet.com/people/bob> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . <http://www.networkedplanet.com/people/jill> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . <http://www.networkedplanet.com/people/john> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . "; // create a simple transaction that adds triples to the store var txn = new Transaction {TriplesToAdd = dataToInsert}; // post the transaction and wait for it to complete. The alternative is to fire and forget, or pass in a call back. // todo: these other options arent available yet. var jobUri = bc.PostTransaction(storeUri, txn); // query for data const string query = "select ?person where { ?people <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . }"; // execute sparql query and get SPARQL result XML. var result = bc.Query(storeUri, query); // Here we use a couple of XElement SPARQL result set specific extension methods, Rows and GetColumnValue //foreach (var resultRow in result.Rows) //{ // Console.WriteLine(resultRow.GetColumnValue("person")); //} }
// Use this for initialization void Start() { Debug.Log("Starting up AllJoyn service and client"); basicServer = new BasicServer(); basicClient = new BasicClient(); basicClient.Connect(); }
public ClientHandler(String key, String password) { this.key = key; this.password = password; client = new BasicClient(key, password); }
/// <summary>Snippet for AMethod</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void AMethodRequestObject() { // Create client BasicClient basicClient = BasicClient.Create(); // Initialize request argument(s) Request request = new Request { }; // Make the request Response response = basicClient.AMethod(request); }
public void CanGenerateAStandardTable() { var client = new BasicClient(new GeneratorSettings() { CharacterString = "abc", Size = 200 }, new ServiceSettings()); var result = client.GenerateTokenTable(); Assert.AreEqual(200, result.ForwardTable.Count); }
public dynamic execute(BasicClient client, string statement, Func<IEnumerable<dynamic>, IEnumerable<dynamic>> transform, Func<IEnumerable<dynamic>, IEnumerable<dynamic>> themeFunc = null, params Func<IEnumerable<dynamic>, IEnumerable<dynamic>>[] userDefinedFuncs) { dynamic retval = null; try { retval = client.runSqlDynamic(statement); } catch (Exception err) { // No op } return reportType.process(retval, transform, themeFunc, userDefinedFuncs); }
/// <summary>Snippet for AMethodAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task AMethodRequestObjectAsync() { // Create client BasicClient basicClient = await BasicClient.CreateAsync(); // Initialize request argument(s) Request request = new Request { }; // Make the request Response response = await basicClient.AMethodAsync(request); }
/// <summary>Snippet for AMethod</summary> public void AMethodRequestObject() { // Snippet: AMethod(Request, CallSettings) // Create client BasicClient basicClient = BasicClient.Create(); // Initialize request argument(s) Request request = new Request { }; // Make the request Response response = basicClient.AMethod(request); // End snippet }
public static int Main(string[] args) { /* * We expect command line arguments such as: * SmartFileTest.exe <method> <endpoint> [ <id> <name>=<value> ] */ String method; String endpoint; if (args.Length < 3) { Console.WriteLine("You must provide an HTTP method and endpoint."); Console.WriteLine("Method:"); method = Console.ReadLine(); Console.WriteLine("Endpoint:"); endpoint = Console.ReadLine(); } else { method = args[0]; endpoint = args[1]; } BasicClient api = new BasicClient(); if (method == "POST" && endpoint == "path/data") { Hashtable p = new Hashtable(); for (int i = 2; i < args.Length; i++) { String argPair = args[i]; String[] parts = argPair.Split('='); if (File.Exists(parts[1])) { p.Add(parts[0], new FileInfo(parts[1])); } else { p.Add(parts[0], parts[1]); } } HttpWebResponse r = api.Post("path/data", null, p); } return(0); }
/// <summary>Snippet for AMethodAsync</summary> public async Task AMethodRequestObjectAsync() { // Snippet: AMethodAsync(Request, CallSettings) // Additional: AMethodAsync(Request, CancellationToken) // Create client BasicClient basicClient = await BasicClient.CreateAsync(); // Initialize request argument(s) Request request = new Request { }; // Make the request Response response = await basicClient.AMethodAsync(request); // End snippet }
public void GetUsers_should_thow_UnauthorizedSecurityException() { // arrange NancyWebAppConfig.IdentityServerEnabled = true; var server = new TestServer(new WebHostBuilder().Configure(app => app.UseOwin().UseNancy())); var client = new BasicClient(server.CreateClient(), "client", "secret"); IEnumerable <User> result = null; this.Invoking((a) => { // act result = client.GetUsers().RunAsSynchronous(); }) // assert .ShouldThrow <SecurityException>(); }
public void GetBooksByUserShouldThowUnauthorizedSecurityException() { // arrange NancyWebAppConfig.IdentityServerEnabled = true; var server = new TestServer(new WebHostBuilder().UseStartup(typeof(Startup))); var client = new BasicClient(server.CreateClient(), "client", "secret"); IEnumerable <Book> result = null; this.Invoking((a) => { // act result = client.GetBooksByUser("alfredorevilla").RunAsSynchronous(); }) // assert .ShouldThrow <SecurityException>(); }
static void Main(string[] args) { BasicClient client = new BasicClient("http://insites-dev.intelligentinsites.com", "username", "password"); //Get the required parameters from user Console.Write("name <IV Pole>: "); string name = Console.ReadLine().Trim(); Console.Write("short-name <iv1>: "); string shortName = Console.ReadLine().Trim(); Console.Write("type <Bxc6t>: "); string type = Console.ReadLine().Trim(); Console.Write("status <Bxc>: "); string status = Console.ReadLine().Trim(); Console.Write("service-status <Bxc>: "); string serviceStatus = Console.ReadLine().Trim(); //Perform a POST request to create a resource ApiResponse createResponse = client.Post("/api/2.0/rest/equipment.xml", String.Format("name={0}&shortName={1}&type={2}&status={3}&service-status={4}", name, shortName, type, status, serviceStatus)); Console.WriteLine("\nThe web service responded with:"); Console.WriteLine(createResponse.ResponseData); //Parse the response to get the id of the new equipment String equipmentId = ParseEquipmentIdFromXMLResponse(createResponse); Console.WriteLine("Parsed the id from the response. The id is: " + equipmentId); //Assign a sensor to the equipment by using the take-sensor method. Sensor resources are identified by //two fields, a key (the 'provider' field), and a value (the 'label' field). Console.WriteLine("\nAssigning an existing sensor to our new equipment..."); Console.Write("sensor to assign <your-rtls.6025> "); //provider.label String sensorId = Console.ReadLine().Trim(); Dictionary<string, object> assignParams = new Dictionary<string, object>(); assignParams["sensor"] = sensorId; ApiResponse assignResponse = client.Post("/api/2.0/rest/equipment/"+equipmentId+"/take-sensor.xml", assignParams); Console.WriteLine("\nAssigned a sensor to the new equipment. The web service responded with:"); Console.WriteLine(assignResponse.ResponseData); Console.WriteLine("\nPress any key to quit"); Console.Read(); }
public void Authenticate_should_return_True() { // arrange NancyWebAppConfig.IdentityServerEnabled = true; var server = new TestServer(new WebHostBuilder().UseStartup(typeof(Startup))); var handler = server.CreateHandler(); var client = new BasicClient(handler, "https://server/connect/token", "client", "secret"); var authorized = false; this.Invoking((a) => { // act authorized = client.AuthenticateUserAsync("alfredorevilla", "password", "api1").RunAsSynchronous(); }) // assert .ShouldNotThrow(); authorized.Should().BeTrue(); }
public void GetBooksByUser_should_be_Ok() { // arrange NancyWebAppConfig.IdentityServerEnabled = false; var server = new TestServer(new WebHostBuilder().UseStartup(typeof(Startup))); var client = new BasicClient(server.CreateClient(), "client", "secret"); IEnumerable <Book> result = null; this.Invoking((a) => { // act result = client.GetBooksByUser("alfredorevilla").RunAsSynchronous(); }) // assert .ShouldNotThrow(); result.Should().NotBeNull(); result.Count().Should().BeGreaterThan(0); }
public void GetTokenUserId() { NancyWebAppConfig.IdentityServerEnabled = true; var server = new TestServer(new WebHostBuilder().UseStartup(typeof(Startup))); var handler = server.CreateHandler(); var client = new BasicClient(handler, "https://server/connect/token", "client", "secret"); string userId = null; this.Invoking((a) => { // act client.AuthenticateUserAsync("alfredorevilla", "password", "api1").RunAsSynchronous(); userId = client.GetTokenUserId(); }) // assert .ShouldNotThrow(); userId.Should().Be("F7D5AC0B-5C00-4253-8B54-046392260658"); }
static void Main() { Console.WriteLine("-- EchoServer/HelloClient --"); EchoServer.StartEchoServer(); HelloClient.Connect(); Task.Delay(50).Wait(); //Wait 50 milliseconds to let HelloClient finish Console.WriteLine("-- BasicServer/BasicClient --"); BasicServer.StartBasicServer(); BasicClient.Connect(); Task.Delay(50).Wait(); //Wait 50 milliseconds to let BasicClient finish Console.WriteLine("-- EasyTcpPacketExample --"); EasyTcpPacketExample.Start(); EasyTcpPacketExample.Connect(); Task.Delay(50).Wait(); //Wait 50 milliseconds to let EasyTcpPacketExample finish Console.WriteLine("-- EncryptionExample --"); EncryptionExample.Start(); EncryptionExample.Connect(); Task.Delay(50).Wait(); //Wait 50 milliseconds to let EncryptionExample finish Console.WriteLine("-- FileServer/FileClient --"); FileServer.StartFileServer(); FileClient.Download("TestFile.txt", "DownloadedTestFile.txt"); FileClient.Upload("TestFile.txt", "UploadedTestFile.txt"); Task.Delay(50).Wait(); //Wait 50 milliseconds to let FileClient finish Console.WriteLine("-- EchoServer/SpeedTestClient --"); SpeedTestClient.RunSpeedTest(); Console.WriteLine("-- ActionEchoServer/ActionSpeedTestClient --"); ActionEchoServer.StartEchoServer(); ActionSpeedTestClient.RunSpeedTest(); Task.Delay(-1).Wait(); }
public void GetTokenExpirationDate() { NancyWebAppConfig.IdentityServerEnabled = true; var server = new TestServer(new WebHostBuilder().UseStartup(typeof(Startup))); var handler = server.CreateHandler(); var client = new BasicClient(handler, "https://server/connect/token", "client", "secret"); DateTimeOffset expirationDate; this.Invoking((a) => { // act client.AuthenticateUserAsync("alfredorevilla", "password", "api1").RunAsSynchronous(); expirationDate = client.GetTokenExpirationDate(); }) // assert .ShouldNotThrow(); expirationDate.Should().BeAfter(DateTimeOffset.UtcNow); expirationDate.Should().BeBefore(DateTimeOffset.MaxValue); }
/// <summary> /// Simple example that uses the basic client to connect to a BrightStar server, list the stores present and then create a new store. /// Assumes the BrightStar server is running on its default port. /// </summary> public static void UsingBasicClientToListStoresAndCreateStore() { // a new brightstar basic client var bc = new BasicClient(); // list stores returns the URLs of each store. // todo: why isnt the hyperserver url in the BasicClient constructor? var stores = bc.ListStores(new Uri("http://localhost:8090/brightstar")); // iterate the store URLs foreach (var store in stores) { Console.WriteLine("store is " + store); } // create a new store with guarenteed unique name var newStoreUri = bc.CreateStore(new Uri("http://localhost:8090/brightstar"), "mystore" + Guid.NewGuid()); // get the data from the new store using the store uri. Note this will be empty. var storeData = bc.GetStoreData(newStoreUri); }
public virtual void Initialize() { Server = new BasicServer(); Client = new BasicClient(); string ip = Guid.NewGuid().ToString(); int port = Common.Port; Server.InitializeServer(GetContext(ip, port), new DirectServerProvider()); Client.InitializeClient(GetContext(ip, port), new DirectClientProvider()); Server.StartServer(); var sv = DirectServerProvider.Servers; Client.StartClient(); ServerService = Server.Context.Services.Get <TService>(); ClientService = Client.Context.Services.Get <TService>(); Assert.IsNotNull(ServerService); Assert.IsNotNull(ClientService); }
static void Main(string[] args) { BasicClient basic = new BasicClient("Christina", "Nastevska", "15/05/2016", 60); BusinessType1Client businessType1Client = new BusinessType1Client("Mark", "Markson", "14/05/2016", 70); BusinessType2Client businessType2Client = new BusinessType2Client("Homer", "Simpson", "15/05/2016", 80); FamilyClient famulyClient = new FamilyClient("Marge", "Simpson", "14/05/2016", 100, 5); PremiumClient premiumClient = new PremiumClient("Bart", "Simpson", "15/05/2016", 150); basic.displayInfo(); basic.set(new PromotionType1()); basic.promotions(); basic.services(); Console.Out.WriteLine("\n"); businessType1Client.displayInfo(); businessType1Client.services(); businessType1Client.promote(); Console.Out.WriteLine("\n"); premiumClient.displayInfo(); premiumClient.promote(); premiumClient.services(); Console.Out.WriteLine("\n"); famulyClient.displayInfo(); famulyClient.promote(); famulyClient.services(); Console.Out.WriteLine("\n"); businessType2Client.displayInfo(); businessType2Client.services(); businessType2Client.promote(); }
/// <summary> /// Simple example of how to create a new store, insert some simple data in the Ntriples (link) format, and then query /// using SPARQL. /// </summary> public static void UsingBasicClientToInsertAndQueryData() { var bc = new BasicClient(); // create a store var storeUri = bc.CreateStore(new Uri("http://*****:*****@" # data in Ntriple format. <http://www.networkedplanet.com/people/bob> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . <http://www.networkedplanet.com/people/jill> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . <http://www.networkedplanet.com/people/john> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . "; // create a simple transaction that adds triples to the store var txn = new Transaction { TriplesToAdd = dataToInsert }; // post the transaction and wait for it to complete. The alternative is to fire and forget, or pass in a call back. // todo: these other options arent available yet. var jobUri = bc.PostTransaction(storeUri, txn); // query for data const string query = "select ?person where { ?people <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . }"; // execute sparql query and get SPARQL result XML. var result = bc.Query(storeUri, query); // Here we use a couple of XElement SPARQL result set specific extension methods, Rows and GetColumnValue //foreach (var resultRow in result.Rows) //{ // Console.WriteLine(resultRow.GetColumnValue("person")); //} }
public string clouddownload(string fname) { string s; BasicClient api = new BasicClient("5FLkdaBJkVG7U1g168EmNneAuHBBjG", "o2I2xXnvWAq5xOeoY9T1sEMrNncyV5"); Hashtable p = new Hashtable(); p.Add("path", "role_base_access/" + fname); p.Add("list", true); p.Add("read", true); p.Add("name", "Screenshot"); try { r = api.Post("/link", null, p); } catch { } using (var streamReader = new StreamReader(r.GetResponseStream())) { var responseText = streamReader.ReadLine(); string lab1 = responseText.ToString(); string furl = lab1.Substring(137, 12).ToString(); // HyperLink1.NavigateUrl = "https://file.ac" + furl + "/MyFile/"+forder[0].ToString(); using (WebClient client = new WebClient()) { s = client.DownloadString("https://file.ac" + furl + "/role_base_access/" + fname); //cloudkeypackets.Add(hashvalue); } } return(s); }
public void cloud_upload(string path) { Environment.SetEnvironmentVariable("SMARTFILE_API_KEY", "5FLkdaBJkVG7U1g168EmNneAuHBBjG"); Environment.SetEnvironmentVariable("SMARTFILE_API_PASSWORD", "o2I2xXnvWAq5xOeoY9T1sEMrNncyV5"); Environment.SetEnvironmentVariable("SMARTFILE_API_URL", "https://nandhu.smartfile.com/"); string filepath = path; BasicClient api = new BasicClient(); FileInfo FI = new FileInfo(filepath);//to know the filepath & also the type Hashtable ht = new Hashtable(); HttpWebResponse HWR; try { ht.Add("file", FI); HWR = api.Post("path/data/role_base_access", null, ht);//path/data/doc is a format given by them } catch (Exception ex) { } }
int TimeLimit = 5000; //в миллисекундах #endregion Fields #region Constructors public TCPClient(BasicClient basic_client) { basic = basic_client; workstations = new List<Workstation>(); log = new Logging("Clientlog.acl"); }
static void Main(string[] args) { BasicClient client = new BasicClient("127.0.0.1", 8085); client.OnDisconnect += (sender, eventArgs) => Console.WriteLine("Disconnected"); client.OnTryConnect += (sender, eventArgs) => Console.WriteLine("Try connect..."); client.OnConnected += (sender, eventArgs) => Console.WriteLine("Connected"); client.OnReceive += (c, packet) => { if (packet.ContainsKey("username") && packet.ContainsKey("message")) { Console.WriteLine($"{packet["username"]} > {packet["message"]}"); } }; Console.Write("Username: "******"User: "******"username"] = username, ["message"] = msg }); } //client.OnReceive += (c, packet) => //{ // Console.WriteLine(c.Handler.RemoteEndPoint); // foreach (var kv in packet) // { // Console.WriteLine($"\t[{kv.Key}] = {kv.Value}"); // } //}; //client.Connect(); //BasicData data = new BasicData(); //while (true) //{ // string msg = Console.ReadLine(); // if (msg == "send") // { // client.Send(data); // data.Clear(); // } // else // { // string[] kv = msg.Split('='); // if (kv.Length != 2) // { // Console.WriteLine("ignored"); // continue; // } // data[kv[0].Trim()] = kv[1].Trim(); // } //} }
public UDPServer(BasicClient BasicClient, String StationName, String PublicKey) { basic = BasicClient; this.StationName = StationName; this.PublicKey = PublicKey; }
public SelectServer(BasicClient Basic_client) { basic = Basic_client; log = new Logging("Serverlog.acl"); RefreshRSAKey(); }
/// <summary> /// create basic client /// </summary> private Client() { basicClient = new BasicClient(); this.DataRecived = false; this.objc = new object(); }
public TCPServer(BasicClient basic_client) { basic = basic_client; log = new Logging("Serverlog.acl"); RefreshRSAKey(); }
// Use this for initialization void Start() { Debug.Log("Starting up AllJoyn client"); basicClient = new BasicClient(); }