Esempio n. 1
0
        /// <summary>
        /// Validates the password for a username token.
        /// </summary>
        private void VerifyPassword(string userName, string password)
        {
            if (String.IsNullOrEmpty(userName))
            {
                // an empty username is not accepted.
                throw ServiceResultException.Create(StatusCodes.BadIdentityTokenInvalid,
                                                    "Security token is not a valid username token. An empty username is not accepted.");
            }

            if (String.IsNullOrEmpty(password))
            {
                // 空的密码不被允许
                throw ServiceResultException.Create(StatusCodes.BadIdentityTokenRejected,
                                                    "Security token is not a valid username token. An empty password is not accepted.");
            }


            if (!DictionaryIdentity.ContainsKey(userName))
            {
                // 账户名验证失败
                throw ServiceResultException.Create(StatusCodes.BadUserAccessDenied,
                                                    "您输入的账户不存在,禁止登录");
            }


            if (DictionaryIdentity[userName] != password)
            {
                // 密码验证失败
                throw ServiceResultException.Create(StatusCodes.BadUserAccessDenied,
                                                    "您输入的账户不存在,禁止登录");
            }
        }
Esempio n. 2
0
 public DataAccessServer()
 {
     // 添加允许登录的用户名
     DictionaryIdentity.Add("admin", "123456");
     DictionaryIdentity.Add("hushaolin", "1234567890");
 }