public void Run() { var chatServer = new ChatServer(); chatServer.Start(); var authenticationServer = new AuthenticationServer(chatServer); authenticationServer.Start(); var server = new NetworkServer(authenticationServer); server.Start(); while (!this.isDisposed) { if (Console.ReadLine() == "quit") { this.Dispose(); } } server.Stop(); authenticationServer.Stop(); }
/// <summary> /// 按条件查询平台中的设备 /// </summary> /// <param name="pageNo"></param> /// <param name="pageSize"></param> /// <param name="startTime">查询注册设备信息时间在startTime之后的记录,格式:“20151212T121212Z”</param> /// <returns>Json数据</returns> public static string QueryDevice(long pageNo, long pageSize, string startTime) { string result = AuthenticationServer.GetNorthAPIContent($"dm/v1.3.0/devices?appId={AuthenticationServer.AppID}" + $"&pageNo={pageNo}&pageSize={pageSize}&startTime={startTime}", "GET"); return(result); }
public static string QueryDeviceHistoryData(string deviceId, string gatewayId, string startTime, string endTime) { string result = AuthenticationServer.GetNorthAPIContent($"data/v1.1.0/deviceDataHistory?deviceId={deviceId}" + $"&gatewayId={gatewayId}&startTime={startTime}&endTime={endTime}", "GET"); return(result); }
public void Discover_Metadata() { var server = new AuthenticationServer("https://accounts.google.com"); var config = server.GetConfigurationAsync(CancellationToken.None).Result; Assert.IsNotNull(config, "metadata is missing"); Assert.AreNotEqual(0, config.SigningTokens.Count(), "signing tokens missing"); }
/// <summary> /// Returns the realm, specified by the next word or number, if the Realm could be found, else sends a reply. /// </summary> /// <param name="trigger"></param> /// <returns></returns> public static RealmEntry GetRealm(CmdTrigger <AuthServerCmdArgs> trigger) { var arg = trigger.Text.Remainder; uint no; var count = AuthenticationServer.RealmCount; if (count > 0) { if (uint.TryParse(arg, out no)) { if (count < no) { trigger.Reply("Invalid Realm Number - Must be between 1 and {0}", count); } else { return(AuthenticationServer.GetRealmByNumber((int)no)); } } else { return(AuthenticationServer.GetRealmByName(arg)); } } else { trigger.Reply("There are no registered Realms."); } return(null); }
/// <summary> /// 修改直连设备信息 /// </summary> /// <param name="deviceId"></param> /// <param name="modifyDeviceInfoMode"></param> /// <returns></returns> public static string ModifyDeviceInfo(string deviceId, ModifyDeviceInfoMode modifyDeviceInfoMode) { //格式化json string json = Newtonsoft.Json.JsonConvert.SerializeObject(modifyDeviceInfoMode, Newtonsoft.Json.Formatting.Indented); string result = AuthenticationServer.GetNorthAPIContent($"dm/v1.2.0/devices/{deviceId}?appId={AuthenticationServer.AppID}", "PUT", json); return(result); }
/// <summary> /// Default constructor /// </summary> public IPCServiceAdapter() { s_authServer = AuthenticationServer.Instance; var channel = OperationContext.Current.Channel; channel.Closed += OnDisconnected; channel.Faulted += OnDisconnected; }
/// <summary> /// Sets all active accounts of one realmserver /// </summary> /// <param name="accNames">the account names to login</param> public void SetAllActiveAccounts(string realmId, string[] accNames) { s_authServer.ClearAccounts(realmId); var realm = AuthenticationServer.GetRealmById(realmId); if (realm != null) { for (int i = 0; i < accNames.Length; i++) { s_authServer.SetAccountLoggedIn(realm, accNames[i]); } } }
public void Home() { var server = new AuthenticationServer("https://accounts.google.com"); // HTTPS required. ExceptionAssert.Throws<ArgumentException>(() => new AuthenticationServer("http://accounts.google.com")); // Query component not allowed. ExceptionAssert.Throws<ArgumentException>(() => new AuthenticationServer("https://accounts.google.com?notallowed=true")); // Fragment component not allowed. ExceptionAssert.Throws<ArgumentException>(() => new AuthenticationServer("https://accounts.google.com#notallowed")); }
public static bool Received(AuthenticationServer form, PacketContent pc, Candidate c) { _form = form; PlayerRecvPackets msgType = (PlayerRecvPackets)pc.GetMsgType(); bool ret = true; switch (msgType) { case PlayerRecvPackets.Login: ret = CheckCredentials(pc, c); break; case PlayerRecvPackets.ServerSelect: ret = PassNewPlayerToServer(pc, c); break; } return ret; }
/// <summary> /// 注册直连设备 /// </summary> /// <param name="nodeId">设备唯一标识码(验证码)</param> /// <param name="timeout">设备验证有效期,超时未绑定则设备验证码失效 /// 0:永久有效(秒)</param> /// <returns></returns> public static string RegisterDirectlyConnectedDevice(string nodeId, string devicePSK) { RegisterDeviceMode registerDevice = new RegisterDeviceMode(); //设置验证码与设备唯一标识码相同 registerDevice.verifyCode = nodeId; registerDevice.nodeId = nodeId; registerDevice.psk = devicePSK; registerDevice.timeout = 3600 * 24 * 7; //格式化json string json = Newtonsoft.Json.JsonConvert.SerializeObject(registerDevice, Newtonsoft.Json.Formatting.Indented); string deviceString = AuthenticationServer.GetNorthAPIContent($"reg/v1.2.0/devices?appId={AuthenticationServer.AppID}", "POST", json); Console.WriteLine(value: " ----------Device_Register_Response:" + deviceString); return(deviceString); }
/// <summary> /// Default constructor /// </summary> public IPCServiceAdapter() { s_authServer = AuthenticationServer.Instance; var channel = OperationContext.Current.Channel; channel.Faulted += (sender, args) => { var realm = GetRealmByChannel((IContextChannel) sender); String msg; if (realm != null) { msg = realm.ToString(); realm.SetOffline(AuthServerConfiguration.RemoveOfflineRealms); } else { msg = "<Unknown>"; } log.Warn(Resources.RealmDisconnected, msg); }; }
/// <summary> /// Registers a realm server with the authentication server /// </summary> /// <param name="realmName">the name of the server</param> /// <param name="serverType">the type of the server</param> /// <param name="flags">the up/down status of the serer (green/red)</param> /// <param name="serverCategory">the timezone the server is in</param> /// <param name="serverStatus">the status of the server (locked or not)</param> public void RegisterRealmServer(string realmName, string addr, int port, int chrCount, int capacity, RealmServerType serverType, RealmFlags flags, RealmCategory serverCategory, RealmStatus serverStatus, ClientVersion clientVersion) { var context = OperationContext.Current; if (context == null) { return; } var channel = context.Channel; if (channel == null) { return; } var id = GetCurrentId(); var realm = AuthenticationServer.GetRealmById(id); var ep = GetCurrentEndPoint(); // find out whether this server is just re-registering (came back online) var isNew = realm == null; if (isNew) { realm = AuthenticationServer.GetRealmByName(realmName); if (realm == null) { if (!AuthServerConfiguration.RealmIPs.Contains(ep.Address)) { // Ignore unknown realms log.Warn("Unallowed Realm (\"{0}\") tried to register from: {1} (For more info, see the <RealmIPs> entry in your configuration)", realmName, ep.Address, AuthServerConfiguration.Instance.FilePath); var chan = OperationContext.Current.Channel; if (chan != null) { try { chan.Close(); } catch (Exception) {} } return; } realm = new RealmEntry(); } else { lock (AuthenticationServer.Realms) { AuthenticationServer.RemoveRealmByName(realmName); } } } if (string.IsNullOrEmpty(addr)) { // no host given addr = ep.Address; } realm.ChannelId = id; realm.Name = realmName; realm.Address = addr; realm.Port = port; realm.Flags = flags; realm.Status = serverStatus; realm.ServerType = serverType; realm.Category = serverCategory; realm.CharCount = chrCount; realm.CharCapacity = capacity; realm.ClientVersion = clientVersion; realm.Channel = channel; realm.ChannelAddress = ep.Address; realm.ChannelPort = ep.Port; if (isNew) { // register after setting all infos lock (AuthenticationServer.Realms) { AuthenticationServer.AddRealm(realm); } } log.Info(resources.RealmRegistered, realm); //realm.ChannelAddress); }
/// <summary> /// Default constructor. /// </summary> /// <param name="server">reference to the parent AuthServer</param> public AuthClient(AuthenticationServer server) : base(server) { }
/// <summary> /// 查询单个设备信息 /// </summary> /// <param name="deviceId">设备ID</param> /// <returns>Json数据</returns> public static string QueryDeviceInfo(string deviceId) { string result = AuthenticationServer.GetNorthAPIContent($"dm/v1.3.0/devices/{deviceId}?appId={AuthenticationServer.AppID}", "GET"); return(result); }
public static string QueryDeviceActivationStatus(string deviceId) { string result = AuthenticationServer.GetNorthAPIContent($"reg/v1.1.0/devices/{deviceId}?appId={AuthenticationServer.AppID}", "GET"); return(result); }
/// <summary> /// 删除直连设备 /// </summary> /// <param name="deviceId"></param> /// <returns></returns> public static string DeleteDirectlyConnectedDevice(string deviceId) { string result = AuthenticationServer.GetNorthAPIContent($"dm/v1.1.0/devices/{deviceId}?appId={AuthenticationServer.AppID}&cascade=true", "DELETE"); return(result); }
/// <summary> /// Returns the RealmEntry that belongs to the Channel /// that is performing the current communication. /// Can only be used from remote IPC Channels. /// </summary> public RealmEntry GetCurrentRealm() { return(AuthenticationServer.GetRealmById(GetCurrentId())); }
private void Initialize() { AuthenticationServer = new AuthenticationServer(); AuthenticationServer.Address = "192.168.255.128"; AuthenticationServer.Port = 5554; }