• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IAuthClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IAuthClient的典型用法代码示例。如果您正苦于以下问题:C# IAuthClient类的具体用法?C# IAuthClient怎么用?C# IAuthClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IAuthClient类属于命名空间,在下文中一共展示了IAuthClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnLogin

		public virtual void OnLogin(IAuthClient client)
		{
			var addr = client.ClientAddress;
			if (addr == null)
			{
				// client disconnected
				return;
            }

            LastIP = addr.GetAddressBytes();
            LastLogin = DateTime.Now;
			Locale = client.Info.Locale;
			ClientVersion = client.Info.Version.ToString();
			//UpdateAndFlush(); TODO: I believe this saves the value to the database

			AuthCommandHandler.AutoExecute(this);

			var evt = LoggedIn;
			if (evt != null)
			{
				evt(this, client);
			}

			s_log.Info("Account \"{0}\" logged in from {1}.", Name, client.ClientAddress);
		}
开发者ID:remixod,项目名称:netServer,代码行数:25,代码来源:Account.cs


示例2: SendAuthChallengeErrorReply

		/// <summary>
		/// Sends an authentication challenge error to the client.
		/// </summary>
		/// <param name="client">the client</param>
		/// <param name="error">the authentication challenge error to send</param>
		public static void SendAuthChallengeErrorReply(IAuthClient client, AccountStatus error)
		{
			using (var packet = new AuthPacketOut(AuthServerOpCode.AUTH_LOGON_CHALLENGE))
			{
				packet.Write((byte)0x00);
				packet.Write((byte)error);

				client.Send(packet);
			}
		}
开发者ID:pallmall,项目名称:WCell,代码行数:15,代码来源:AuthenticationHandler.cs


示例3: SendAuthChallengeSuccessReply

		/// <summary>
		/// Sends an authentication challenge success reply to the client.
		/// </summary>
		/// <param name="client">the client</param>
		public static void SendAuthChallengeSuccessReply(IAuthClient client)
		{
			using (var packet = new AuthPacketOut(AuthServerOpCode.AUTH_LOGON_CHALLENGE))
			{
				packet.Write((byte)AccountStatus.Success);
				// Grunt command
				packet.Write((byte)0x00);

				client.Authenticator.WriteServerChallenge(packet);

                //var rand = new BigInteger(new Random(Environment.TickCount), 128);
                //packet.WriteBigInt(rand, 16);
                Random rand = new Random(Environment.TickCount);
                byte[] randbytes = new byte[16];              
                rand.NextBytes(randbytes);           
                packet.Write(randbytes);            
                
                const byte securityFlag = 0x0;
				packet.Write(securityFlag);

				// Require PIN input
                //if ((securityFlag & 0x1) == 0x1)
                //{
                //    packet.WriteInt(0);
                //    packet.Write(new byte[16]);
                //}

                // Matrix input
                //if ((securityFlag & 0x2) == 0x2)
                //{
                //    packet.Write((byte)0);
                //    packet.Write((byte)0);
                //    packet.Write((byte)0);
                //    packet.Write((byte)0);
                //    packet.Write(0UL);
                //}
				// Require Security Token input
                //if ((securityFlag & 0x4) == 0x4)
                //{
                //    packet.Write((byte)1);
                //}

				client.Send(packet);
			}
		}
开发者ID:pallmall,项目名称:WCell,代码行数:49,代码来源:AuthenticationHandler.cs


示例4: AuthChallengeRequest

		public static void AuthChallengeRequest(IAuthClient client, AuthPacketIn packet)
		{
			packet.SkipBytes(6); // Skip game name and packet size

			client.Info = ClientInformation.ReadFromPacket(packet);

			// Account-names are always sent upper-case by the client (make sure, the tradition is kept alive)
			var accName = packet.ReadPascalString().ToUpper();

			s_log.Debug(Resources.AccountChallenge, accName);

			client.AccountName = accName;
			AuthenticationServer.Instance.AddMessage(new Message1<IAuthClient>(client, AuthChallengeRequestCallback));
		}
开发者ID:pallmall,项目名称:WCell,代码行数:14,代码来源:AuthenticationHandler.cs


示例5: AuthChallengeRequestCallback

		/// <summary>
		/// Check for bans and already logged in Accounts, else continue the journey
		/// </summary>
		/// <param name="client"></param>
		private static void AuthChallengeRequestCallback(IAuthClient client)
		{
			if (!client.IsConnected)
			{
				// Client disconnected in the meantime
				return;
			}

			if (BanMgr.IsBanned(client.ClientAddress))
			{
				OnLoginError(client, AccountStatus.AccountBanned);	
			}
			//else if (client.Server.IsAccountLoggedIn(client.AccountName))
			//{
			//    OnLoginError(client, AccountStatus.AccountInUse);
			//}
			else
			{
			    var acctQuery = new Action(() =>
			    {
			        var acc = AccountMgr.GetAccount(client.AccountName);
			        QueryAccountCallback(client, acc);
			    });

				AuthenticationServer.Instance.AddMessage(acctQuery);
			}
		}
