当前位置: 首页>>代码示例>>C#>>正文


C# ChannelFactory.CreateChannelWithIssuedToken方法代码示例

本文整理汇总了C#中System.ServiceModel.ChannelFactory.CreateChannelWithIssuedToken方法的典型用法代码示例。如果您正苦于以下问题:C# ChannelFactory.CreateChannelWithIssuedToken方法的具体用法?C# ChannelFactory.CreateChannelWithIssuedToken怎么用?C# ChannelFactory.CreateChannelWithIssuedToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.ChannelFactory的用法示例。


在下文中一共展示了ChannelFactory.CreateChannelWithIssuedToken方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Webservice

        public ActionResult Webservice()
        {
            ViewBag.Message = "Your application description page.";

            // Setup the channel factory for the call to the backend service
            var binding = new WS2007FederationHttpBinding(
            WSFederationHttpSecurityMode.TransportWithMessageCredential);
            var factory = new ChannelFactory<WebService.IService>(binding, new EndpointAddress("https://[BackendService]/Service.svc"));
            // turn off CardSpace
            factory.Credentials.SupportInteractive = false;

            // Get the token representing the logged in user
            var actAsToken = GetActAsToken();

            // Create the channel to the backend service using the acquired token
            var channel = factory.CreateChannelWithIssuedToken(actAsToken);

            // Call the service
            var serviceClaims = channel.GetClaimsPrincipal();

            // At this point, you can compare the claims the are available to the backend service with the ones available to the web app
            // See for example that the backend service has knowledge of both the logged in user and the front end app through which the user is logged in

            ViewBag.Message = "Web service call succeeded!";
            return View();
        }
开发者ID:AnnejanBarelds,项目名称:AuthDemos,代码行数:26,代码来源:HomeController.cs

示例2: CallService

        private static void CallService(SecurityToken token)
        {
            var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
            binding.Security.Message.EstablishSecurityContext = false;
            binding.Security.Message.IssuedKeyType = SecurityKeyType.BearerKey;

            var factory = new ChannelFactory<IClaimsService>(
                binding,
                new EndpointAddress("https://adfs.leastprivilege.vm/adfsapp/service.svc"));
            factory.Credentials.SupportInteractive = false;

            var channel = factory.CreateChannelWithIssuedToken(token);
            channel.GetClaims().ToList().ForEach(c => Console.WriteLine(c.Value));
        }
开发者ID:kurtmarr,项目名称:IdentityAccessControl,代码行数:14,代码来源:Program.cs

示例3: CallService

        private static void CallService(SecurityToken token)
        {
            "Calling Service".ConsoleYellow();

            var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
            binding.Security.Message.EstablishSecurityContext = false;
            binding.Security.Message.IssuedKeyType = SecurityKeyType.BearerKey;

            var factory = new ChannelFactory<IClaimsService>(binding, new EndpointAddress(_serviceAddress));
            factory.Credentials.SupportInteractive = false;
            factory.Credentials.UseIdentityConfiguration = true;
            var proxy = factory.CreateChannelWithIssuedToken(token);

            var id = proxy.GetIdentity();
            Helper.ShowIdentity(id);
        }
开发者ID:rachkoud,项目名称:HardCodedToken,代码行数:16,代码来源:Program.cs

示例4: CreateProxy

        private static IService CreateProxy()
        {
            // request identity token from ADFS
            SecurityToken token = RequestIdentityToken();

            // set up factory and channel
            var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
            binding.Security.Message.EstablishSecurityContext = false;
            
            var factory = new ChannelFactory<IService>(binding, _serviceEndpoint);
            factory.Credentials.SupportInteractive = false;

            // enable WIF on channel factory
            factory.ConfigureChannelFactory();

            return factory.CreateChannelWithIssuedToken(token);
        }
开发者ID:1nv4d3r5,项目名称:Thinktecture.IdentityModel.Web,代码行数:17,代码来源:Program.cs

示例5: Main

        static void Main(string[] args)
        {
            var jwt = GetJwt();
            var xmlToken = WrapJwt(jwt);

            var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
            binding.HostNameComparisonMode = HostNameComparisonMode.Exact;
            binding.Security.Message.EstablishSecurityContext = false;
            binding.Security.Message.IssuedKeyType = SecurityKeyType.BearerKey;

            var factory = new ChannelFactory<IService>(
                binding,
                new EndpointAddress("https://localhost:44335/token"));

            var channel = factory.CreateChannelWithIssuedToken(xmlToken);
            
            Console.WriteLine(channel.Ping());
        }
开发者ID:camainc,项目名称:IdentityServer3.Samples,代码行数:18,代码来源:Program.cs

