Exemple #1
0
        static void Main(string[] args)
        {
            // Setup Log4Net configuration by loading it from configuration file.
            // log4net is not necessary and is only being used for demonstration.
            XmlConfigurator.Configure();

            // To ensure that the WSP is up and running.
            Thread.Sleep(1000);

            // Retrieve token
            IStsTokenService tokenService = new StsTokenServiceCache(TokenServiceConfigurationFactory.CreateConfiguration());
            var securityToken             = tokenService.GetToken();

            // Call WSP with token
            var client = new HelloWorldClient();
            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(securityToken);

            Console.WriteLine(channelWithIssuedToken.HelloNone("Schultz")); // Even if the protection level is set to 'None' Digst.OioIdws.Wsc ensures that the body is always at least signed.
            Console.WriteLine(channelWithIssuedToken.HelloSign("Schultz"));
            Console.WriteLine(channelWithIssuedToken.HelloEncryptAndSign("Schultz"));

            //Checking that SOAP faults can be read.SOAP faults are encrypted in Sign and EncryptAndSign mode if no special care is taken.
            try
            {
                channelWithIssuedToken.HelloSignError("Schultz");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadKey();
        }
Exemple #2
0
        private string RunSoap(SecurityToken bootstrapToken)
        {
            // Retrieve token
            IStsTokenService stsTokenService = new StsTokenServiceCache(TokenServiceConfigurationFactory.CreateConfiguration());
            SecurityToken    securityToken   = null;

            if (bootstrapToken != null)
            {
                securityToken = stsTokenService.GetTokenWithBootstrapToken(bootstrapToken);
            }
            else
            {
                securityToken = stsTokenService.GetToken();
            }

            // Call WSP with token
            var client = new HelloWorldClient();

            // enable revocation check if not white listed at Nets, don't do this in production!
            //client.ClientCredentials.ServiceCertificate.Authentication.RevocationMode = System.Security.Cryptography.X509Certificates.X509RevocationMode.NoCheck;

            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(securityToken);

            return(channelWithIssuedToken.HelloSign("Oiosaml-net.dk TEST"));
        }
Exemple #3
0
        public void SoapRequestFailDueToHeaderToTamperingTest()
        {
            // Arrange
            _fiddlerApplicationOnBeforeRequest = delegate(Session oS)
            {
                // Only act on requests to WSP
                if (WspHostName != oS.hostname)
                {
                    return;
                }

                oS.utilReplaceInRequest("https://digst.oioidws.wsp:9090/HelloWorld</a:To>",
                                        "https://digst.oioidws.wsp:9090/HelloWorldTampered</a:To>");
            };
            FiddlerApplication.BeforeRequest += _fiddlerApplicationOnBeforeRequest;

            // Act
            var client = new HelloWorldClient();
            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(_stsTokenService.GetToken());

            try
            {
                channelWithIssuedToken.HelloSign("Schultz");
                Assert.IsTrue(false, "Expected exception was not thrown!!!");
            }
            catch (MessageSecurityException mse)
            {
                // Assert
                var fe = mse.InnerException as FaultException;
                Assert.IsNotNull(fe, "Expected inner fault exception");
                Assert.AreEqual("An error occurred when verifying security for the message.", fe.Message);
            }
        }
Exemple #4
0
    public static void Main()
    {
        // Picks up configuration from the config file.
        HelloWorldClient wcfClient = new HelloWorldClient();

        try
        {
            // Making calls.
            Console.WriteLine("Enter the greeting to send: ");
            string greeting = Console.ReadLine();
            Console.WriteLine("The service responded: " + wcfClient.SampleMethod(greeting));

            // Done with service.
            wcfClient.Close();
            Console.WriteLine("Done!");
        }
        catch (TimeoutException timeProblem)
        {
            Console.WriteLine("The service operation timed out. " + timeProblem.Message);
            wcfClient.Abort();
        }
        catch (CommunicationException commProblem)
        {
            Console.WriteLine("There was a communication problem. " + commProblem.Message);
            wcfClient.Abort();
        }
        finally
        {
            Console.WriteLine("Press ENTER to exit:");
            Console.ReadLine();
        }
    }
Exemple #5
0
        static async Task Main(string[] args)
        {
            HelloWorldClient.Hello("Shahid");

            await CustomersMaintClient.CreateCustomers(2);

            var update = new UpdateCustomerRequest
            {
                Id        = "e3cf5ae6-d149-4b80-8bd8-aea03f2b0754",
                FirstName = "Shahid Ali",
                LastName  = "Khan",
                Address   = "Charsadda, Pakistan",
                Phone     = "123490000"
            };
            await CustomersMaintClient.UpdateCustomer(update);

            await CustomersMaintClient.GetAllCustomers();

            await CustomersMaintClient.DeleteCustomer("e3cf5ae6-d149-4b80-8bd8-aea03f2b0754");

            await CustomersMaintClient.GetAllCustomers();

            await CustomersMaintClient.DeleteAllCustomers();

            await CustomersMaintClient.GetAllCustomers();

            await CustomersMaintClient.CreateCustomers(10);

            await CustomersMaintClient.GetAllCustomers();

            Console.ReadLine();
        }
        public void SoapRequestExpiredTest()
        {
            // Arrange
            _fiddlerApplicationOnBeforeRequest = delegate(Session oS)
            {
                // Only act on requests to WSP
                if (WspHostName != oS.hostname)
                {
                    return;
                }

                Thread.Sleep(_wait);
            };
            FiddlerApplication.BeforeRequest += _fiddlerApplicationOnBeforeRequest;

            var client = new HelloWorldClient();
            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(_stsTokenService.GetToken());

            // Act
            try
            {
                channelWithIssuedToken.HelloSign("Schultz");
                Assert.IsTrue(false, "Expected exception was not thrown!!!");
            }
            catch (MessageSecurityException mse)
            {
                // Assert
                var fe = mse.InnerException as FaultException;
                Assert.IsNotNull(fe, "Expected inner fault exception");
                Assert.AreEqual("An error occurred when verifying security for the message.", fe.Message);
            }
        }
Exemple #7
0
        static void Main(string[] args)
        {
            HelloWorldClient client = new HelloWorldClient("BasicHttpBinding_IHelloWorld");
            string           result = client.SayHello();

            System.Console.WriteLine(result);
            System.Console.ReadLine();
        }
Exemple #8
0
 static void Main(string[] args)
 {
     HelloWorldClient client = new HelloWorldClient("NetTcpBinding_IHelloWorld");
     Name person = new Name();
     person.First = "Eyebe";
     person.Last = "Yespapi";
     Console.WriteLine(client.SayHello(person));
     Console.ReadLine();
 }
Exemple #9
0
 static void Main(string[] args)
 {
     HelloWorldClient client = new HelloWorldClient("BasicHttpBinding_IHelloWorld");
     Name person = new Name();
     person.First = "Jay";
     person.Last = "Lars";
     Console.WriteLine(client.SayHello(person));
     Console.ReadLine();
 }
Exemple #10
0
        static void Main(string[] args)
        {
            HelloWorldClient client = new HelloWorldClient("BasicHttpBinding_IHelloWorld");
            Name             person = new Name();

            person.FirstName = "Julius";
            person.LastName  = "Bacosa";
            Console.WriteLine(client.SayHello(person));
            Console.ReadLine();
        }
Exemple #11
0
        static void Main(string[] args)
        {
            HelloWorldClient client = new HelloWorldClient("WSHttpBinding_IHelloWorld");
            Name             person = new Name();

            person.First = "John";
            person.Last  = "MUtabazi";
            Console.WriteLine(client.SayHello(person));
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            HelloWorldClient client = new HelloWorldClient("BasicHttpBinding_IHelloWorld");
            Name             person = new Name();

            person.First = "Christopher";
            person.Last  = "Tan";
            Console.WriteLine(client.SayHello(person));
            Console.ReadKey();
        }
Exemple #13
0
        static void Main(string[] args)
        {
            HelloWorldClient client = new HelloWorldClient("NetTcpBinding_IHelloWorld");
            Name             person = new Name();

            person.First = "Howard";
            person.Last  = "Zhou";
            Console.WriteLine(client.SayHello(person));
            Console.ReadLine();
        }
Exemple #14
0
        static void Main(string[] args)
        {
            HelloWorldClient worldClient = new HelloWorldClient("WSHttpBinding_IHelloWorld");
            string           notes       = worldClient.GetWelcomeNotesAsync().Result;

            //HelloWorldClient helloWorld = new HelloWorldClient("WSHttpBinding_IHelloWorld1");
            //string notes1 = helloWorld.GetWelcomeNotesAsync().Result;

            //HelloWorldClient helloWorldClient = new HelloWorldClient("WSHttpBinding_IHelloWorld1");
            //string notes2 = helloWorldClient.GetWelcomeNotesAsync().Result;
        }
        static void Main(string[] args)
        {
            // initializing the client proxy will initialize necessary channel too.
            HelloWorldClient client = new HelloWorldClient("NetTcpBinding_IHelloWorld");
            Name             person = new Name();

            person.First = "Mohit";
            person.Last  = "Sharma";

            Console.WriteLine(client.SayHello(person));
            Console.ReadLine();
        }
Exemple #16
0
        public void TotalFlowNoneSucessTest()
        {
            // Arrange
            var client = new HelloWorldClient();
            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(_stsTokenService.GetToken());

            // Act
            var response = channelWithIssuedToken.HelloNone("Schultz");

            // Assert
            Assert.IsTrue(response.StartsWith("Hello"));
        }
Exemple #17
0
        public void HelloNull()
        {
            // initialize
            string userName = null;
            string expectedResult = "Hello ";
            string realResult;
            HelloWorldClient myService = new HelloWorldClient();

            // test body
            realResult = myService.SayHello(userName);

            // assert
            Assert.AreEqual(expectedResult, realResult);
        }
Exemple #18
0
        public void SoapRequestFailDueToHeaderSecurityTamperingTest()
        {
            // Arrange

            _fiddlerApplicationOnBeforeRequest = delegate(Session oS)
            {
                // Only act on requests to WSP
                if (WspHostName != oS.hostname)
                {
                    return;
                }

                // Use xml version instead of utilReplaceInRequest(...) because message id is dynamically
                var bodyAsString     = Encoding.UTF8.GetString(oS.RequestBody);
                var bodyAsXml        = XDocument.Load(new StringReader(bodyAsString));
                var namespaceManager = new XmlNamespaceManager(new NameTable());
                namespaceManager.AddNamespace("s", "http://www.w3.org/2003/05/soap-envelope");
                namespaceManager.AddNamespace("o",
                                              "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
                namespaceManager.AddNamespace("u",
                                              "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
                var createdTimestampElement =
                    bodyAsXml.XPathSelectElement("/s:Envelope/s:Header/o:Security/u:Timestamp/u:Created",
                                                 namespaceManager);
                var dateTime       = DateTime.Parse(createdTimestampElement.Value);
                var addMinutes     = dateTime.AddMinutes(1);
                var longDateString = addMinutes.ToUniversalTime().ToString(TimeFormat);
                createdTimestampElement.Value = longDateString;
                oS.RequestBody = Encoding.UTF8.GetBytes(bodyAsXml.ToString(SaveOptions.DisableFormatting));
            };
            FiddlerApplication.BeforeRequest += _fiddlerApplicationOnBeforeRequest;

            // Act
            var client = new HelloWorldClient();
            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(_stsTokenService.GetToken());

            try
            {
                channelWithIssuedToken.HelloSign("Schultz");
                Assert.IsTrue(false, "Expected exception was not thrown!!!");
            }
            catch (MessageSecurityException mse)
            {
                // Assert
                var fe = mse.InnerException as FaultException;
                Assert.IsNotNull(fe, "Expected inner fault exception");
                Assert.IsTrue(fe.Message.StartsWith("An error occurred when verifying security for the message."));
            }
        }
Exemple #19
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Enter First Name:");
            string firstname = Console.ReadLine();

            Console.WriteLine("Enter Last Name:");
            string lastName = Console.ReadLine();

            HelloWorldClient client = new HelloWorldClient("NetTcpBinding_IHelloWorld");
            Name myName = new Name() { FirstName = firstname, LastName = lastName };
            Console.WriteLine("Sending Service Request ...");
            Console.WriteLine(client.SayHelloAsync(myName).Result);
            client.Close();
            Console.ReadLine();
        }
        public void HelloDearUser()
        {
            //initialize
            string username = "******";
            string expectedResult = "Hello Dear User";
            string realResult;
            HelloWorldClient myservice = new HelloWorldClient();

            //test body
            realResult = myservice.SayHello(username);

            //assert
            Assert.AreEqual(expectedResult, realResult);

                }
Exemple #21
0
        public void SoapRequestFailDueToTokenTamperingTest()
        {
            // Arrange

            _fiddlerApplicationOnBeforeRequest = delegate(Session oS)
            {
                // Only act on requests to WSP
                if (WspHostName != oS.hostname)
                {
                    return;
                }

                // Use xml version instead of utilReplaceInRequest(...) because message id is dynamically
                var bodyAsString     = Encoding.UTF8.GetString(oS.RequestBody);
                var bodyAsXml        = XDocument.Load(new StringReader(bodyAsString));
                var namespaceManager = new XmlNamespaceManager(new NameTable());
                namespaceManager.AddNamespace("s", "http://www.w3.org/2003/05/soap-envelope");
                namespaceManager.AddNamespace("o",
                                              "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
                namespaceManager.AddNamespace("u", "urn:oasis:names:tc:SAML:2.0:assertion");
                namespaceManager.AddNamespace("xenc", "http://www.w3.org/2001/04/xmlenc#");
                var cipherValueElement =
                    bodyAsXml.XPathSelectElement(
                        "/s:Envelope/s:Header/o:Security/u:EncryptedAssertion/xenc:EncryptedData/xenc:CipherData/xenc:CipherValue",
                        namespaceManager);
                cipherValueElement.Value =
                    "caOITLZYC9wHy4gxMdtxoYjYY9V2t3Jj5ZT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JtarWowJZVYVYGUbcyNcXxLII5VWz3Q6lWRV1h3IWixGtuU8IzxoHT8F1ECyS1Dcx3QJ8w3Ksw6PCnd3byfKAj2POu+qfGM6FOO52QAWViqOyDks2AoDfPmp8p91FMrvyWy0No/Mg2a83CSByxzvnXvMht0ekzacBRfROMz1mwqX7/kMDsqBSLugoOyptGfTnWojezaijWXkRYyZj4maK/SzQKm4ks4yFqTiV1OlPA8v058q21tleIEMefCqKLp5bJMffYVZal5bpUCESr2l4HCDCCGQX0BtRdQ2GrxTbffQCfnQ9Iq0YjW9TLJCowJKhS0uOORYplr0jWqXz/w5CwSyjM7JbsLIjZ0r/Au413tTOUucyz5ZvboSwlzcJ6O0R5VulIdcOlgjVeEFJn8sdawn11H6qo3Uf2zIrEX5KlsntuS8KlLgKF3n6r4d5EXlNMBYfBZntzHFF0JqOs/5RAtil6+E1VpSyUZRxA==";
                oS.RequestBody = Encoding.UTF8.GetBytes(bodyAsXml.ToString(SaveOptions.DisableFormatting));
            };
            FiddlerApplication.BeforeRequest += _fiddlerApplicationOnBeforeRequest;

            // Act
            var client = new HelloWorldClient();
            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(_stsTokenService.GetToken());

            try
            {
                channelWithIssuedToken.HelloSign("Schultz");
                Assert.IsTrue(false, "Expected exception was not thrown!!!");
            }
            catch (MessageSecurityException mse)
            {
                // Assert
                var fe = mse.InnerException as FaultException;
                Assert.IsNotNull(fe, "Expected inner fault exception");
                Assert.IsTrue(fe.Message.StartsWith("An error occurred when verifying security for the message."));
            }
        }
Exemple #22
0
        public void HelloDearUser()
        {
            //init
            string           userName       = null;
            string           expectedResult = "Hello Dear User";
            string           realResult;
            HelloWorldClient myService = new HelloWorldClient();


            //test body
            realResult = myService.SayHello(userName);


            //assert
            Assert.AreEqual(expectedResult, realResult);
        }
Exemple #23
0
        static void Main(string[] args)
        {
            var client = new HelloWorldClient("BasicHttpBinding_IHelloWorld");

            var name = new Name();

            Console.Write("Firstname: ");
            name.FName = Console.ReadLine();
            Console.Write("Lastname: ");
            name.LName = Console.ReadLine();

            Console.WriteLine(client.SayHello(name));

            Console.WriteLine();

            Console.ReadKey();
        }
Exemple #24
0
        public void TotalFlowNoneSoapFaultSucessTest()
        {
            // Arrange
            var client = new HelloWorldClient();
            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(_stsTokenService.GetToken());

            // Act
            try
            {
                channelWithIssuedToken.HelloNoneError("Schultz");
            }
            catch (Exception e)
            {
                // Assert
                Assert.IsTrue(e.Message.StartsWith("Hello"));
            }
        }
        public void SoapResponseExpiredTest()
        {
            // Arrange
            _fiddlerApplicationOnBeforeRequest = delegate(Session oS)
            {
                // Only act on requests to WSP
                if (WspHostName != oS.hostname)
                {
                    return;
                }

                // it not set then Thread.Sleep is ignored on the response.
                oS.bBufferResponse = true;
            };
            FiddlerApplication.BeforeRequest += _fiddlerApplicationOnBeforeRequest;

            _fiddlerApplicationOnBeforeResponse = delegate(Session oS)
            {
                // Only act on requests to WSP
                if (WspHostName != oS.hostname)
                {
                    return;
                }

                Thread.Sleep(_wait);
            };
            FiddlerApplication.BeforeResponse += _fiddlerApplicationOnBeforeResponse;

            var client = new HelloWorldClient();
            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(_stsTokenService.GetToken());

            // Act
            try
            {
                channelWithIssuedToken.HelloSign("Schultz");
                Assert.IsTrue(false, "Expected exception was not thrown!!!");
            }
            catch (MessageSecurityException mse)
            {
                // Assert
                Assert.IsTrue(mse.Message.StartsWith("The security timestamp is stale because its expiration time"));
            }
        }
Exemple #26
0
        public void SoapRequestFailDueToReplayAttackTest()
        {
            // Arrange
            byte[] recordedRequest = null;
            _fiddlerApplicationOnBeforeRequest = delegate(Session oS)
            {
                // Only act on requests to WSP
                if (WspHostName != oS.hostname)
                {
                    return;
                }
                if (recordedRequest == null)
                {
                    // record request
                    recordedRequest = oS.RequestBody;
                }
                else
                {
                    // Replay
                    oS.RequestBody = recordedRequest;
                }
            };
            FiddlerApplication.BeforeRequest += _fiddlerApplicationOnBeforeRequest;

            var client = new HelloWorldClient();
            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(_stsTokenService.GetToken());

            channelWithIssuedToken.HelloSign("Schultz");

            // Act
            try
            {
                channelWithIssuedToken.HelloSign("Schultz");
                Assert.IsTrue(false, "Expected exception was not thrown!!!");
            }
            catch (MessageSecurityException mse)
            {
                // Assert
                var fe = mse.InnerException as FaultException;
                Assert.IsNotNull(fe, "Expected inner fault exception");
                Assert.IsTrue(fe.Message.StartsWith("An error occurred when verifying security for the message."));
            }
        }
Exemple #27
0
        public void SoapRequestSucceedNoLibertyHeaderTest()
        {
            var soap12 = "http://www.w3.org/2003/05/soap-envelope";

            var noLibHead = false;

            _fiddlerApplicationOnBeforeRequest = delegate(Session oS)
            {
                // Only act on requests to WSP
                if (WspHostName != oS.hostname)
                {
                    return;
                }

                // Use xml version instead of utilReplaceInRequest(...)
                // because message id is dynamically
                var bodyAsString     = Encoding.UTF8.GetString(oS.RequestBody);
                var bodyAsXml        = XDocument.Load(new StringReader(bodyAsString));
                var namespaceManager = new XmlNamespaceManager(new NameTable());
                namespaceManager.AddNamespace("s", soap12);
                // If we can't find the Liberty Header, it's because it's no
                // longer part of the SOAP 1.2 message
                var frameworkElement =
                    bodyAsXml.XPathSelectElement(
                        "/s:Envelope/s:Header/Framework",
                        namespaceManager
                        );
                noLibHead = (null == frameworkElement);
            };
            FiddlerApplication.BeforeRequest +=
                _fiddlerApplicationOnBeforeRequest;

            // Act
            var client = new HelloWorldClient();
            var channelWithIssuedToken =
                client.ChannelFactory.CreateChannelWithIssuedToken(
                    _stsTokenService.GetToken()
                    );

            channelWithIssuedToken.HelloSign("Schultz");
            Assert.IsTrue(noLibHead, "Succeed with no Liberty header.");
        }
Exemple #28
0
        public void SoapRequestSucceedIsSoap12Test()
        {
            var soap12 = "http://www.w3.org/2003/05/soap-envelope";

            var isSoap12 = false;

            _fiddlerApplicationOnBeforeRequest = delegate(Session oS)
            {
                // Only act on requests to WSP
                if (WspHostName != oS.hostname)
                {
                    return;
                }

                // Use xml version instead of utilReplaceInRequest(...)
                // because message id is dynamically
                var bodyAsString     = Encoding.UTF8.GetString(oS.RequestBody);
                var bodyAsXml        = XDocument.Load(new StringReader(bodyAsString));
                var namespaceManager = new XmlNamespaceManager(new NameTable());
                namespaceManager.AddNamespace("s", soap12);
                // If we can find the root element, it's because the namespace
                // of SOAP 1.2 matches
                var envelopeElement =
                    bodyAsXml.XPathSelectElement(
                        "/s:Envelope",
                        namespaceManager
                        );
                isSoap12 = (null != envelopeElement);
            };
            FiddlerApplication.BeforeRequest +=
                _fiddlerApplicationOnBeforeRequest;

            // Act
            var client = new HelloWorldClient();
            var channelWithIssuedToken =
                client.ChannelFactory.CreateChannelWithIssuedToken(
                    _stsTokenService.GetToken()
                    );

            channelWithIssuedToken.HelloSign("Schultz");
            Assert.IsTrue(isSoap12, "Succeed with a valid SOAP 1.2 header.");
        }
        public void TotalFlowTokenExpiredTest()
        {
            // Arrange
            var client = new HelloWorldClient();
            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(_stsTokenService.GetToken());

            // Act
            try
            {
                Thread.Sleep(_wait);
                channelWithIssuedToken.HelloSign("Schultz");
                Assert.IsTrue(false, "Expected exception was not thrown!!!");
            }
            catch (MessageSecurityException mse)
            {
                // Assert
                var fe = mse.InnerException as FaultException;
                Assert.IsNotNull(fe, "Expected inner fault exception");
                Assert.AreEqual("At least one security token in the message could not be validated.", fe.Message);
            }
        }
        public void TestSayHelloEmptyName()
        {
            // Tres partes de las pruebas unitarias.
            //--------------------------------------/////////
            // 1. Preparar el escenario
            string myName = string.Empty;
            string resultadoEsperado = "Hello world";
            string resultadoReal;
            HelloWorldClient client = new HelloWorldClient();

            // 2. Invoco al metodo correspondiente
            resultadoReal = client.SayHello(myName);


            // 3. Comparacion de resultados, Todos los resultados se van por Assert
            Assert.AreEqual(resultadoEsperado, resultadoReal,
              string.Format(
              mensajeAssert,
              resultadoEsperado.ToString(), resultadoReal.ToString())
              );
        }
        static void Main(string[] args)
        {
            var service = new HelloWorldClient("BasicHttp");

            Console.WriteLine("Enter your first name.");
            var first = Console.ReadLine();

            Console.WriteLine("Enter your last name.");
            var last    = Console.ReadLine();
            var NewName = new Name()
            {
                FirstName = first, LastName = last
            };

            Console.WriteLine("Loading...");
            var greeting = service.Hello(NewName);

            Console.Clear();
            Console.WriteLine(greeting);
            Console.ReadKey();
        }
Exemple #32
0
        public void SoapRequestFailDueToHeaderMessageIdTamperingTest()
        {
            // Arrange
            _fiddlerApplicationOnBeforeRequest = delegate(Session oS)
            {
                // Only act on requests to WSP
                if (WspHostName != oS.hostname)
                {
                    return;
                }

                // Use xml version instead of utilReplaceInRequest(...) because message id is dynamically
                var bodyAsString     = Encoding.UTF8.GetString(oS.RequestBody);
                var bodyAsXml        = XDocument.Load(new StringReader(bodyAsString));
                var namespaceManager = new XmlNamespaceManager(new NameTable());
                namespaceManager.AddNamespace("s", "http://www.w3.org/2003/05/soap-envelope");
                namespaceManager.AddNamespace("a", "http://www.w3.org/2005/08/addressing");
                var messageIdElement = bodyAsXml.XPathSelectElement("/s:Envelope/s:Header/a:MessageID", namespaceManager);
                messageIdElement.Value = "urn:uuid:0e07468e-42b2-4813-b837-6c2c6122a9c9";
                oS.RequestBody         = Encoding.UTF8.GetBytes(bodyAsXml.ToString(SaveOptions.DisableFormatting));
            };
            FiddlerApplication.BeforeRequest += _fiddlerApplicationOnBeforeRequest;

            // Act
            var client = new HelloWorldClient();
            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(_stsTokenService.GetToken());

            try
            {
                channelWithIssuedToken.HelloSign("Schultz");
                Assert.IsTrue(false, "Expected exception was not thrown!!!");
            }
            catch (MessageSecurityException mse)
            {
                // Assert
                var fe = mse.InnerException as FaultException;
                Assert.IsNotNull(fe, "Expected inner fault exception");
                Assert.AreEqual("An error occurred when verifying security for the message.", fe.Message);
            }
        }
Exemple #33
0
        public static IHelloWorld CreateInstance(HelloWorldClient client, string connectionString)
        {
            HelloWorldRepository repository = new HelloWorldRepository(connectionString);

            switch (client)
            {
            case HelloWorldClient.CONSOLE:
                return(new HelloWorldConsole(repository));

            case HelloWorldClient.WEB:
                return(new HelloWorldWeb(repository));

            case HelloWorldClient.MOBILE:
                return(new HelloWorldMobile(repository));

            case HelloWorldClient.WIN_SERVICE:
                return(new HelloWorldWinService(repository));

            default:
                throw new NotImplementedException(string.Format("Unknown Client : {0} ", client));
            }
        }
Exemple #34
0
        private static async void Execute()
        {
            var hwClient      = new HelloWorldClient("NetTcpBinding_IHelloWorld");
            var invoiceClient = new InvoiceServiceClient("BasicHttpBinding_IInvoiceService");

            var person = new Person
            {
                FirstName = "Lucas",
                LastName  = "Amorim"
            };

            var responseHello = await hwClient.SayHelloAsync(person);

            Console.WriteLine(responseHello);

            var responseBye = await hwClient.SayByeAsync(person);

            Console.WriteLine(responseBye);

            var invoice = new Invoice
            {
                CustomerId  = "cus_AAA",
                InvoiceDate = DateTime.Now
            };

            await invoiceClient.SubmitInvocieAsync(invoice);

            Console.WriteLine("Invoice submmitted");

            var responseGetInvoices = await invoiceClient.GetInvoicesAsync();

            foreach (var item in responseGetInvoices)
            {
                Console.WriteLine(item.CustomerId + " " + item.InvoiceDate + " " + item.ExtensionData);
            }
        }
Exemple #35
0
        public void SoapRequestSucceedIsOasisSamlToken11Test()
        {
            var soap12 = "http://www.w3.org/2003/05/soap-envelope";
            var wsse00 = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
            var wsse11 = "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd";

            var oasisSamlToken11 = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0";

            var isOasisSamlToken11 = false;

            _fiddlerApplicationOnBeforeRequest = delegate(Session oS)
            {
                // Only act on requests to WSP
                if (WspHostName != oS.hostname)
                {
                    return;
                }

                // Use xml version instead of utilReplaceInRequest(...)
                // because message id is dynamically
                var bodyAsString     = Encoding.UTF8.GetString(oS.RequestBody);
                var bodyAsXml        = XDocument.Load(new StringReader(bodyAsString));
                var namespaceManager = new XmlNamespaceManager(new NameTable());
                namespaceManager.AddNamespace("s", soap12);
                namespaceManager.AddNamespace("o", wsse00);
                namespaceManager.AddNamespace("b", wsse11);
                // If we can't find the Liberty Header, it's because it's no
                // longer part of the SOAP 1.2 message
                var tokenElement =
                    bodyAsXml.XPathSelectElement(
                        "/s:Envelope/s:Header/o:Security/o:SecurityTokenReference",
                        namespaceManager
                        );
                if (null != tokenElement)
                {
                    XNamespace lns       = wsse11;
                    var        tokenType =
                        tokenElement
                        .Attributes(lns + "TokenType")
                        .First();

                    if (null != tokenType)
                    {
                        isOasisSamlToken11 =
                            tokenType.Value.Equals(oasisSamlToken11);
                    }
                }
            };
            FiddlerApplication.BeforeRequest +=
                _fiddlerApplicationOnBeforeRequest;

            // Act
            var client = new HelloWorldClient();
            var channelWithIssuedToken =
                client.ChannelFactory.CreateChannelWithIssuedToken(
                    _stsTokenService.GetToken()
                    );

            channelWithIssuedToken.HelloSign("Schultz");
            Assert.IsTrue(
                isOasisSamlToken11,
                "Succeed with a OASIS SAML Token 1.1 profile."
                );
        }
Exemple #36
0
 public HelloWorldBase(HelloWorldRepository repository, HelloWorldClient client)
 {
     this.client     = client;
     this.repository = repository;
 }