public void Open()
        {
            IssuedSecurityTokenProvider p = SetupProvider(new BasicHttpBinding());

            try {
                p.Open();
            } finally {
                if (p.State == CommunicationState.Opened)
                {
                    p.Close();
                }
            }
        }
        public void GetToken()
        {
            IssuedSecurityTokenProvider p = SetupProvider(CreateIssuerBinding(new RequestSender(OnGetToken), true));

            try {
                p.Open(TimeSpan.FromSeconds(5));
                p.GetToken(TimeSpan.FromSeconds(10));
            } finally {
                if (p.State == CommunicationState.Opened)
                {
                    p.Close();
                }
            }
        }
        public void GetTokenWithoutProtectionTokenParameters()
        {
            IssuedSecurityTokenProvider p = SetupProvider(CreateIssuerBinding(null, false));

            try {
                p.Open();
                p.GetToken(TimeSpan.FromSeconds(10));
            } finally {
                if (p.State == CommunicationState.Opened)
                {
                    p.Close();
                }
            }
        }
        public void GetTokenNoSecureBinding()
        {
            IssuedSecurityTokenProvider p = SetupProvider(new BasicHttpBinding());

            try {
                p.Open();
                p.GetToken(TimeSpan.FromSeconds(10));
            } finally {
                if (p.State == CommunicationState.Opened)
                {
                    p.Close();
                }
            }
        }
        public void GetTokenWithoutServiceCertificate()
        {
            IssuedSecurityTokenProvider p = SetupProvider(CreateIssuerBinding(null, true));

            p.IssuerAddress = new EndpointAddress("stream:dummy");
            try {
                p.Open(TimeSpan.FromSeconds(5));
                p.GetToken(TimeSpan.FromSeconds(10));
            } finally {
                if (p.State == CommunicationState.Opened)
                {
                    p.Close();
                }
            }
        }
Exemple #6
0
    public static void Main()
    {
        IssuedSecurityTokenProvider p =
            new IssuedSecurityTokenProvider();

        p.SecurityTokenSerializer = WSSecurityTokenSerializer.DefaultInstance;
        p.IssuerAddress           = new EndpointAddress("http://localhost:8080");
        WSHttpBinding binding = new WSHttpBinding();

        //binding.Security.Mode = SecurityMode.Message;
        p.IssuerBinding          = binding;
        p.SecurityAlgorithmSuite = SecurityAlgorithmSuite.Default;
        p.TargetAddress          = new EndpointAddress("http://localhost:8080");

        p.Open();
        p.GetToken(TimeSpan.FromSeconds(10));
        p.Close();
    }
Exemple #7
0
        public static void Main(string [] args)
        {
            bool no_nego = false, no_sc = false;

            foreach (string arg in args)
            {
                if (arg == "--no-nego")
                {
                    no_nego = true;
                }
                else if (arg == "--no-sc")
                {
                    no_sc = true;
                }
                else
                {
                    Console.WriteLine("Unrecognized option '{0}'", arg);
                    return;
                }
            }

            X509Certificate2            cert = new X509Certificate2("test.pfx", "mono");
            IssuedSecurityTokenProvider p    =
                new IssuedSecurityTokenProvider();

            p.IssuerAddress = new EndpointAddress(new Uri("http://localhost:8080"), new X509CertificateEndpointIdentity(cert));
            p.TargetAddress = new EndpointAddress("http://localhost:8080");
            WSHttpBinding binding            = new WSHttpBinding();

            // the following lines are required to not depend on
            // MessageCredentialType.Windows (which uses SSPI).
            binding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
            ClientCredentials cred = new ClientCredentials();

            cred.ClientCertificate.Certificate = cert;
            cred.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
            p.IssuerChannelBehaviors.Add(cred);

            if (no_sc)
            {
                binding.Security.Message.EstablishSecurityContext = false;
            }
            if (no_nego)
            {
                binding.Security.Message.NegotiateServiceCredential = false;
            }

            p.IssuerBinding           = binding;
            p.SecurityTokenSerializer = new WSSecurityTokenSerializer();
            p.SecurityAlgorithmSuite  = SecurityAlgorithmSuite.Default;
            p.KeyEntropyMode          = SecurityKeyEntropyMode.ClientEntropy;
            p.Open();
            SecurityToken token = p.GetToken(TimeSpan.FromSeconds(10));

            p.Close();

            XmlWriter writer = XmlWriter.Create(Console.Out);

            new ClientCredentialsSecurityTokenManager(cred).CreateSecurityTokenSerializer(MessageSecurityVersion.Default.SecurityTokenVersion).WriteToken(writer, token);
            writer.Close();
        }
 void IDisposable.Dispose()
 {
     innerProvider.Close();
     disposed = true;
 }