Επεξεργασία

Κοινή χρήση μέσω


ServiceCredentials Class

Definition

Configures a service credential. Use this class to specify the credential for the service such as an X.509 certificate. Also, use this class to specify the authentication model for various client credentials such as user name and password validation.

public ref class ServiceCredentials : System::ServiceModel::Security::SecurityCredentialsManager, System::ServiceModel::Description::IServiceBehavior
public class ServiceCredentials : System.ServiceModel.Security.SecurityCredentialsManager, System.ServiceModel.Description.IServiceBehavior
type ServiceCredentials = class
    inherit SecurityCredentialsManager
    interface IServiceBehavior
Public Class ServiceCredentials
Inherits SecurityCredentialsManager
Implements IServiceBehavior
Inheritance
ServiceCredentials
Implements

Examples

The following code shows how to override this class to implement custom service credentials.

public class MyServiceCredentials : ServiceCredentials
{
    X509Certificate2 additionalCertificate;

    public MyServiceCredentials()
    {
    }

    protected MyServiceCredentials(MyServiceCredentials other)
        : base(other)
    {
        this.additionalCertificate = other.additionalCertificate;
    }

    public X509Certificate2 AdditionalCertificate
    {
        get
        {
            return this.additionalCertificate;
        }
        set
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            this.additionalCertificate = value;
        }
    }

    public override SecurityTokenManager CreateSecurityTokenManager()
    {
        return base.CreateSecurityTokenManager();
    }

    protected override ServiceCredentials CloneCore()
    {
        return new MyServiceCredentials(this);
    }
}
Public Class MyServiceCredentials
    Inherits ServiceCredentials
    Private additionalCertificateValue As X509Certificate2

    Public Sub New() 
    
    End Sub

    Protected Sub New(ByVal other As MyServiceCredentials) 
        MyBase.New(other)
        Me.additionalCertificate = other.additionalCertificate
    End Sub
    
    
    Public Property AdditionalCertificate() As X509Certificate2 
        Get
            Return Me.additionalCertificateValue
        End Get
        Set
            If value Is Nothing Then
                Throw New ArgumentNullException("value")
            End If
            Me.additionalCertificateValue = value
        End Set
    End Property

    Public Overrides Function CreateSecurityTokenManager() As SecurityTokenManager 
        Return MyBase.CreateSecurityTokenManager()
    
    End Function
    
    
    Protected Overrides Function CloneCore() As ServiceCredentials 
        Return New MyServiceCredentials(Me)
    
    End Function
End Class

Remarks

This class is used as a parameter in the BuildChannelListenerCore method, by methods of the ServiceCredentialsSecurityTokenManager, and is returned by the ServiceHostBase.Credentials property.

Constructors

ServiceCredentials()

Initializes a new instance of the ServiceCredentials class.

ServiceCredentials(ServiceCredentials)

Initializes a new instance of ServiceCredentials from the specified ServiceCredentials.

Properties

ClientCertificate

Gets the current client certificate authentication and provisioning settings for this service.

ExceptionMapper

Gets or sets the exception mapper associated with the service credentials.

IdentityConfiguration

Gets or sets the identity configuration for the service.

IssuedTokenAuthentication

Gets the current issued token (for example, SAML) authentication settings for this service.

Peer

Gets the current credential authentication and provisioning settings to be used by peer transport endpoints configured on the service.

SecureConversationAuthentication

Gets the current settings to be used by a secure conversation.

ServiceCertificate

Gets the current certificate associated with this service.

UseIdentityConfiguration

Gets or sets whether the service credential uses identity configuration.

UserNameAuthentication

Gets the current user name/password authentication settings for this service.

WindowsAuthentication

Gets the current Windows authentication settings for this service.

Methods

Clone()

Creates a copy of the current instance.

CloneCore()

Copies the essential members of the current instance.

CreateSecurityTokenManager()

Creates a token manager for this service.

Equals(Object)

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

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

IServiceBehavior.AddBindingParameters(ServiceDescription, ServiceHostBase, Collection<ServiceEndpoint>, BindingParameterCollection)

Adds this instance to a binding parameter collection. This is an infrastructure method and not intended to be called directly.

IServiceBehavior.ApplyDispatchBehavior(ServiceDescription, ServiceHostBase)

Apply the dispatch behavior. This is an infrastructure method and not intended to be called directly.

IServiceBehavior.Validate(ServiceDescription, ServiceHostBase)

Validates a service description. This is an infrastructure method and not intended to be called directly.

Applies to