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.

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

public class ServiceCredentials : SecurityCredentialsManager, 
	IServiceBehavior

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

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

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

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

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

.NET Framework

Supported in: 3.5, 3.0

.NET Compact Framework

Supported in: 3.5

Community Additions

ADD
Show:
© 2014 Microsoft