Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IdentityModel.Claims;
- using System.IdentityModel.Protocols.WSTrust;
- using System.IdentityModel.Tokens;
- using System.ServiceModel;
- using System.ServiceModel.Security;
- namespace WsTrustActiveSTSClient
- {
- internal class Program
- {
- private static void Main(string[] args)
- {
- WS2007HttpBinding binding = new WS2007HttpBinding(SecurityMode.TransportWithMessageCredential, false);
- binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
- binding.Security.Message.EstablishSecurityContext = false;
- EndpointAddress endpoint = new EndpointAddress("https://localhost:9443/services/wso2carbon-sts");
- WSTrustChannelFactory factory = new WSTrustChannelFactory(binding, endpoint);
- factory.Credentials.UserName.UserName = "admin";
- factory.Credentials.UserName.Password = "admin";
- WSTrustChannel channel = (WSTrustChannel) factory.CreateChannel();
- RequestSecurityToken rst = new RequestSecurityToken
- {
- RequestType = RequestTypes.Issue,
- KeyType = KeyTypes.Symmetric,
- Claims =
- {
- new RequestClaim(ClaimTypes.Name)
- }
- };
- RequestSecurityTokenResponse rstr = null;
- SecurityToken token = channel.Issue(rst, out rstr);
- Console.WriteLine("{0}", token);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement