コード例 #1
0
ファイル: samplecli5.cs プロジェクト: stanasse/olive
    static void Run()
    {
        SymmetricSecurityBindingElement sbe =
            new SymmetricSecurityBindingElement();

        //sbe.IncludeTimestamp = false;
        //sbe.LocalClientSettings.DetectReplays = false;

        //X509SecurityTokenParameters p = new X509SecurityTokenParameters ();
        //sbe.EndpointSupportingTokenParameters.Endorsing.Add (p);
        sbe.ProtectionTokenParameters = new X509SecurityTokenParameters();
        sbe.ProtectionTokenParameters.InclusionMode = SecurityTokenInclusionMode.Never;
        sbe.SetKeyDerivation(false);
        sbe.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
        HttpTransportBindingElement hbe =
            new HttpTransportBindingElement();
        CustomBinding    binding = new CustomBinding(new XBE(), sbe, hbe);
        X509Certificate2 cert    = new X509Certificate2("test.pfx", "mono");
        X509Certificate2 cert2   = cert;      //new X509Certificate2 ("test2.cer");
        FooProxy         proxy   = new FooProxy(binding,
                                                new EndpointAddress(new Uri("http://localhost:8080"), new X509CertificateEndpointIdentity(cert2)));

        //proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
        proxy.ClientCredentials.ClientCertificate.Certificate = cert;
        proxy.Endpoint.Behaviors.Add(new StdErrInspectionBehavior());
        proxy.Open();
        Console.WriteLine(proxy.Echo(Message.CreateMessage(MessageVersion.Default, "http://tempuri.org/IFoo/Echo", "Request Input text.")));
    }
コード例 #2
0
        public void OpenBeforeDisplayInitializationUI()
        {
            var f = new FooProxy(new BasicHttpBinding(), new EndpointAddress("http://localhost:" + NetworkHelpers.FindFreePort()));

            f.Endpoint.Contract.Behaviors.Add(new MyContractBehavior());
            f.Open();
        }
コード例 #3
0
        public void CanRoundTripProxyToRegular()
        {
            var model = BuildModel();

            Foo foo = new Foo {
                Id = 1234, Name = "abcd"
            }, proxy = new FooProxy(foo), clone;

            Assert.IsNotNull(foo);
            Assert.IsNotNull(proxy);

            clone = (Foo)model.DeepClone(foo);
            CompareFoo(foo, clone, "Runtime/Foo");
            clone = (Foo)model.DeepClone(proxy);
            CompareFoo(proxy, clone, "Runtime/FooProxy");

            model.CompileInPlace();
            clone = (Foo)model.DeepClone(foo);
            CompareFoo(foo, clone, "CompileInPlace/Foo");
            clone = (Foo)model.DeepClone(proxy);
            CompareFoo(proxy, clone, "CompileInPlace/FooProxy");

            var compiled = model.Compile();

            clone = (Foo)compiled.DeepClone(foo);
            CompareFoo(foo, clone, "Compile/Foo");
            clone = (Foo)compiled.DeepClone(proxy);
            CompareFoo(proxy, clone, "Compile/FooProxy");
        }
コード例 #4
0
ファイル: samplecli2.cs プロジェクト: stanasse/olive
    public static void Main()
    {
        WSHttpBinding binding = new WSHttpBinding();

        binding.Security.Transport.ClientCredentialType     = HttpClientCredentialType.None;
        binding.Security.Message.EstablishSecurityContext   = false;
        binding.Security.Message.NegotiateServiceCredential = false;
        binding.Security.Message.ClientCredentialType       = MessageCredentialType.UserName;
        X509Certificate2 cert  = new X509Certificate2("test.pfx", "mono");
        FooProxy         proxy = new FooProxy(binding,
                                              new EndpointAddress(new Uri("http://localhost:8080/"), new X509CertificateEndpointIdentity(cert)));

        //proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
        //proxy.ClientCredentials.ClientCertificate.Certificate = cert;
        proxy.ClientCredentials.UserName.UserName = "******";
        proxy.Endpoint.Behaviors.Add(new StdErrInspectionBehavior());
        proxy.Open();
        try {
            Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
        } catch (MessageSecurityException ex) {
            FaultException inner = ex.InnerException as FaultException;
            if (inner == null)
            {
                throw;
            }
            Console.WriteLine(inner.Reason);
            Console.WriteLine(ex);
        }
    }