开发者ID:pallmall,项目名称:WCell,代码行数:31,代码来源:AuthenticationHandler.cs


示例6: OnLoginError

		/// <summary>
		/// Called when the given client failed to login due to the given reason.
		/// Delays, fires the LoginFailed event and sends the reply.
		/// </summary>
		/// <param name="client"></param>
		/// <param name="error"></param>
		public static void OnLoginError(IAuthClient client, AccountStatus error)
		{
			OnLoginError(client, error, false);
		}
开发者ID:pallmall,项目名称:WCell,代码行数:10,代码来源:AuthenticationHandler.cs


示例7: AuthProofRequest

		public static void AuthProofRequest(IAuthClient client, AuthPacketIn packet)
		{
			if (client.Authenticator == null)
			{
				client.Server.DisconnectClient(client);
			}
			else
			{
				if (client.Authenticator.IsClientProofValid(packet))
				{
					if (client.IsAutocreated)
					{
						// Their stuff matched, which means they gave us the same password
						// as their username, which is what must occur to autocreate. Create
						// the account for them before proceeding.

						s_log.Debug(Resources.AutocreatingAccount, client.CurrentUser);

						string role;
						if (IPAddress.IsLoopback(client.ClientAddress))
						{
							// local users get the highest role
							role = RoleGroupInfo.HighestRole.Name;
						}
						else
						{
							// remote users get default role
							role = AuthServerConfiguration.DefaultRole;
						}

						var acctCreateQuery = QueryFactory.CreateResultQuery(
							() => AccountMgr.Instance.CreateAccount(
							          client.CurrentUser,
							          client.Authenticator.SRP.Credentials.GetBytes(20),
							          null,
							          role,
							          ClientId.Wotlk
							          ),
							AutocreateAccountCallback,
							client
							);

						client.Server.EnqueueTask(acctCreateQuery);
					}
					else
					{
						// The following was sent twice
						var authInfo = new AuthenticationInfo {
							SessionKey = client.Authenticator.SRP.SessionKey.GetBytes(40),
							Salt = client.Authenticator.SRP.Salt.GetBytes(32),
							Verifier = client.Authenticator.SRP.Verifier.GetBytes(),
							SystemInformation = ClientInformation.Serialize(client.ClientInfo)
						};

						client.Server.StoreAuthenticationInfo(client.CurrentUser, authInfo);

						SendAuthProofSuccessReply(client);
					}
				}
				else
				{
					s_log.Debug(Resources.InvalidClientProof, client.CurrentUser);

					OnLoginError(client, AccountStatus.InvalidInformation);
				}
			}
		}
开发者ID:KroneckerX,项目名称:WCell,代码行数:67,代码来源:Authentication.cs


示例8: AuthReconnectChallenge

		public static void AuthReconnectChallenge(IAuthClient client, AuthPacketIn packet)
		{
			SendAuthReconnectChallenge(client);
		}
开发者ID:pallmall,项目名称:WCell,代码行数:4,代码来源:AuthenticationHandler.cs


示例9: SendAuthReconnectChallenge

		public static void SendAuthReconnectChallenge(IAuthClient client)
		{
			//using (var packet = new AuthPacketOut(AuthServerOpCode.AUTH_RECONNECT_CHALLENGE))
			//{
			//    //client.Authenticator.WriteReconnectChallenge(packet);
			//    client.Send(packet);
			//}

			// drop silently for now
			OnLoginError(client, AccountStatus.Failure, true);
		}
开发者ID:pallmall,项目名称:WCell,代码行数:11,代码来源:AuthenticationHandler.cs


示例10: WriteRealm

        /// <summary>
        /// Writes the realm information to the specified packet.
        /// </summary>
        /// <param name="packet">the packet to write the realm info to</param>
        public void WriteRealm(IAuthClient client, AuthPacketOut packet)
        {
			var status = Status;
			var flags = Flags;
			var name = Name;
			if (!ClientVersion.IsSupported(client.Info.Version))
			{
				flags = RealmFlags.Offline;
				name += " [" + ClientVersion.BasicString + "]";
			}
            else if (Flags.HasFlag(RealmFlags.Offline) && Status == RealmStatus.Locked)
            {
            	var acc = client.Account;
                var role = acc.Role;
                if (role.IsStaff)
                {
                    status = RealmStatus.Open;
                	flags = RealmFlags.None;
                }
			}

            // TODO: Change char-count to amount of Characters of the querying account on this Realm
			packet.Write((byte)ServerType);
            packet.Write((byte)status);
            packet.Write((byte)flags);
            packet.WriteCString(name);
            packet.WriteCString(AddressString);
            packet.Write(Population);
            packet.Write(Chars);
            packet.Write((byte)Category);
            packet.Write((byte)0x00); // realm separator?
        }
