Exemplo n.º 1
0
        /// <summary>
        /// Implement to confirm that the endpoint meets some intended criteria.
        /// </summary>
        /// <param name="endpoint">The endpoint to validate.</param>
        public void Validate(ServiceEndpoint endpoint)
        {
            var other = endpoint.Behaviors.Find <ClientCredentials> ();

            if (other == null)
            {
                return;
            }

            endpoint.Behaviors.Remove(other.GetType());

            var item = new FederatedClientCredentials(other);

            endpoint.Behaviors.Add(item);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T">T is the interface the service provider exposes.</typeparam>
        /// <param name="token">GenericXmlSecurityToken containing a saml2SecurityToken</param>
        /// <param name="clientCertificate"></param>
        /// <param name="serviceCertificate"></param>
        /// <param name="serviceEndpointAddress"></param>
        /// <returns></returns>
        public static T CreateChannelWithIssuedToken <T>(SecurityToken token, X509Certificate2 clientCertificate, X509Certificate2 serviceCertificate, EndpointAddress serviceEndpointAddress)
        {
            bool sslEnabled = serviceEndpointAddress.Uri.Scheme.ToLowerInvariant() == "https";

            ChannelFactory <T> echoServiceFactory = new ChannelFactory <T>(new ServiceproviderBinding(sslEnabled), serviceEndpointAddress);


            echoServiceFactory.Credentials.ClientCertificate.Certificate = clientCertificate;

            //Issuedtoken binding information needs to be set, even though it aint used.
            echoServiceFactory.Credentials.IssuedToken.LocalIssuerBinding = new SecurityTokenServiceBinding();
            echoServiceFactory.Credentials.IssuedToken.LocalIssuerAddress = new EndpointAddress(new Uri("http://NotAnUrlAndNotToBeUsed"));

            echoServiceFactory.Credentials.ServiceCertificate.DefaultCertificate = serviceCertificate;

            FederatedClientCredentials.ConfigureChannelFactory(echoServiceFactory);

            return(echoServiceFactory.CreateChannelWithIssuedToken(token));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Implement to confirm that the endpoint meets some intended criteria.
        /// </summary>
        /// <param name="endpoint">The endpoint to validate.</param>
        public void Validate( ServiceEndpoint endpoint )
        {
            var other = endpoint.Behaviors.Find<ClientCredentials> ();

            if ( other == null )
            {
                return;
            }

            endpoint.Behaviors.Remove ( other.GetType () );

            var item = new FederatedClientCredentials ( other );

            endpoint.Behaviors.Add ( item );
        }