コード例 #5
0
    static void Run()
    {
        SymmetricSecurityBindingElement sbe =
            new SymmetricSecurityBindingElement();

        sbe.MessageSecurityVersion       = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
        sbe.RequireSignatureConfirmation = true;
        //sbe.IncludeTimestamp = false;

        X509SecurityTokenParameters p =
            new X509SecurityTokenParameters(X509KeyIdentifierClauseType.Thumbprint, SecurityTokenInclusionMode.AlwaysToRecipient);

        p.RequireDerivedKeys = false;
        sbe.EndpointSupportingTokenParameters.Endorsing.Add(p);
        sbe.ProtectionTokenParameters =
            new X509SecurityTokenParameters(X509KeyIdentifierClauseType.Thumbprint, SecurityTokenInclusionMode.Never);
        //sbe.SetKeyDerivation (false);
        //sbe.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
        HttpTransportBindingElement hbe =
            new HttpTransportBindingElement();
        CustomBinding    binding = new CustomBinding(new XBE(), sbe, hbe);
        X509Certificate2 cert    = new X509Certificate2("test.pfx", "mono");
        X509Certificate2 cert2   = cert;      //new X509Certificate2 ("test2.cer");
        FooProxy         proxy   = new FooProxy(binding,
                                                new EndpointAddress(new Uri("http://localhost:8080"), new X509CertificateEndpointIdentity(cert2)));

        //proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
        proxy.ClientCredentials.ClientCertificate.Certificate = cert;
        proxy.Endpoint.Behaviors.Add(new StdErrInspectionBehavior());
        proxy.Open();
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
    }
コード例 #6
0
        public void TestExternalize()
        {
            var stream = new MemoryStream();

            {
                var foo = new Foo();
                var bar = new Bar();

                foo.Value = 5;
                bar.Value = 10;
                foo.Bar   = bar;

                var externalizer = new Externalizer();
                var proxy        = new FooProxy(foo, SaveFoo, LoadFoo);
                var mem          = externalizer.Save(proxy);

                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, mem);
            }

            stream.Position = 0;
            {
                var formatter = new BinaryFormatter();
                var mem       = formatter.Deserialize(stream) as IMemento;

                var externalizer = new Externalizer();
                var proxy        = externalizer.Load(mem) as FooProxy;

                var foo = proxy.Real;
                Assert.AreEqual(5, foo.Value);
                Assert.AreEqual(10, foo.Bar.Value);
            }
        }
コード例 #7
0
ファイル: samplecli.cs プロジェクト: stanasse/olive
    public static void Main()
    {
        FooProxy proxy = new FooProxy(String.Empty);

        proxy.Open();
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
    }
コード例 #8
0
ファイル: Foo.cs プロジェクト: zhouweiaccp/nhibernate-core
 public void Disconnect()
 {
     if (_foo != null)
     {
         _foo.Disconnect();
     }
     _foo = null;
 }
コード例 #9
0
        public void NotAllowedInitializationUI()
        {
            var f = new FooProxy(new BasicHttpBinding(), new EndpointAddress("http://localhost:" + NetworkHelpers.FindFreePort()));

            f.Endpoint.Contract.Behaviors.Add(new MyContractBehavior());
            f.InnerChannel.AllowInitializationUI = false;
            f.DisplayInitializationUI();
        }
コード例 #10
0
    public static void Main()
    {
        FooProxy proxy = new FooProxy(
            new BasicHttpBinding(),
            new EndpointAddress("http://localhost:8080/"));

        proxy.Open();
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
        Console.WriteLine(proxy.Add(1000, 2000));
        Console.WriteLine("done");
    }