示例6: CallService

        private static void CallService(SecurityToken token)
        {
            //var serviceEndpoint = "https://" + "adfs.leastprivilege.vm" + "/rp/service.svc";
            var serviceEndpoint = "https://" + "localhost:44305" + "/service.svc";
            
            var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
            binding.Security.Message.EstablishSecurityContext = false;
            binding.Security.Message.IssuedKeyType = SecurityKeyType.BearerKey;

            var factory = new ChannelFactory<IClaimsService>(
                binding,
                new EndpointAddress(serviceEndpoint));
            factory.Credentials.SupportInteractive = false;

            var channel = factory.CreateChannelWithIssuedToken(token);
            var claims = channel.GetClaims();

            claims.ForEach(c => Console.WriteLine("{0}\n {1}\n\n", c.Type, c.Value));
        }
开发者ID:mscherpenisse,项目名称:Thinktecture.IdentityModel.45,代码行数:19,代码来源:Program.cs

示例7: CreateClient

        private IFederatedService CreateClient()
        {
            //var serviceEndpoint = "https://localhost:44300/FederatedService.svc";

            //var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
            //binding.Security.Message.EstablishSecurityContext = false;
            //binding.Security.Message.IssuedKeyType = SecurityKeyType.BearerKey;

            //var factory = new ChannelFactory<IFederatedService>(
            //    binding,
            //    new EndpointAddress(serviceEndpoint));

            //factory.Credentials.UseIdentityConfiguration = true;
            //factory.Credentials.SupportInteractive = false;
            var factory = new ChannelFactory<IFederatedService>("WS2007FederationHttpBinding_IFederatedService");
            var token = GetIssuedToken();
            var channel = factory.CreateChannelWithIssuedToken(token);
            return channel;
        }
开发者ID:khoanguyen,项目名称:Test-WS-Federation,代码行数:19,代码来源:HomeController.cs

示例8: _btnCallService_Click

        private void _btnCallService_Click(object sender, RoutedEventArgs e)
        {
            var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
            binding.Security.Message.EstablishSecurityContext = false;
            binding.Security.Message.IssuedKeyType = SecurityKeyType.BearerKey;

            var ep = new EndpointAddress("https://" + Constants.WebHost + "/webservicesecurity/soap.svc/bearer");

            var factory = new ChannelFactory<IService>(binding, ep);
            factory.Credentials.SupportInteractive = false;
            factory.ConfigureChannelFactory();

            var channel = factory.CreateChannelWithIssuedToken(RSTR.SecurityToken);
            var claims = channel.GetClientIdentity();
            
            var sb = new StringBuilder(128);
            claims.ForEach(c => sb.AppendFormat("{0}\n {1}\n\n", c.ClaimType, c.Value));
            _txtDebug.Text = sb.ToString();
        }
开发者ID:1nv4d3r5,项目名称:Thinktecture.IdentityModel.Web,代码行数:19,代码来源:MainWindow.xaml.cs

示例9: CallMessage

        private static void CallMessage(SamlSecurityToken token)
        {
            var factory = new ChannelFactory<IServiceClientChannel>(
                new ClientSamlHttpBinding(SecurityMode.Message),
                new EndpointAddress(
                    new Uri("http://roadie:9000/Services/ClientSaml/Message"),
                    EndpointIdentity.CreateDnsIdentity("Service")));

            factory.Credentials.ServiceCertificate.SetDefaultCertificate(
                StoreLocation.CurrentUser,
                StoreName.My,
                X509FindType.FindBySubjectDistinguishedName,
                "CN=Service");

            factory.ConfigureChannelFactory<IServiceClientChannel>();
            var proxy = factory.CreateChannelWithIssuedToken<IServiceClientChannel>(token);

            proxy.Ping("foo");
            proxy.Close();
        }
开发者ID:IdentityModel,项目名称:Thinktecture.IdentityModel.v1,代码行数:20,代码来源:Program.cs

示例10: CallMixedMode

        private static void CallMixedMode(SamlSecurityToken token)
        {
            var factory = new ChannelFactory<IServiceClientChannel>("*");

            factory.ConfigureChannelFactory<IServiceClientChannel>();
            var proxy = factory.CreateChannelWithIssuedToken<IServiceClientChannel>(token);

            proxy.Ping("foo");
            proxy.Close();
        }
开发者ID:IdentityModel,项目名称:Thinktecture.IdentityModel.v1,代码行数:10,代码来源:Program.cs

示例11: GetServiceProxy

        private static IClaimsService GetServiceProxy(SecurityToken token)
        {
            var serviceAddress = FederatedAuthentication.FederationConfiguration.WsFederationConfiguration.Reply + "service.svc";
            
            var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
            binding.Security.Message.EstablishSecurityContext = false;
            binding.Security.Message.IssuedKeyType = SecurityKeyType.BearerKey;

            var factory = new ChannelFactory<IClaimsService>(
                binding,
                new EndpointAddress(serviceAddress));
            factory.Credentials.SupportInteractive = false;

            var channel = factory.CreateChannelWithIssuedToken(token);
            return channel;
        }
开发者ID:Rameshcyadav,项目名称:Thinktecture.IdentityModel.45,代码行数:16,代码来源:UserController.cs


注:本文中的System.ServiceModel.ChannelFactory.CreateChannelWithIssuedToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。