예제 #1
0
        /// <summary>
        /// Sends a Login Request
        /// </summary>
        /// <param name="alias"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public static async Task SendLoginRequestAsync(string alias, string pwd)
        {
            string hashPwd;

            //Create a hashed pwd
            using (MD5 md5hash = MD5.Create())
            {
                hashPwd = EncryptionMD5.GetMd5Hash(md5hash, pwd);
            }
            //StorageController.LoadeRsa();

            Request request = new Request();

            request.LoginRequest(alias, hashPwd);

            Response r = await SendReqestToServerAsync(request);

            if (r == null)
            {
                return;
            }

            if (r.Type == "loginSuccess")
            {
                UserController.CurrentTocken = r.Parameters[0].ToString();
                UserController.LogedInUser   = new User(request.Parameters[0].ToString(), request.Parameters[1].ToString());
                ConfigurNagServer();
                //debug
                sendAllert = 0;
            }
            else if (r.Type == "loginError")
            {
                string messg = r.Parameters[0].ToString();

                DisplayError(messg);

                UserController.CurrentTocken = "";
                UserController.LogedInUser   = null;
            }
            else
            {
            }
        }
예제 #2
0
        /// <summary>
        /// Register Request:
        /// Sends the User Name and a Md5 hashed Pwd
        /// </summary>
        /// <param name="alias">User Name</param>
        /// <param name="pwd">Password String</param>
        /// <returns></returns>
        public static async Task SendRegisterRequestAsync(string alias, string pwd)
        {
            string hashPwd;

            //Create a hashed pwd
            using (MD5 md5hash = MD5.Create())
            {
                hashPwd = EncryptionMD5.GetMd5Hash(md5hash, pwd);
            }

            //RSAEncryption.Encryption userEncryption = UserController.GetEncryption();


            Request request = new Request();

            //request.RegisterRequest(alias, hashPwd,userEncryption.PublicKey);
            request.RegisterRequest(alias, hashPwd, "");

            Response r = await SendReqestToServerAsync(request);

            if (r == null)
            {
                return;
            }

            if (r.Type == "registationSuccess")
            {
                UserController.CurrentTocken = r.Parameters[0].ToString();
                UserController.LogedInUser   = new User(alias, hashPwd);
                ConfigurNagServer();
            }
            else
            {
                UserController.CurrentTocken = "";
                UserController.LogedInUser   = null;
            }
        }