コード例 #11
0
    public static void Main(string [] args)
    {
        bool     bar     = args.FirstOrDefault(s => s == "--bar") != null;
        var      binding = new BasicHttpBinding();
        FooProxy proxy   = new FooProxy(binding,
                                        new EndpointAddress("http://localhost:8080/samplesvc3.svc/" + (bar ? "bar" : "foo")));

        proxy.Open();
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
        Console.WriteLine(proxy.Add(1000, 2000));
        Console.WriteLine("done");
    }
コード例 #12
0
ファイル: samplecli16.cs プロジェクト: stanasse/olive
    static void Run()
    {
        var binding = new NetTcpBinding();

        binding.Security.Mode = SecurityMode.Message;
        binding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
        X509Certificate2 cert  = new X509Certificate2("test.pfx", "mono");
        FooProxy         proxy = new FooProxy(binding,
                                              new EndpointAddress(new Uri("net.tcp://localhost:8080/"), new X509CertificateEndpointIdentity(cert)));

        proxy.ClientCredentials.ClientCertificate.Certificate = cert;
        proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
        proxy.Open();
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
    }
コード例 #13
0
ファイル: samplecli2.cs プロジェクト: stanasse/olive
    static void Run()
    {
        FooProxy proxy = new FooProxy(
            new BasicHttpBinding(),
            new EndpointAddress("http://localhost:8080/"));

        proxy.Open();

        Message req = Message.CreateMessage(MessageVersion.Soap11, "http://tempuri.org/IFoo/Echo");
        Message res = proxy.Echo(req);

        using (XmlWriter w = XmlWriter.Create(Console.Out)) {
            res.WriteMessage(w);
        }
    }
コード例 #14
0
ファイル: samplecli.cs プロジェクト: stanasse/olive
    static void Run()
    {
        WSHttpBinding binding = new WSHttpBinding();

        binding.Security.Message.EstablishSecurityContext   = false;
        binding.Security.Message.NegotiateServiceCredential = false;
        binding.Security.Message.ClientCredentialType       = MessageCredentialType.Certificate;
        X509Certificate2 cert  = new X509Certificate2("test.pfx", "mono");
        FooProxy         proxy = new FooProxy(binding,
                                              new EndpointAddress(new Uri("http://localhost:8080/"), new X509CertificateEndpointIdentity(cert)));

        proxy.Endpoint.Behaviors.Add(new StdErrInspectionBehavior());
        proxy.ClientCredentials.ClientCertificate.Certificate = cert;
        proxy.Open();
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
    }
コード例 #15
0
ファイル: samplecli.cs プロジェクト: stanasse/olive
    static void Run(string user, string pass)
    {
        var binding = new BasicHttpBinding();

        binding.Security.Mode =
            BasicHttpSecurityMode.TransportCredentialOnly;
        binding.Security.Transport.ClientCredentialType =
            HttpClientCredentialType.Basic;
        FooProxy proxy = new FooProxy(binding,
                                      new EndpointAddress("http://localhost:8080/auth.svc"));

        proxy.ClientCredentials.UserName.UserName = user;
        proxy.ClientCredentials.UserName.Password = pass;
        proxy.Open();
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
        Console.WriteLine(proxy.Add(1000, 2000));
        Console.WriteLine("done");
    }
コード例 #16
0
    static void Run()
    {
        SymmetricSecurityBindingElement sbe =
            new SymmetricSecurityBindingElement();

        sbe.ProtectionTokenParameters =
            new SspiSecurityTokenParameters();
        HttpTransportBindingElement hbe =
            new HttpTransportBindingElement();
        CustomBinding    binding = new CustomBinding(sbe, hbe);
        X509Certificate2 cert    = new X509Certificate2("test.cer");
        FooProxy         proxy   = new FooProxy(binding,
                                                //new EndpointAddress (new Uri ("http://localhost:8080")));
                                                new EndpointAddress(new Uri("http://localhost:8080"), new UpnEndpointIdentity("PC\\atsushi")));

        //new EndpointAddress (new Uri ("http://localhost:8080"), new SpnEndpointIdentity ("PC/atsushi")));
        proxy.Open();
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
    }