开发者ID:NVN,项目名称:WCell,代码行数:36,代码来源:RealmEntry.cs


示例11: LoginClient

		/// <summary>
		/// Client passed login challenge and can be logged in
		/// </summary>
		/// <param name="client"></param>
		private static void LoginClient(IAuthClient client)
		{
			var acc = client.Account;

			if (acc == null)
			{
				// Pass and username are identical so an Account can be auto-created
				// the corresponding check happened before
				s_log.Debug(Resources.AutocreatingAccount, client.AccountName);

				if (AccountMgr.DoesAccountExist(client.AccountName))
				{
					// account was already created								
					SendAuthProofErrorReply(client, AccountStatus.Failure);
					return;
				}
				acc = AutoCreateAccount(client);
			}

			var authInfo = new AuthenticationInfo
			{
				SessionKey = client.Authenticator.SRP.SessionKey.GetBytes(40),
				Salt = client.Authenticator.SRP.Salt.GetBytes(32),
				Verifier = client.Authenticator.SRP.Verifier.GetBytes(),
				SystemInformation = ClientInformation.Serialize(client.Info)
			};
			client.Server.StoreAuthenticationInfo(client.AccountName, authInfo);

			acc.OnLogin(client);
			SendAuthProofSuccessReply(client);
		}
开发者ID:pallmall,项目名称:WCell,代码行数:35,代码来源:AuthenticationHandler.cs


示例12: OnLoginError

		/// <summary>
		/// Called when the given client failed to login due to the given reason.
		/// Delays, fires the LoginFailed event and sends the reply.
		/// </summary>
		/// <param name="client"></param>
		/// <param name="error"></param>
		private static void OnLoginError(IAuthClient client, AccountStatus error)
		{
			TimeoutWaitHandle delayHandle;
			if (!failedLogins.TryGetValue(client.ClientAddress, out delayHandle))
			{
				failedLogins.Add(client.ClientAddress, delayHandle = new TimeoutWaitHandle(DateTime.Now));
			}
			else
			{
				delayHandle.LastAttempt = DateTime.Now;
			}

			ThreadPool.RegisterWaitForSingleObject(delayHandle.Handle, (state, timedOut) => {
				if (client.IsConnected)
				{
					var evt = LoginFailed;
					if (evt != null)
					{
						evt(client, error);
					}
					SendAuthProofErrorReply(client, error);
				}
			}, null, LoginFailedDelay, true);
		}
开发者ID:KroneckerX,项目名称:WCell,代码行数:30,代码来源:Authentication.cs


示例13: AuthPacketMessage

		public AuthPacketMessage(Action<IAuthClient, AuthPacketIn> handler, IAuthClient client, AuthPacketIn packet)
		{
			m_handler = handler;
			m_client = client;
			m_packet = packet;
		}
开发者ID:KroneckerX,项目名称:WCell,代码行数:6,代码来源:AuthPacketMessage.cs


示例14: SendAuthReconnectChallenge

		public static void SendAuthReconnectChallenge(IAuthClient client)
		{
			using (var packet = new AuthPacketOut(AuthServerOpCode.AUTH_RECONNECT_CHALLENGE))
			{
				client.Authenticator.WriteReconnectChallenge(packet);
			}
		}
开发者ID:KroneckerX,项目名称:WCell,代码行数:7,代码来源:Authentication.cs


示例15: AuthReconnectProof

		public static void AuthReconnectProof(IAuthClient client, AuthPacketIn packet)
		{
			AuthenticationInfo authInfo;
			if (AuthenticationServer.Instance.GetAuthenticationInfo(client.CurrentUser, out authInfo))
			{
				if (client.Authenticator.IsReconnectProofValid(packet, authInfo))
				{
					SendAuthReconnectProof(client);
				}
			}

		}
开发者ID:KroneckerX,项目名称:WCell,代码行数:12,代码来源:Authentication.cs


