Beispiel #1
0
        public AsnElt Encode()
        {
            SignedCms signed = new SignedCms(
                new ContentInfo(
                    IdPkInitAuthData,
                    AuthPack.Encode().Encode()
                    )
                );

            var signer = new CmsSigner(PKCert);

            signed.ComputeSignature(signer, silent: false);

            return(AsnElt.Make(AsnElt.SEQUENCE, new AsnElt[] {
                AsnElt.Make(AsnElt.CONTEXT, 0, new AsnElt[] {
                    AsnElt.MakeBlob(signed.Encode())
                })
            }));
        }
        public async Task <IActionResult> Login(AuthPack userInput)
        {
            if (ModelState.IsValid)
            {
                string inputEmail    = userInput.Email;
                string inputPassword = userInput.Password;

                try
                {
                    string request       = $"manager/get/{inputEmail}";
                    var    resultManager = await this.GetDataAsync <Manager>(request);

                    if (resultManager.Password == inputPassword && resultManager.Email == inputEmail)
                    {
                        CurrentManager = resultManager;
                        return(RedirectToAction("Index", "Manager"));
                    }
                    else
                    {
                        // TODO: Show the user the login failed.

                        return(View(userInput));
                    };
                }
                catch (HttpRequestException)
                {
                    // TODO: Add information for the user if the request failed.
                    return(View(userInput));
                }
                catch (NullReferenceException)
                {
                    // TODO: Add information for the user if there was no customer returned.
                    return(View(userInput));
                }
            }

            return(View(userInput));
        }
        public async Task <IActionResult> AddCustomer(Customer customer)
        {
            // TODO: Use Customer MVC Model instead of DB Model
            if (ModelState.IsValid)
            {
                try
                {
                    Customer newCustomer = new Customer(customer.Name, customer.Email, customer.Password, customer.Address);
                    await this.PostDataAsync($"customer/add", newCustomer);

                    AuthPack customerData = new AuthPack(customer.Email, customer.Password);
                    return(RedirectToAction("Login", "Home", customerData));
                } catch (HttpRequestException e)
                {
                    ModelState.AddModelError(string.Empty, e.Message);
                    return(View(customer));
                }
            }
            else
            {
                return(View(customer));
            }
        }
Beispiel #4
0
        public AsnElt Encode()
        {
            SignedCms signed = new SignedCms(
                new ContentInfo(
                    IdPkInitAuthData,
                    AuthPack.Encode().Encode()
                    )
                );

            var signer = new CmsSigner(PKCert);

            if (!VerifyCerts)
            {
                signer.IncludeOption = X509IncludeOption.EndCertOnly; // only the end certificate is included in the X.509 chain information.
            }
            signed.ComputeSignature(signer, silent: false);

            return(AsnElt.Make(AsnElt.SEQUENCE, new AsnElt[] {
                AsnElt.Make(AsnElt.CONTEXT, 0, new AsnElt[] {
                    AsnElt.MakeBlob(signed.Encode())
                })
            }));
        }
Beispiel #5
0
 private void btn_AutoAuth_Click(object sender, EventArgs e)
 {
     SessionPackMgr.putToHead(AuthPack.makeAutoAuthPack(2));
     // new NetSceneGetChatRoomMsg().doScene("7582614867@chatroom", 666591975);
     // new NetSceneInitContact().doScene(SessionPackMgr.getAccount().getUsername(),0,0);
 }