当前位置: 首页>>代码示例>>C#>>正文


C# IAuthClient类代码示例

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


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


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