コード例 #17
0
ファイル: samplecli10.cs プロジェクト: stanasse/olive
    static void Run()
    {
        SymmetricSecurityBindingElement sbe =
            new SymmetricSecurityBindingElement();

        sbe.ProtectionTokenParameters =
            new SslSecurityTokenParameters();
        HttpTransportBindingElement hbe =
            new HttpTransportBindingElement();
        CustomBinding    binding = new CustomBinding(sbe, hbe);
        X509Certificate2 cert    = new X509Certificate2("test.cer");
        FooProxy         proxy   = new FooProxy(binding,
                                                new EndpointAddress(new Uri("http://localhost:8080"), new X509CertificateEndpointIdentity(cert)));

        proxy.ClientCredentials.ServiceCertificate.Authentication
        .CertificateValidationMode =
            X509CertificateValidationMode.None;
//		proxy.Endpoint.Behaviors.Add (new StdErrInspectionBehavior ());
        proxy.Open();
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
    }
コード例 #18
0
    static void Run()
    {
        WSHttpBinding binding = new WSHttpBinding();

        //binding.Security.Message.EstablishSecurityContext = false;
        binding.Security.Message.NegotiateServiceCredential = false;
        binding.Security.Message.ClientCredentialType       =
            MessageCredentialType.IssuedToken;
        X509Certificate2 cert2 = new X509Certificate2("test.cer");
        // DefaultCertificate does not work here...
        FooProxy proxy = new FooProxy(binding,
                                      new EndpointAddress(new Uri("http://localhost:8080"),
                                                          new X509CertificateEndpointIdentity(cert2)));

        proxy.ClientCredentials.ServiceCertificate.Authentication
        .CertificateValidationMode =
            X509CertificateValidationMode.None;
        proxy.ClientCredentials.ServiceCertificate.Authentication
        .RevocationMode = X509RevocationMode.NoCheck;
        //proxy.Open ();
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
    }
コード例 #19
0
ファイル: samplecli14.cs プロジェクト: stanasse/olive
    static void Run(string issuerUri, string issuerCertFile)
    {
        SymmetricSecurityBindingElement sbe =
            new SymmetricSecurityBindingElement();
        IssuedSecurityTokenParameters ip =
            new IssuedSecurityTokenParameters();

        ip.ClaimTypeRequirements.Add(new ClaimTypeRequirement(
                                         ClaimTypes.PPID));
        //ClaimTypes.Email));
        if (issuerUri != null)
        {
            // if exists, then a managed card is required.
            ip.IssuerAddress = new EndpointAddress(new Uri(issuerUri),
                                                   new X509CertificateEndpointIdentity(new X509Certificate2(issuerCertFile)));
        }
        X509Certificate2 cert2  = new X509Certificate2("test.cer");
        EndpointAddress  target =
            new EndpointAddress(new Uri("http://localhost:8080"),
                                new X509CertificateEndpointIdentity(cert2));

        sbe.ProtectionTokenParameters            = ip;
        sbe.LocalClientSettings.IdentityVerifier =
            new MyVerifier();
        HttpTransportBindingElement hbe =
            new HttpTransportBindingElement();
        CustomBinding binding = new CustomBinding(sbe, hbe);
        // DefaultCertificate does not work here...
        FooProxy proxy = new FooProxy(binding, target);

        proxy.ClientCredentials.ServiceCertificate.Authentication
        .CertificateValidationMode =
            X509CertificateValidationMode.None;
        proxy.ClientCredentials.ServiceCertificate.Authentication
        .RevocationMode = X509RevocationMode.NoCheck;
        //proxy.ClientCredentials.IssuedToken.LocalIssuerAddress = ip.IssuerAddress;
        //proxy.ClientCredentials.IssuedToken.LocalIssuerBinding = ip.IssuerBinding;
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
    }
