Export (0) Print
Expand All

ServiceCredentials Class

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.

System.Object
  System.ServiceModel.Security.SecurityCredentialsManager
    System.ServiceModel.Description.ServiceCredentials

Namespace:  System.ServiceModel.Description
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public class ServiceCredentials : SecurityCredentialsManager, 
	IServiceBehavior

The ServiceCredentials type exposes the following members.

  NameDescription
Public methodServiceCredentials()Initializes a new instance of the ServiceCredentials class.
Protected methodServiceCredentials(ServiceCredentials)Initializes a new instance of ServiceCredentials from the specified ServiceCredentials.
Top

  NameDescription
Public propertyClientCertificateGets the current client certificate authentication and provisioning settings for this service.
Public propertyExceptionMapperGets or sets the exception mapper associated with the service credentials.
Public propertyIdentityConfigurationGets or sets the identity configuration for the service.
Public propertyIssuedTokenAuthenticationGets the current issued token (for example, SAML) authentication settings for this service.
Public propertyPeerGets the current credential authentication and provisioning settings to be used by peer transport endpoints configured on the service.
Public propertySecureConversationAuthenticationGets the current settings to be used by a secure conversation.
Public propertyServiceCertificateGets the current certificate associated with this service.
Public propertyUseIdentityConfigurationGets or sets whether the service credential uses identity configuration.
Public propertyUserNameAuthenticationGets the current user name/password authentication settings for this service.
Public propertyWindowsAuthenticationGets the current Windows authentication settings for this service.
Top

  NameDescription
Public methodCloneCreates a copy of the current instance.
Protected methodCloneCoreCopies the essential members of the current instance.
Public methodCreateSecurityTokenManagerCreates a token manager for this service. (Overrides SecurityCredentialsManager.CreateSecurityTokenManager().)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate methodIServiceBehavior.AddBindingParametersInfrastructure. Adds this instance to a binding parameter collection. This is an infrastructure method and not intended to be called directly.
Explicit interface implemetationPrivate methodIServiceBehavior.ApplyDispatchBehaviorInfrastructure. Apply the dispatch behavior. This is an infrastructure method and not intended to be called directly.
Explicit interface implemetationPrivate methodIServiceBehavior.ValidateInfrastructure. Validates a service description. This is an infrastructure method and not intended to be called directly.
Top

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

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);
    }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft