
Throw new ConfigurationErrorsException("creditCardFile not specified in service config") ĬreditCardFile = String.Format(" If (string.IsNullOrEmpty(creditCardFile)) Public EchoServiceHost(parameters Uri addresses)ĬreditCardFile = ConfigurationManager.AppSettings The service credentials class is located in the CreditCardServiceCredentials class and is added to the behaviors collections of the service host in the EchoServiceHost.InitializeRuntime method. To consume a credit card token in the message, the sample uses custom service credentials to provide this functionality. Return new CustomBinding(messageSecurity, httpTransport) MessageSecurity.ProtectionTokenParameters = x509ProtectionParameters X509ProtectionParameters.InclusionMode = SecurityTokenInclusionMode.Never X509SecurityTokenParameters x509ProtectionParameters = new X509SecurityTokenParameters() Var messageSecurity = new SymmetricSecurityBindingElement() The token that is encrypted with the service's certificate. The message security binding element will be configured to require a credit card. Var httpTransport = new HttpTransportBindingElement() Public static Binding CreateCreditCardBinding() The behavior specifies the service credentials that are to be used for client authentication and also information about the service X.509 certificate. This sample sets the SymmetricSecurityBindingElement to use a service's X.509 certificate to protect the symmetric key during transmission and to pass a custom CreditCardToken in a WS-Security message header as a signed and encrypted security token. The binding is configured with a custom binding using SymmetricSecurityBindingElement and HttpTransportBindingElement.

The endpoint consists of an address, a binding, and a contract. The service exposes a single endpoint that is programmatically created using BindingHelper and EchoServiceHost classes. How the server's X.509 certificate is used to protect the symmetric key used for message encryption and signature.Ĭlient Authentication Using a Custom Security Token

#SKRUMBLE ADD CUSTOM TOKEN CODE#
How the WCF service code can obtain the information about received security tokens including the custom security token. How the service can consume and validate a custom security token. How a client can pass a custom security token to a service. To summarize, this sample demonstrates the following: The setup procedure and build instructions for this sample are located at the end of this topic.