示例16: AutocreateAccountCallback

		private static void AutocreateAccountCallback(IAuthClient client, Account acct)
		{
			if (acct == null)
			{
				OnLoginError(client, AccountStatus.InvalidInformation);

				return;
			}

			var authInfo = new AuthenticationInfo {
				SessionKey = client.Authenticator.SRP.SessionKey.GetBytes(40),
				Salt = client.Authenticator.SRP.Salt.GetBytes(32),
				Verifier = client.Authenticator.SRP.Verifier.GetBytes(),
				SystemInformation = ClientInformation.Serialize(client.ClientInfo)
			};

			client.Server.StoreAuthenticationInfo(client.CurrentUser, authInfo);

			SendAuthProofSuccessReply(client);
		}
开发者ID:KroneckerX,项目名称:WCell,代码行数:20,代码来源:Authentication.cs


示例17: QueryAccountCallback

		private static void QueryAccountCallback(IAuthClient client, Account acct)
		{
			if (!client.IsConnected)
			{
				return;
			}

			var accName = client.AccountName;

			if (acct == null)
			{
				// Account doesn't exist yet -> Check for auto creation
				if (AuthServerConfiguration.AutocreateAccounts)
				{
					if (!AccountMgr.NameValidator(ref accName))
					{
						OnLoginError(client, AccountStatus.InvalidInformation);
						return;
					}

					// Fill in this client's info with the username they gave.
					// We have to go through the authentication phase, and if 
					// the password ends up matching the username, we know it's
					// an autocreation attempt.

					var passHash = SecureRemotePassword.GenerateCredentialsHash(accName, accName);

					client.Authenticator = new Authenticator(new SecureRemotePassword(accName, passHash, true));
					SendAuthChallengeSuccessReply(client);
				}
				else
				{
					OnLoginError(client, AccountStatus.InvalidInformation);
				}
			}
			else
			{
				// check if Account may be used
				if (acct.CheckActive())
				{
					client.Account = acct;
					client.Authenticator = new Authenticator(new SecureRemotePassword(accName, acct.Password, true));
					SendAuthChallengeSuccessReply(client);
				}
				else
				{
 					// Account has been deactivated
					if (client.Account.StatusUntil == null)
					{
						// temporarily suspended
						OnLoginError(client, AccountStatus.AccountBanned);
					}
					else
					{
						// deactivated
						OnLoginError(client, AccountStatus.AccountFrozen);
					}
				}
			}
		}
开发者ID:pallmall,项目名称:WCell,代码行数:60,代码来源:AuthenticationHandler.cs


示例18: RealmListRequest

 public static void RealmListRequest(IAuthClient client, PacketIn packet)
 {
     SendRealmList(client);
 }
开发者ID:remixod,项目名称:netServer,代码行数:4,代码来源:RealmEntry.cs


示例19: AuthProofRequest

		public static void AuthProofRequest(IAuthClient client, AuthPacketIn packet)
		{
			if (client.Authenticator == null)
			{
				client.Server.DisconnectClient(client);
			}
			else if (client.IsConnected)
			{
                if (client.Authenticator.IsClientProofValid(packet))
                {
                    AuthenticationServer.Instance.AddMessage(() =>
                    {
                    	LoginClient(client);
                    });
                }
                else
                {
                    s_log.Debug(Resources.InvalidClientProof, client.AccountName);

                    OnLoginError(client, AccountStatus.InvalidInformation);
                }
			}
		}
开发者ID:pallmall,项目名称:WCell,代码行数:23,代码来源:AuthenticationHandler.cs


示例20: SendRealmList

        /// <summary>
        /// Sends the realm list to the client.
        /// </summary>
        /// <param name="client">the Session the incoming packet belongs to</param>
        public static void SendRealmList(IAuthClient client)
        {
			if (client.Account == null)
			{
				AuthenticationHandler.OnLoginError(client, AccountStatus.Failure);
				return;
			}
            using (var packet = new AuthPacketOut(AuthServerOpCode.REALM_LIST))
            {
            	packet.Position += 2;							// Packet length
                packet.Write(0);								// Unknown Value (0x0000)
            	//var cpos = packet.Position;
            	//packet.Position = cpos + 2;

            	packet.Write((short)AuthenticationServer.RealmCount);

            	//var count = 0;
                foreach (var realm in AuthenticationServer.Realms)
                {
                	// check for client version
                	//if (realm.ClientVersion.IsSupported(client.Info.Version))
                	realm.WriteRealm(client, packet);
                }

            	//packet.Write((byte)0x15);
                packet.Write((byte)0x10);
				packet.Write((byte)0x00);

				//packet.Position = cpos;
				//packet.WriteShort(count);

                packet.Position = 1;
                packet.Write((short)packet.TotalLength - 3);

                client.Send(packet);
            }
        }
开发者ID:remixod,项目名称:netServer,代码行数:41,代码来源:RealmEntry.cs



注:本文中的IAuthClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IAuthProvider类代码示例发布时间:2022-05-24
下一篇:
C# IAudioStream类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap