Beispiel #1
0
        private void ShowDecryptDataUI()
        {
            DecryptDataRequestDto decryptDataRequestDto = new DecryptDataRequestDto();

            try
            {
                Console.WriteLine("=====================Request building start======================");
                decryptDataRequestDto.BillingLabel          = Read_String_Input("Enter BillingLabel:", true);
                decryptDataRequestDto.CustomerTransactionID = Read_String_Input("Enter CustomerTransactionID:", true);
                decryptDataRequestDto.CustomerCode          = Read_String_Input("Enter CustomerCode:", false);
                decryptDataRequestDto.Username              = Read_String_Input("Enter UserName:"******"Enter Password:"******"Enter EncryptedData:", false);
                decryptDataRequestDto.KSN                   = Read_String_Input("Enter KSN:", false);
                decryptDataRequestDto.KeyType               = Read_KeyType_Input("Enter KeyType:");
                decryptDataRequestDto.AdditionalRequestData = Read_MultipleKeysInput("AdditionalRequestData");
                var svc    = _serviceProvider.GetService <IDecryptV3Client>();
                var result = svc.DecryptData(decryptDataRequestDto).Result;
                if ((result.Response != null) && (result.SoapDetails != null))
                {
                    Console.WriteLine("=====================Response Start======================");
                    Console.WriteLine("Request:");
                    Console.Write(PrettyXml(result.SoapDetails.RequestXml) + "\n");
                    Console.WriteLine("Response:");
                    Console.Write(PrettyXml(result.SoapDetails.ResponseXml) + "\n");
                    Console.WriteLine("=====================Response End======================");
                    Console.WriteLine("=====================Parsed Response Start======================");
                    Console.WriteLine(result.Response.ToString());
                    Console.WriteLine("=====================Parsed Response End======================");
                }
                else
                {
                    Console.WriteLine("Response is null, Please check with input values given and try again");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error while DecryptData : " + ex.Message.ToString());
            }
        }
Beispiel #2
0
        private async void btn_Process_Click(object sender, RoutedEventArgs e)
        {
            DecryptDataRequestDto decryptDataRequestDto = new DecryptDataRequestDto();

            try
            {
                decryptDataRequestDto.BillingLabel          = txt_billinglabel.Text;
                decryptDataRequestDto.CustomerTransactionID = txt_customerTransactionId.Text;
                decryptDataRequestDto.CustomerCode          = txt_Customercode.Text;
                decryptDataRequestDto.Password = txt_Password.Password;
                decryptDataRequestDto.Username = txt_Username.Text;
                var encrypteddata = txt_EncryptedData.Text;
                decryptDataRequestDto.EncryptedData         = encrypteddata;
                decryptDataRequestDto.KSN                   = txt_KSn.Text;
                decryptDataRequestDto.KeyType               = txt_KeyType.Text;
                decryptDataRequestDto.AdditionalRequestData = new List <KeyValuePair <string, string> >();
                foreach (var item in _additionalRequestData)
                {
                    var temp = new KeyValuePair <string, string>(item.Key, item.Value);
                    decryptDataRequestDto.AdditionalRequestData.Add(temp);
                }

                var validator = new DecryptDataRequestDtoValidator();
                var results   = validator.Validate(decryptDataRequestDto);
                if (!results.IsValid)
                {
                    var errorMsg = string.Empty;
                    var failures = results.Errors.ToList();
                    failures.ForEach(x => errorMsg = errorMsg + x + Environment.NewLine);
                    MessageBox.Show(errorMsg, "Validation Failure");
                }
                else
                {
                    IServiceCollection services = new ServiceCollection();
                    IConfiguration     config   = new ConfigurationBuilder().AddJsonFile("appsettings.json", true, true).Build();
                    services.AddSingleton <IConfiguration>(config);
                    services.AddSingleton <IDecryptV3Client, DecryptV3Client>();
                    if (config.GetValue <string>("CERTIFICATE_FILENAME").Trim() == "")
                    {
                        MessageBox.Show("Certificate FileName Not Found In appsettings.json");
                    }
                    else if (config.GetValue <string>("CERTIFICATE_PASSWORD").Trim() == "")
                    {
                        MessageBox.Show("Certificate Password Not Found In appsettings.json");
                    }
                    else
                    {
                        IServiceProvider serviceProvider = services.BuildServiceProvider();
                        var svc    = serviceProvider.GetService <IDecryptV3Client>();
                        var result = await svc.DecryptData(decryptDataRequestDto);

                        if ((result.Response != null) && (result.SoapDetails != null))
                        {
                            txt_Response.Text = result.Response.ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                txt_Response.Text = "Error while DecryptData : " + ex.Message.ToString();
            }
        }