示例#1
0
        public void Net2JavaAddressedLTLevelInSteps()
        {
            String text = "This is a secret message from Alice for Bob written at " + DateTime.Now.ToString();

            var tsa = new TimeStampAuthorityClient(new StsBinding(), new EndpointAddress("https://services-acpt.ehealth.fgov.be/TimestampAuthority/v2"));

            tsa.Endpoint.Behaviors.Remove <ClientCredentials>();
            tsa.Endpoint.Behaviors.Add(new OptClientCredentials());
            tsa.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "566fd3fe13e3ab185a7224bcec8ad9cffbf9e9c2");

            IDataSealer sealer = EidDataSealerFactory.Create(Level.B_Level);
            Stream      msg    = sealer.Seal(new MemoryStream(Encoding.UTF8.GetBytes(text)), new EncryptionToken(Utils.ReadFully(GetAbsoluteTestFilePath("bob/bobs_public_key.etk"))));

            IDataCompleter completer = DataCompleterFactory.Create(Level.LT_Level, new EHealthTimestampProvider(tsa));
            Stream         msg2      = completer.Complete(msg);

            FileStream msgFile = new FileStream(GetAbsoluteTestFilePath("message_to_bob.msg"), FileMode.OpenOrCreate);

            using (msgFile)
            {
                msg2.CopyTo(msgFile);
            }

            String output = RunJava("etee.crypto.test.Unseal MANDATORY");

            Assert.IsTrue(output.Contains(text));
        }
示例#2
0
        private Stream Complete(Stream toComplete)
        {
            IDataCompleter completer = DataCompleterFactory.Create(level.Value, tsa);
            Stream         output    = completer.Complete(toComplete);

            return(output);
        }
示例#3
0
        private Stream Complete(Stream toComplete)
        {
            IDataCompleter completer;

            if (useTmaInsteadOfTsa)
            {
                completer = DataCompleterFactory.CreateForTimeMarkAuthority(level.Value);
            }
            else
            {
                completer = DataCompleterFactory.Create(level.Value, tsa);
            }
            Stream output = completer.Complete(toComplete);

            return(output);
        }