當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。