예제 #1
0
        private void btnFaturaSec_Click(object sende, EventArgs e)
        {
            var dosyaIcerik = string.Empty;
            var result      = openFileDialog.ShowDialog(); // Show the dialog.

            if (result == DialogResult.OK)                 // Test result.
            {
                string file = openFileDialog.FileName;

                dosyaIcerik = File.ReadAllText(file);

                tcFaturaBilgileri.Visible = true;

                wbFaturaXml.DocumentText         = dosyaIcerik.StartsWith("<?xml version=\"1.0\"") ? dosyaIcerik : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + dosyaIcerik;
                wbFaturaHtml.DocumentText        = Utils.Utils.Invoice2Html(dosyaIcerik, Utils.Utils.InvoiceRenderMode.Custom);
                wbGibFaturaGorunumu.DocumentText = Utils.Utils.Invoice2Html(dosyaIcerik, Utils.Utils.InvoiceRenderMode.GIB);
                wbSignatureXml.DocumentText      = Utils.Utils.GetSignatureXmlFromInvoice(dosyaIcerik);

                var validationResult = SignatureValidationUtil.ValidateSignatureFromXml(dosyaIcerik);

                lblImzaDorulamaSonucudata.Text      = validationResult.SignatureValidationResult.ResultText;
                lblImzaDorulamaSonucudata.ForeColor = validationResult.SignatureValidationResult.Successful ? Color.Green : Color.Red;
                lblImzalamaZamani.Text = validationResult.SignatureInfo.SigningTime.ToString();
                lblUBLVersiyonNo.Text  = validationResult.SignatureInfo.UBLVersionID;

                dataGridCertControl.DataSource = validationResult.CertificateValidationResult.ValidationResultList;
            }
            else
            {
            }
        }
        public IActionResult Post([FromBody] NoahEvent noahEvent)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string body = "";
                    Request.EnableRewind();
                    using (var reader = new StreamReader(Request.Body))
                    {
                        Request.Body.Seek(0, SeekOrigin.Begin);
                        body = reader.ReadToEnd();
                    }

                    string signatureFromHeader          = Request.Headers["X-Hub-Signature"].FirstOrDefault();
                    string originFromHeader             = Request.Headers["X-Hub-Origin"].FirstOrDefault();
                    string transmissionAtemptFromHeader = Request.Headers["X-Hub-TransmissionAtempt"].FirstOrDefault();

                    string sharedSecret = _settings.WebHookSharedSecret; // "keepmesafe";

                    bool isSignatureValid = SignatureValidationUtil.ValidateSignature(body, signatureFromHeader, sharedSecret);

                    if (isSignatureValid == false)
                    {
                        _logger.LogError($"Noah Event Recieved was rejected - invalid signature, TenantId: {noahEvent.TenantId}, NotificationEventId: {noahEvent.NotificationEventId}, SignatureFromHeader: {signatureFromHeader}");
                        return(Unauthorized());
                    }

                    _noahEventQueue.Enqueue(noahEvent);
                    _logger.LogInformation($"Noah Event Recieved OK, TenantId: {noahEvent.TenantId}, NotificationEventId: {noahEvent.NotificationEventId}");
                    return(Ok());
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, $"Noah Event Recieved Unable to process incoming event, TenantId: {noahEvent.TenantId}, NotificationEventId: {noahEvent.NotificationEventId}");
                    return(BadRequest("Unable to process incoming event"));
                }
            }
            else
            {
                _logger.LogError($"Noah Event Recieved Invalid Message, TenantId: {noahEvent.TenantId}, NotificationEventId: {noahEvent.NotificationEventId}");
                return(BadRequest(ModelState));
            }
        }