Class UserCredentialsEndpointBehaviorExtension
Provides configuration extension element for an endpoint behavior that allows to populate the client User Name and Windows credentials from the configuration file. Note that providing clear text credentials in configuration file is not secure and must be used with configuration encryption option or for testing purposes only.
Namespace: Nevatech.Vsb.Repository.Services
Assembly: Nevatech.Vsb.Repository.dll
Syntax
public sealed class UserCredentialsEndpointBehaviorExtension : BehaviorExtensionElement
Remarks
The sample configuration would look like the following:
<system.serviceModel> <behaviors> <endpointBehaviors> <behavior name="UserCredentials"> <clientCredentials /> <userCredentials enableHttpPreAuthentication="true" encrypted="false"> <userName userName="user" password="password"/> <windows userName="user" password="password" domain="domain"/> </userCredentials> </behavior> </endpointBehaviors> </behaviors> <extensions> <behaviorExtensions> <add name="userCredentials" type="Nevatech.Vsb.Repository.Services.UserCredentialsEndpointBehaviorExtension, Nevatech.Vsb.Repository"/> </behaviorExtensions> </extensions> </system.serviceModel>
Note that due to some internal WCF issue the <clientCredentials/> element must be present in the same behavior configuration element before <userCredentials/> element. However this is not required, if client credentials are set programmatically, as it is done, for example, in Sentinet.
Constructors
UserCredentialsEndpointBehaviorExtension()
Declaration
public UserCredentialsEndpointBehaviorExtension()
Fields
IsEncryptedElementName
Name of the element representing the flag indicating that provided client credentials are encrypted.
Declaration
public const string IsEncryptedElementName = "encrypted"
Field Value
Type | Description |
---|---|
String |
PreAuthenticationEnabledElementName
Name of the element representing the flag to control HTTP(S) Basic Pre-Authentication enablement in the configuration element.
Declaration
public const string PreAuthenticationEnabledElementName = "enableHttpPreAuthentication"
Field Value
Type | Description |
---|---|
String |
UserNameElementName
Name of the element representing the user name credentials in the configuration element.
Declaration
public const string UserNameElementName = "userName"
Field Value
Type | Description |
---|---|
String |
WindowsElementName
Name of the element representing the Windows credentials in the configuration element.
Declaration
public const string WindowsElementName = "windows"
Field Value
Type | Description |
---|---|
String |
Properties
BehaviorType
Gets the type of the configured endpoint behavior.
Declaration
public override Type BehaviorType { get; }
Property Value
Type | Description |
---|---|
Type |
IsEncrypted
Gets or sets the flag indicating that provided client credentials are encrypted using Windows Data Protection API.
Declaration
public bool IsEncrypted { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
PreAuthenticationEnabled
Gets or sets the flag indicating that client credentials should be passed to the server on the very first call without waiting for a negotiation challenge if HTTP Basic Authentication is used.
Declaration
public bool PreAuthenticationEnabled { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
The actual username credentials can either be explicitly provided in the UserName property (first choice) or extracted from the existing ClientCredentials instance.
Properties
Gets collection of configuration element properties.
Declaration
protected override ConfigurationPropertyCollection Properties { get; }
Property Value
Type | Description |
---|---|
ConfigurationPropertyCollection |
UserName
Gets the user name credentials configuration element.
Declaration
public UserNameCredentialsElement UserName { get; }
Property Value
Type | Description |
---|---|
UserNameCredentialsElement |
Windows
Gets the Windows credentials configuration element.
Declaration
public WindowsCredentialsElement Windows { get; }
Property Value
Type | Description |
---|---|
WindowsCredentialsElement |
Methods
CreateBehavior()
Returns a new instance of the endpoint behavior.
Declaration
protected override object CreateBehavior()
Returns
Type | Description |
---|---|
Object | New configured instance of the endpoint behavior. |
Encrypt(String)
Encrypts the provided string in order to be used with encrypted configuration.
Declaration
public static string Encrypt(string value)
Parameters
Type | Name | Description |
---|---|---|
String | value | Value to be encrypted. |
Returns
Type | Description |
---|---|
String | Encrypted string suitable for using with encrypted configuration. |