public void SetupServer()
 {
     Log.LogManager.Level = Log.LogLevel.Fatal;
     _config = new CoapConfig();
     _server = new CoapServer();
     CoAPEndPoint endpoint = new CoAPEndPoint(_serverPort, _config);
     _server.AddEndPoint(endpoint);
     _server.Add(new TestResource(TARGET));
     _server.Start();
 }
示例#2
0
 public void SetupServer()
 {
     Log.LogManager.Level = Log.LogLevel.Fatal;
     CoAPEndPoint endpoint = new CoAPEndPoint();
     _server = new CoapServer();
     _server.Add(new AccResource());
     _server.Add(new NoAccResource());
     _server.AddEndPoint(endpoint);
     _server.Start();
     _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port;
 }
示例#3
0
        private void CreateServer()
        {
            _server = new CoapServer();

            TcpEndPoint endpoint = new TcpEndPoint();

            _server.AddEndPoint(endpoint);

            _server.Add(new HelloWorldResource("hello"));

            _server.Start();

            _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port;
        }
示例#4
0
        public static void Main(String[] args)
        {
            KeySet keys = new KeySet();

            OneKey key = new OneKey();

            key.Add(CoseKeyKeys.KeyType, COSE.GeneralValues.KeyType_Octet);
            key.Add(CoseKeyKeys.KeyIdentifier, CBORObject.FromObject(Encoding.UTF8.GetBytes("password")));
            key.Add(CoseKeyParameterKeys.Octet_k, CBORObject.FromObject(Encoding.UTF8.GetBytes("sesame")));
            keys.AddKey(key);


            CoapServer server = new CoapServer();

            // server.AddEndPoint(new TcpEndPoint(5683));
            server.AddEndPoint(new DTLSEndPoint(null, keys, 5684));

            server.Add(new HelloWorldResource("hello"));
            server.Add(new FibonacciResource("fibonacci"));
            server.Add(new StorageResource("storage"));
            server.Add(new ImageResource("image"));
            server.Add(new MirrorResource("mirror"));
            server.Add(new LargeResource("large"));
            server.Add(new CarelessResource("careless"));
            server.Add(new SeparateResource("separate"));
            server.Add(new TimeResource("time"));

            try
            {
                server.Start();

                Console.Write("CoAP server [{0}] is listening on", server.Config.Version);

                foreach (var item in server.EndPoints)
                {
                    Console.Write(" ");
                    Console.Write(item.LocalEndPoint);
                }
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
            server.Stop();
        }
示例#5
0
        private void CreateServer()
        {
            TlsKeyPairSet allKeys = new TlsKeyPairSet();
            allKeys.AddKey(X509Key);
            TLSEndPoint endpoint = new TLSEndPoint(allKeys, new KeySet(), 0);
            endpoint.TlsEventHandler += ServerTlsEvents;

            _resource = new TlsX509.HelloResource("Hello1");
            _server = new CoapServer();
            _server.Add(_resource);

            _server.AddEndPoint(endpoint);
            _server.Start();
            _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port;
        }
        private void CreateServer()
        {
            _config = new CoapConfig {
                NonTimeout = 10             // 10 ms
            };

            _resource  = new ObserveTests2.ObserveResource(target1);
            _resource2 = new ObserveTests2.ObserveResource(target2);
            _server    = new CoapServer(_config);
            _server.Add(_resource);
            _server.Add(_resource2);
            IEndPoint endpoint = Pump.AddEndPoint("server #1", MockMessagePump.ServerAddress, _config, new Type[] { typeof(ObserveLayer), typeof(TokenLayer), typeof(ReliabilityLayer) });

            _server.AddEndPoint(endpoint);
            _server.Start();
        }
示例#7
0
        private void CreateServer()
        {
            CoAPEndPoint endpoint = new CoAPEndPoint(0);

            _resource = new TestResource(NAME_1, PAYLOAD);
            _server   = new CoapServer();
            _server
            .Add(new Resource(RES_A)
                 .Add(new Resource(RES_AA)
                      .Add(_resource
                           .Add(new TestResource(CHILD, CHILD_PAYLOAD)))));

            _server.AddEndPoint(endpoint);
            _server.Start();
            _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port;
        }
        private void CreateServer()
        {
            _config            = new CoapConfig();
            _config.NonTimeout = 10; // 10 ms

            CoAPEndPoint endpoint = new CoAPEndPoint(0, _config);

            _resource  = new ObserveResource(target1);
            _resource2 = new ObserveResource(target2);
            _server    = new CoapServer(_config);
            _server.Add(_resource);
            _server.Add(_resource2);

            _server.AddEndPoint(endpoint);
            _server.Start();
            _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port;
        }
示例#9
0
        private void CreateServer()
        {
            CoAPEndPoint endpoint = new CoAPEndPoint(0);

            _resource = new StorageResource(TARGET, CONTENT_1);
            _server   = new CoapServer();
            _server.Add(_resource);

            _server.AddEndPoint(endpoint);
            _server.Start();
            _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port;

            Resource r2 = new EchoLocation("abc");

            _server.Add(r2);

            r2.Add(new EchoLocation("def"));
        }
示例#10
0
        public static void Main(String[] args)
        {
            string ipadress = args[0];
            string port     = args[1];
            int    portInt  = Int32.Parse(port);

            // System.Net.EndPoint endpoint= System.Net.EndPoint  (ipadress, portInt);

            //System.Net.EndPoint endPoint = System.Net.IPAddress.Parse(ipadress);
            System.Net.IPAddress ip     = System.Net.IPAddress.Parse(ipadress);
            CoapServer           server = new CoapServer();

            server.AddEndPoint(ip, portInt);

            server.Add(new HelloWorldResource("hello"));
            server.Add(new FibonacciResource("fibonacci"));
            server.Add(new StorageResource("Devices"));
            server.Add(new ImageResource("image"));
            server.Add(new MirrorResource("mirror"));
            server.Add(new LargeResource("large"));
            server.Add(new CarelessResource("careless"));
            server.Add(new SeparateResource("separate"));
            server.Add(new TimeResource("time"));

            try
            {
                server.Start();
                Console.Write("CoAP server [{0}] is listening on", server.Config.Version);

                foreach (var item in server.EndPoints)
                {
                    Console.Write(" ");
                    Console.Write(item.LocalEndPoint);
                }
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
示例#11
0
        private void CreateServer()
        {
            CoAPEndPoint endpoint = new CoAPEndPoint(0);


            KeySet ks = new KeySet();

            ks.AddKey(psk);
            ks.AddKey(_clientSignKey.PublicKey());

            _resource = new EdhocResource(ks, serverSignKey);
            _server   = new CoapServer();
            _server.Add(_resource);

            _server.Add(new Hello("hello"));

            _server.AddEndPoint(endpoint);
            _server.Start();
            _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port;
        }
示例#12
0
        static void Main(string[] args)
        {
            CoapConfig _config = new CoapConfig();

            _config.DefaultBlockSize = 32;
            _config.MaxMessageSize   = 32;

            CoapServer   server   = new CoapServer(_config);
            CoAPEndPoint endpoint = new CoAPEndPoint(CoapConstants.DefaultPort, _config);

            server.AddEndPoint(endpoint);

            server.Add(new Temp("/sensors/temp"));
            server.Add(new Humidity("/sensors/humidity"));
            server.Add(new Vcc3("/sensors/vcc3"));
            server.Add(new Storage("/data/buffer"));
            server.Add(new Light("/sensors/light"));
            server.Add(new Hops("/info/hops"));

            try
            {
                server.Start();

                Console.Write("CoAP server [{0}] is listening on", server.Config.Version);

                foreach (var item in server.EndPoints)
                {
                    Console.Write(" ");
                    Console.Write(item.LocalEndPoint);
                }
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
示例#13
0
        public Client(int port)
        {
            _MessageDeliverer            = _CoapServer.MessageDeliverer;
            _CoapServer.MessageDeliverer = this;
            //_EndPoint = new CoAPEndPoint(port, CoapConfig.Default);

            //_EndPoint = new CoAPEndPoint(new FlowClientSecureChannel(port), CoapConfig.Default);
            //_EndPoint = new CoAPEndPoint(new FlowChannel(port), CoapConfig.Default);

            _Channel = new FlowClientChannel(port);

            UseCertificateFile("Client.pem");

            _EndPoint = new CoAPEndPoint(_Channel, CoapConfig.Default);
            _CoapServer.AddEndPoint(_EndPoint);
            _CoapServer.Add(_SecurityResources);
            _CoapServer.Add(_ServerResources);
            _CoapServer.Add(_BootsrapComplete);
            _Root           = _BootsrapComplete.Parent;
            _Timer.Interval = 30000;
            _Timer.Elapsed += new System.Timers.ElapsedEventHandler(_Timer_Elapsed);
        }
示例#14
0
        private void CreateServer()
        {
            CoapConfig config = new CoapConfig();

            CoAPEndPoint endpoint = new CoAPEndPoint(0, config);

            _resource = new MulticastResource(MulticastTarget, MulticastResponse);
            _server   = new CoapServer();
            _server.Add(_resource);

            _server.AddEndPoint(endpoint);
            _server.Start();
            _serverPort = ((IPEndPoint)endpoint.LocalEndPoint).Port;

            endpoint.AddMulticastAddress(new IPEndPoint(multicastAddress3, _serverPort));
            endpoint.AddMulticastAddress(new IPEndPoint(multicastAddress4, _serverPort));
            endpoint.AddMulticastAddress(new IPEndPoint(multicastAddress, _serverPort + PortJump));
            endpoint.AddMulticastAddress(new IPEndPoint(multicastAddress2, _serverPort + PortJump));

            Resource r2 = new UnicastResource(UnicastTarget, UnicastResponse);

            _server.Add(r2);
        }
示例#15
0
        private void CreateServer()
        {
            CoAPEndPoint endpoint = new CoAPEndPoint(0);

            _server = new CoapServer();

            //            _resource = new StorageResource(TARGET, CONTENT_1);
            //           _server.Add(_resource);

            Resource r2 = new EchoLocation("abc");

            _server.Add(r2);

            r2.Add(new EchoLocation("def"));

            _server.AddEndPoint(endpoint);
            _server.Start();
            _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port;

            SecurityContextSet oscoapContexts = new SecurityContextSet();

            SecurityContextSet.AllContexts.Add(SecurityContext.DeriveContext(_Secret, null, _ServerId, _ClientId));
        }
示例#16
0
        public void SetupServer()
        {
            Log.LogManager.Level = Log.LogLevel.Fatal;
            CoapConfig config = new CoapConfig();

            config.Deduplicator         = "MarkAndSweep";
            config.MarkAndSweepInterval = TEST_SWEEP_DEDUPLICATOR_INTERVAL;
            config.ExchangeLifetime     = TEST_EXCHANGE_LIFETIME;
            config.MaxMessageSize       = TEST_BLOCK_SIZE;
            config.DefaultBlockSize     = TEST_BLOCK_SIZE;

            // Create the endpoint for the server and create surveillant
            _serverEndpoint    = new CoAPEndPoint(config);
            _serverSurveillant = new EndpointSurveillant("server", _serverEndpoint);
            _clientEndpoint    = new CoAPEndPoint(config);
            _clientEndpoint.Start();
            _clientSurveillant = new EndpointSurveillant("client", _clientEndpoint);

            // Create a server with two resources: one that sends piggy-backed
            // responses and one that sends separate responses

            _server = new CoapServer(config);
            _server.AddEndPoint(_serverEndpoint);
            TestResource piggyRes    = new TestResource(PIGGY, Mode.PiggyBacked);
            TestResource separateRes = new TestResource(SEPARATE, Mode.Separate);

            _server.Add(piggyRes);
            _server.Add(separateRes);
            _server.Start();
            _serverPort = ((System.Net.IPEndPoint)_serverEndpoint.LocalEndPoint).Port;

            _timer = new Timer(o =>
            {
                piggyRes.Fire();
                separateRes.Fire();
            }, null, 0, OBS_NOTIFICATION_INTERVALL);
        }
示例#17
0
        public void Start()
        {
            CoAP.Log.LogManager.Level = CoAP.Log.LogLevel.Error;
            int port;
            string apiPort = System.Configuration.ConfigurationManager.AppSettings["APIPort"];
            if (!int.TryParse(apiPort, out port))
                port = 14080;
            _ProcessRequestsThread = new Thread(new ThreadStart(ProcessRequests));
            if (_ProcessRequestsThread.Name == null)
                _ProcessRequestsThread.Name = "ProcessRequestsThread";
            _ProcessRequestsThread.IsBackground = true;
            _ProcessRequestsThread.Start();
            if (_CoapServer == null)
            {
                _CoapServer = new CoapServer();
                _CoapServer.MessageDeliverer = this;
                if (!SecureOnly)
                    _CoapServer.AddEndPoint(new CoAPEndPoint(new FlowChannel(Port), CoapConfig.Default));
                _SecureChannel = new FlowSecureChannel(Port + 1);
                if (System.IO.File.Exists("LWM2MServer.pem"))
                {
                    _SecureChannel.CertificateFile = "LWM2MServer.pem";
                }
                _SecureChannel.PSKIdentities = _PSKIdentities;
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CCM_8);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256);
                _SecureChannel.ValidatePSK += new EventHandler<ValidatePSKEventArgs>(ValidatePSK);
                _CoapServer.AddEndPoint(new CoAPEndPoint(_SecureChannel, CoapConfig.Default));
            }
            _CoapServer.Start();

            ServiceEventMessage message = new ServiceEventMessage();
            Imagination.Model.LWM2MServer lwm2mServer = new Imagination.Model.LWM2MServer();
            lwm2mServer.Url = ServiceConfiguration.ExternalUri.ToString();
            message.AddParameter("Server", lwm2mServer);
            BusinessLogicFactory.ServiceMessages.Publish("LWM2MServer.Start", message, TMessagePublishMode.Confirms);

            _ServerEndPoint = string.Concat("net.tcp://", ServiceConfiguration.Hostname, ":", port.ToString(), "/LWM2MServerService");
            if (_NativeServerAPI == null)
                _NativeServerAPI = new NativeIPCServer(AddressFamily.InterNetwork,port);
            _NativeServerAPI.Start();
            if (_NativeServerAPIv6 == null)
                _NativeServerAPIv6 = new NativeIPCServer(AddressFamily.InterNetworkV6, port);
            _NativeServerAPIv6.Start();
            //if (_ServiceHost != null)
            //    _ServiceHost.Close();
            //_ServiceHost = new ServiceHost(typeof(Imagination.Service.ServerAPI));
            //ServiceThrottlingBehavior throttle = _ServiceHost.Description.Behaviors.Find<ServiceThrottlingBehavior>();
            //if (throttle == null)
            //{
            //    throttle = new ServiceThrottlingBehavior
            //    {
            //        MaxConcurrentCalls = 100,
            //        MaxConcurrentSessions = 100,
            //        MaxConcurrentInstances = int.MaxValue
            //    };
            //    _ServiceHost.Description.Behaviors.Add(throttle);
            //}
            //else
            //{
            //    throttle.MaxConcurrentCalls = 100;
            //    throttle.MaxConcurrentSessions = 100;
            //    throttle.MaxConcurrentInstances = int.MaxValue;
            //}
            //NetTcpBinding netTcpBinding = new NetTcpBinding();
            //_ServiceHost.AddServiceEndpoint(typeof(Imagination.Service.ILWM2MServerService), netTcpBinding, _ServerEndPoint);
            ////int newLimit = _ServiceHost.IncrementManualFlowControlLimit(100);
            //_ServiceHost.Open();
        }
示例#18
0
        private void CreateServer()
        {
            CoAPEndPoint endpoint = new CoAPEndPoint(0);

            _resource = new TestResource(NAME_1, PAYLOAD);
            _server = new CoapServer();
            _server
                .Add(new Resource(RES_A)
                    .Add(new Resource(RES_AA)
                        .Add(_resource
                            .Add(new TestResource(CHILD, CHILD_PAYLOAD)))));

            _server.AddEndPoint(endpoint);
            _server.Start();
            _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port;
        }
示例#19
0
        private void CreateServer()
        {
            CoAPEndPoint endpoint = new CoAPEndPoint(0);
            _resource = new StorageResource(TARGET, CONTENT_1);
            _server = new CoapServer();
            _server.Add(_resource);

            _server.AddEndPoint(endpoint);
            _server.Start();
            _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port;
        }
示例#20
0
        public void Start()
        {
            CoAP.Log.LogManager.Level = CoAP.Log.LogLevel.Error;
            int    port;
            string apiPort = System.Configuration.ConfigurationManager.AppSettings["APIPort"];

            if (!int.TryParse(apiPort, out port))
            {
                port = 14080;
            }
            _ProcessRequestsThread = new Thread(new ThreadStart(ProcessRequests));
            if (_ProcessRequestsThread.Name == null)
            {
                _ProcessRequestsThread.Name = "ProcessRequestsThread";
            }
            _ProcessRequestsThread.IsBackground = true;
            _ProcessRequestsThread.Start();
            if (_CoapServer == null)
            {
                _CoapServer = new CoapServer();
                _CoapServer.MessageDeliverer = this;
                if (!SecureOnly)
                {
                    _CoapServer.AddEndPoint(new CoAPEndPoint(new FlowChannel(Port), CoapConfig.Default));
                }
                _SecureChannel = new FlowSecureChannel(Port + 1);
                if (System.IO.File.Exists("LWM2MServer.pem"))
                {
                    _SecureChannel.CertificateFile = "LWM2MServer.pem";
                }
                _SecureChannel.PSKIdentities = _PSKIdentities;
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CCM_8);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256);
                _SecureChannel.ValidatePSK += new EventHandler <ValidatePSKEventArgs>(ValidatePSK);
                _CoapServer.AddEndPoint(new CoAPEndPoint(_SecureChannel, CoapConfig.Default));
            }
            _CoapServer.Start();

            ServiceEventMessage message = new ServiceEventMessage();

            Imagination.Model.LWM2MServer lwm2mServer = new Imagination.Model.LWM2MServer();
            lwm2mServer.Url = ServiceConfiguration.ExternalUri.ToString();
            message.AddParameter("Server", lwm2mServer);
            BusinessLogicFactory.ServiceMessages.Publish("LWM2MServer.Start", message, TMessagePublishMode.Confirms);


            _ServerEndPoint = string.Concat("net.tcp://", ServiceConfiguration.Hostname, ":", port.ToString(), "/LWM2MServerService");
            if (_NativeServerAPI == null)
            {
                _NativeServerAPI = new NativeIPCServer(AddressFamily.InterNetwork, port);
            }
            _NativeServerAPI.Start();
            if (_NativeServerAPIv6 == null)
            {
                _NativeServerAPIv6 = new NativeIPCServer(AddressFamily.InterNetworkV6, port);
            }
            _NativeServerAPIv6.Start();
            //if (_ServiceHost != null)
            //    _ServiceHost.Close();
            //_ServiceHost = new ServiceHost(typeof(Imagination.Service.ServerAPI));
            //ServiceThrottlingBehavior throttle = _ServiceHost.Description.Behaviors.Find<ServiceThrottlingBehavior>();
            //if (throttle == null)
            //{
            //    throttle = new ServiceThrottlingBehavior
            //    {
            //        MaxConcurrentCalls = 100,
            //        MaxConcurrentSessions = 100,
            //        MaxConcurrentInstances = int.MaxValue
            //    };
            //    _ServiceHost.Description.Behaviors.Add(throttle);
            //}
            //else
            //{
            //    throttle.MaxConcurrentCalls = 100;
            //    throttle.MaxConcurrentSessions = 100;
            //    throttle.MaxConcurrentInstances = int.MaxValue;
            //}
            //NetTcpBinding netTcpBinding = new NetTcpBinding();
            //_ServiceHost.AddServiceEndpoint(typeof(Imagination.Service.ILWM2MServerService), netTcpBinding, _ServerEndPoint);
            ////int newLimit = _ServiceHost.IncrementManualFlowControlLimit(100);
            //_ServiceHost.Open();
        }
示例#21
0
        static CoapServer SetupServer(ICoapConfig config, EndPoint endPoint, int port, KeySet dtlsSignKeys,
                                      KeySet dtlsValidateKeys)
        {
            //
            //

            CoapServer   server = new CoapServer(config, endPoint, port);
            DTLSEndPoint ep2    = new DTLSEndPoint(dtlsSignKeys, dtlsValidateKeys, port + 1);

            server.AddEndPoint(ep2);

            IResource root = new HelloWorldResource("hello", true);

            server.Add(root);

            IResource x = new OscoapTest("coap");

            root.Add(x);

            x = new OscoapTest("1");
            root.Add(x);

            root.Add(new OscoapTest("2"));
            root.Add(new OscoapTest("3"));
            root.Add(new OscoapTest("6"));
            root.Add(new OscoapTest("7"));

            server.Add(new OscoapTest("test"));

            server.Add(new TimeResource("observe"));

            server.Add(new LargeResource("LargeResource"));

#if DEV_VERSION
            AceTest.Setup(server, "RS1");
#if false
            server.Add(new Com.AugustCellars.CoAP.EDHOC.EdhocResource(edhocKeys, edhocSign));
#endif

            //  Setup the ACE resources
            string UseAsServer = "coaps://localhost:5689/token";
            // UseAsServer = "coaps://31.133.142.90/token";
            // UseAsServer = "coaps://31.133.134.176/token";

            KeySet myDecryptKeySet = new KeySet();
            OneKey key             = new OneKey();

            key.Add(CoseKeyKeys.KeyType, GeneralValues.KeyType_Octet);
            key.Add(CoseKeyParameterKeys.Octet_k, CBORObject.FromObject(new byte[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }));
            key.Add(CoseKeyKeys.KeyIdentifier, CBORObject.FromObject(Encoding.UTF8.GetBytes("SERVER_KID")));
            key.Add(CoseKeyKeys.Algorithm, AlgorithmValues.AES_CCM_64_128_128);

            myDecryptKeySet.AddKey(key);

            key = new OneKey();
            key.Add(CoseKeyKeys.KeyType, GeneralValues.KeyType_Octet);
            key.Add(CoseKeyParameterKeys.Octet_k, CBORObject.FromObject(new byte[] { (byte)'a', (byte)'b', (byte)'c', 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 }));
            key.Add(CoseKeyKeys.KeyIdentifier, CBORObject.FromObject(new byte[] { 0x70, 0x63, 0x6F, 0x61, 0x70, 0x3A, 0x2F, 0x2F, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x68, 0x6F, 0x73, 0x74 }));
            key.Add(CoseKeyKeys.Algorithm, CBORObject.FromObject(5));
            myDecryptKeySet.AddKey(key);

            AuthZ authZ = new AuthZ(myDecryptKeySet, null);
            server.Add(authZ);
            AceOAuthTest r = new AceOAuthTest("ace-echo", true, true, UseAsServer);
            r.AuthTokenProcessor = authZ;
            server.Add(r);
            OscoapContexts = SecurityContextSet.AllContexts;
#endif

            // ep2.Add(new AceOAuthTest("ace/echo", true, true, null));

#if INCLUDE_RD
            ResourceDirectoryResource.CreateResources(server);
#endif

#if DEV_VERSION
            // server = new CoapServer(config);
            CoAPEndPoint tcp = new TcpEndPoint(port);
            tcp.Start();
            server.AddEndPoint(tcp);

            // server.Add(new HelloWorldResource("hello", false));
            // server.Add(new LargeResource("LargeResource"));
            server.Add(new LargeResource("ExtraLargeResource", 20 * 1024));
            server.Add(new StorageResource("StorageHere"));
            server.Start();

            // server = new CoapServer(config);
            tcp = new TLSEndPoint(dtlsSignKeys, dtlsValidateKeys, port + 1);
            tcp.Start();
            server.AddEndPoint(tcp);

            AceTest.Setup(server, "RS2");

            //server.Add(new HelloWorldResource("hello", false));
#endif

            server.Start();
            return(server);
        }
示例#22
0
 private void CreateServer()
 {
     _server = new CoapServer();
     CoAPEndPoint endpoint = new CoAPEndPoint(_serverPort, _config);
     _server.AddEndPoint(endpoint);
     _server.MessageDeliverer = new MessageDeliverer(this);
     _server.Start();
 }