コード例 #20
0
ファイル: samplecli4.cs プロジェクト: stanasse/olive
    static void Run()
    {
        SymmetricSecurityBindingElement sbe =
            new SymmetricSecurityBindingElement();

        //sbe.IncludeTimestamp = false;
        //sbe.LocalClientSettings.DetectReplays = false;

        sbe.ProtectionTokenParameters = new X509SecurityTokenParameters();
        sbe.ProtectionTokenParameters.InclusionMode = SecurityTokenInclusionMode.Never;
        sbe.SetKeyDerivation(false);
        sbe.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
        HttpTransportBindingElement hbe =
            new HttpTransportBindingElement();
        CustomBinding    binding = new CustomBinding(new XBE(), sbe, hbe);
        X509Certificate2 cert    = new X509Certificate2("test.cer");
        FooProxy         proxy   = new FooProxy(binding,
                                                new EndpointAddress(new Uri("http://localhost:8080"), new X509CertificateEndpointIdentity(cert)));

        proxy.Endpoint.Behaviors.Add(new StdErrInspectionBehavior());
        proxy.Open();
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
    }
コード例 #21
0
ファイル: samplecli9.cs プロジェクト: stanasse/olive
    static void Run()
    {
        SymmetricSecurityBindingElement sbe =
            new SymmetricSecurityBindingElement();

        UserNameSecurityTokenParameters p =
            new UserNameSecurityTokenParameters();

        p.RequireDerivedKeys = false;
        sbe.EndpointSupportingTokenParameters.SignedEncrypted.Add(p);
        sbe.ProtectionTokenParameters =
            new X509SecurityTokenParameters(X509KeyIdentifierClauseType.Thumbprint, SecurityTokenInclusionMode.Never);
        HttpTransportBindingElement hbe =
            new HttpTransportBindingElement();
        CustomBinding    binding = new CustomBinding(new XBE(), sbe, hbe);
        X509Certificate2 cert    = new X509Certificate2("test.pfx", "mono");
        FooProxy         proxy   = new FooProxy(binding,
                                                new EndpointAddress(new Uri("http://localhost:8080"), new X509CertificateEndpointIdentity(cert)));

        proxy.ClientCredentials.UserName.UserName = "******";
        proxy.Endpoint.Behaviors.Add(new StdErrInspectionBehavior());
        proxy.Open();
        Console.WriteLine(proxy.Echo("TEST FOR ECHO"));
    }
コード例 #22
0
        public void CanRoundTripProxyToRegular()
        {
            var model = BuildModel();

            Foo foo = new Foo { Id = 1234, Name = "abcd" }, proxy = new FooProxy(foo), clone;
            Assert.IsNotNull(foo);
            Assert.IsNotNull(proxy);

            clone = (Foo)model.DeepClone(foo);
            CompareFoo(foo, clone, "Runtime/Foo");
            clone = (Foo)model.DeepClone(proxy);
            CompareFoo(proxy, clone, "Runtime/FooProxy");

            model.CompileInPlace();
            clone = (Foo)model.DeepClone(foo);
            CompareFoo(foo, clone, "CompileInPlace/Foo");
            clone = (Foo)model.DeepClone(proxy);
            CompareFoo(proxy, clone, "CompileInPlace/FooProxy");

            var compiled = model.Compile();
            clone = (Foo)compiled.DeepClone(foo);
            CompareFoo(foo, clone, "Compile/Foo");
            clone = (Foo)compiled.DeepClone(proxy);
            CompareFoo(proxy, clone, "Compile/FooProxy");

        }
コード例 #23
0
		public void Disconnect() 
		{
			if ( _foo!=null) _foo.Disconnect();
			_foo=null;
		}