ClientCredentials ClientCredentials ClientCredentials ClientCredentials Class

Definition

Enables the user to configure client and service credentials as well as service credential authentication settings for use on the client side of communication.

public ref class ClientCredentials : System::ServiceModel::Description::IEndpointBehavior
public class ClientCredentials : System.ServiceModel.Description.IEndpointBehavior
type ClientCredentials = class
    interface IEndpointBehavior
Public Class ClientCredentials
Implements IEndpointBehavior
Inheritance
ClientCredentialsClientCredentialsClientCredentialsClientCredentials
Implements

Examples

The following code sample shows how to override this class and implement your own custom client credentials that includes a custom security token manager.

Important

It is important to note that the CreateSecurityTokenManager method is overridden to create a custom security token manager. The security token manager, derived from ClientCredentialsSecurityTokenManager. must return a custom security token provider, derived from SecurityTokenProvider, to create the actual security token. If you do not follow this pattern for creating security tokens, your application will be at risk for security attacks, specifically elevation of privileges. This coding pattern ensures that the correct credentials are used when channel factories are cached.

public class MyClientCredentials : ClientCredentials
{
    string creditCardNumber;

    public MyClientCredentials()
    {
        // Perform client credentials initialization.
    }

    protected MyClientCredentials(MyClientCredentials other)
        : base(other)
    {
        // Clone fields defined in this class.
        this.creditCardNumber = other.creditCardNumber;
    }

    public string CreditCardNumber
    {
        get
        {
            return this.creditCardNumber;
        }
        set
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            this.creditCardNumber = value;
        }
    }

    public override SecurityTokenManager CreateSecurityTokenManager()
    {
        // Return your implementation of the SecurityTokenManager.
        return new MyClientCredentialsSecurityTokenManager(this);
    }

    protected override ClientCredentials CloneCore()
    {
        // Implement the cloning functionality.
        return new MyClientCredentials(this);
    }
}
Public Class MyClientCredentials
    Inherits ClientCredentials
    Private creditCardNumberValue As String

    Public Sub New() 
    
    End Sub 'New
    
    ' Perform client credentials initialization.    
    Protected Sub New(ByVal other As MyClientCredentials) 
        MyBase.New(other)
        ' Clone fields defined in this class.
        Me.creditCardNumberValue = other.creditCardNumberValue
    
    End Sub

    Public Property CreditCardNumber() As String 
        Get
            Return Me.creditCardNumberValue
        End Get
        Set
            If value Is Nothing Then
                Throw New ArgumentNullException("value")
            End If
            Me.creditCardNumberValue = value
        End Set
    End Property

    Public Overrides Function CreateSecurityTokenManager() As SecurityTokenManager 
        ' Return your implementation of the SecurityTokenManager.
        Return New MyClientCredentialsSecurityTokenManager(Me)
    
    End Function
    
    Protected Overrides Function CloneCore() As ClientCredentials 
        ' Implement the cloning functionality.
        Return New MyClientCredentials(Me)
    
    End Function
End Class

Remarks

The ClientCredentials is accessed through the ClientCredentials property of the ClientBase<TChannel> class.

A ClientCredentials object is added to the Behaviors collection. The ClientCredentials property is a Fa├žade (a well-known design pattern) over an entry in that collection. Many properties in this class return objects that consist mainly of properties. These objects can be used for configuration: once you get the object, you can use it to set properties by calling its members.

Constructors

ClientCredentials() ClientCredentials() ClientCredentials() ClientCredentials()

Initializes a new instance of the ClientCredentials class.

ClientCredentials(ClientCredentials) ClientCredentials(ClientCredentials) ClientCredentials(ClientCredentials) ClientCredentials(ClientCredentials)

This is a copy constructor.

Properties

ClientCertificate ClientCertificate ClientCertificate ClientCertificate

Gets an object that you can use to provide the X.509 certificate that the client uses to authenticate to the service.

HttpDigest HttpDigest HttpDigest HttpDigest

Gets the current HTTP Digest credential.

IssuedToken IssuedToken IssuedToken IssuedToken

Use this property to specify the endpoint address and binding to use when contacting your local Security Token Service. This information is used when a service requires authentication using an issued token, but the policy of the service (represented as a binding on the client) does not explicitly specify how and where to obtain the issued token.

Peer Peer Peer Peer

Controls the credentials that a peer node uses to authenticate itself to other nodes in the mesh, as well as authentication settings that a peer node uses to authenticate other peer nodes.

SecurityTokenHandlerCollectionManager SecurityTokenHandlerCollectionManager SecurityTokenHandlerCollectionManager SecurityTokenHandlerCollectionManager

Gets or sets the security token handler for the client credential.

ServiceCertificate ServiceCertificate ServiceCertificate ServiceCertificate

Gets an object used to specify a service's X.509 certificate.

SupportInteractive SupportInteractive SupportInteractive SupportInteractive

Gets or sets a value that indicates whether the system is allowed to interactively prompt the user for credentials when necessary. For example, setting it to false might be desired in middle-tier scenarios.

UseIdentityConfiguration UseIdentityConfiguration UseIdentityConfiguration UseIdentityConfiguration

Gets or sets whether the client credentials uses identity configuration.

UserName UserName UserName UserName

Gets a credential object that you can use to set the user name and password that the client uses to authenticate itself to the service.

Windows Windows Windows Windows

Gets an object used to control the Windows credential that the client uses to authenticate itself to the service.

Methods

ApplyClientBehavior(ServiceEndpoint, ClientRuntime) ApplyClientBehavior(ServiceEndpoint, ClientRuntime) ApplyClientBehavior(ServiceEndpoint, ClientRuntime) ApplyClientBehavior(ServiceEndpoint, ClientRuntime)

Applies the specified client behavior to the endpoint.

Clone() Clone() Clone() Clone()

Creates a new copy of this ClientCredentials instance.

CloneCore() CloneCore() CloneCore() CloneCore()

Creates a new copy of this ClientCredentials instance.

CreateSecurityTokenManager() CreateSecurityTokenManager() CreateSecurityTokenManager() CreateSecurityTokenManager()

Creates a security token manager for this instance. This method is rarely called explicitly; it is primarily used in extensibility scenarios and is called by the system itself.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetInfoCardSecurityToken(Boolean, CardSpacePolicyElement[], SecurityTokenSerializer) GetInfoCardSecurityToken(Boolean, CardSpacePolicyElement[], SecurityTokenSerializer) GetInfoCardSecurityToken(Boolean, CardSpacePolicyElement[], SecurityTokenSerializer) GetInfoCardSecurityToken(Boolean, CardSpacePolicyElement[], SecurityTokenSerializer)

Generates and returns a security token using the CardSpace system and the specified policy chain and token serializer.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

IEndpointBehavior.AddBindingParameters(ServiceEndpoint, BindingParameterCollection) IEndpointBehavior.AddBindingParameters(ServiceEndpoint, BindingParameterCollection) IEndpointBehavior.AddBindingParameters(ServiceEndpoint, BindingParameterCollection) IEndpointBehavior.AddBindingParameters(ServiceEndpoint, BindingParameterCollection)

Adds this instance of this class to a binding parameter collection.

IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint, EndpointDispatcher) IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint, EndpointDispatcher) IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint, EndpointDispatcher) IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint, EndpointDispatcher)

Implements a modification or extension of the service across an endpoint.

IEndpointBehavior.Validate(ServiceEndpoint) IEndpointBehavior.Validate(ServiceEndpoint) IEndpointBehavior.Validate(ServiceEndpoint) IEndpointBehavior.Validate(ServiceEndpoint)

Reserved for future use.

Applies to