Esempio n. 1
0
        public void FormatPkpTest()
        {
            var pkpString = @"AA==";
            var pkpBytes  = Convert.FromBase64String(pkpString);

            Assert.AreEqual(pkpString, EetRegisterRequest.FormatPkp(pkpBytes));
        }
Esempio n. 2
0
        /*
         *  <Data dic_popl="CZ1212121218" id_provoz="1" id_pokl="POKLADNA01" porad_cis="1" dat_trzby="2016-06-30T08:43:28+02:00" celk_trzba="100.00" rezim="0"/>
         *  <pkp cipher="RSA2048" digest="SHA256" encoding="base64">Ddk2WTYu8nzpQscH7t9n8cBsGq4k/ggCwdfkPjM+gHUHPL8P7qmnWofzeW2pAekSSmOClBjF141yN+683g0aXh6VvxY4frBjYhy4XB506LDykIW0oAv086VH7mR0utA8zGd7mCI55p3qv1M/oog/2yG0DefD5mtHIiBG7/n7jgWbROTatJPQYeQWEXEoOJh9/gAq2kuiK3TOYeGeHwOyFjM2Cy3UVal8E3LwafP49kmGOWjHG+cco0CRXxOD3b8y4mgBqTwwC4V8e85917e5sVsaEf3t0hwPkag+WM1LIRzW+QwkkgiMEwoIqCAkhoF1eq/VcsML2ZcrLGejAeAixw==</pkp>
         *  <bkp digest="SHA1" encoding="base16">AC502107-1781EEE4-ECFD152F-2ED08CBA-E6226199</bkp>
         */
        public static async Task SignAndSend()
        {
            EetRegisterRequest data = EetRegisterRequest.Builder()
                                      .SetDicPopl("CZ1212121218")
                                      .SetIdProvoz("1")
                                      .SetIdPokl("POKLADNA01")
                                      .SetPoradCis("1")
                                      .SetDatTrzby("2016-09-12T08:43:28+02:00")
                                      .SetCelkTrzba(100.0)
                                      .SetPkcs12(TestData._01000003)
                                      .SetPkcs12Password("eet")
                                      .SetRezim(0)
                                      .Build();

            if (data == null)
            {
                throw new Exception("failed - data null");
            }
            Console.WriteLine(@"business data created");

            string pkp         = EetRegisterRequest.FormatPkp(data.Pkp);
            string bkp         = EetRegisterRequest.FormatBkp(data.Bkp);
            string expectedPkp = "Ddk2WTYu8nzpQscH7t9n8cBsGq4k/ggCwdfkPjM+gHUHPL8P7qmnWofzeW2pAekSSmOClBjF141yN+683g0aXh6VvxY4frBjYhy4XB506LDykIW0oAv086VH7mR0utA8zGd7mCI55p3qv1M/oog/2yG0DefD5mtHIiBG7/n7jgWbROTatJPQYeQWEXEoOJh9/gAq2kuiK3TOYeGeHwOyFjM2Cy3UVal8E3LwafP49kmGOWjHG+cco0CRXxOD3b8y4mgBqTwwC4V8e85917e5sVsaEf3t0hwPkag+WM1LIRzW+QwkkgiMEwoIqCAkhoF1eq/VcsML2ZcrLGejAeAixw==";
            string expectedBkp = "AC502107-1781EEE4-ECFD152F-2ED08CBA-E6226199";

            if (!pkp.Equals(expectedPkp))
            {
                throw new Exception("failed - PKP differs");
            }
            if (!bkp.Equals(expectedBkp))
            {
                throw new Exception("failed - BKP differs");
            }
            Console.WriteLine(@"Codes validated");

            string signed = data.GenerateSoapRequest();

            Console.WriteLine(@"SOAP request created");

            //assertTrue(validateXmlDSig(signed, data.getCertificate()));
            string response = await data.SendRequestAsync(signed, "https://pg.eet.cz:443/eet/services/EETServiceSOAP/v3");

            //via local stunnel
            //string  response=data.SendRequest(signed, "http://127.0.0.1:27541/eet/services/EETServiceSOAP/v2");

            if (response.IndexOf("Potvrzeni fik=", StringComparison.Ordinal) < 0)
            {
                throw new ApplicationException("FIK not found in the response");
            }
            Console.WriteLine(@"FIK received:" + response.Substring(response.IndexOf("Potvrzeni fik=", StringComparison.Ordinal) + 15, 36));
        }