Table of Contents

Class SecurityContextProvider

Namespace
log4net.Core
Assembly
log4net.dll

The SecurityContextProvider providers default SecurityContext instances.

public class SecurityContextProvider
Inheritance
SecurityContextProvider
Inherited Members

Remarks

A configured component that interacts with potentially protected system resources uses a SecurityContext to provide the elevated privileges required. If the SecurityContext object has been not been explicitly provided to the component then the component will request one from this SecurityContextProvider.

By default the DefaultProvider is an instance of SecurityContextProvider which returns only NullSecurityContext objects. This is a reasonable default where the privileges required are not know by the system.

This default behavior can be overridden by subclassing the SecurityContextProvider and overriding the CreateSecurityContext(object) method to return the desired SecurityContext objects. The default provider can be replaced by programmatically setting the value of the DefaultProvider property.

An alternative is to use the log4net.Config.SecurityContextProviderAttribute This attribute can be applied to an assembly in the same way as the log4net.Config.XmlConfiguratorAttribute". The attribute takes the type to use as the SecurityContextProvider as an argument.

Constructors

SecurityContextProvider()

Protected default constructor to allow subclassing

protected SecurityContextProvider()

Remarks

Protected default constructor to allow subclassing

Properties

DefaultProvider

Gets or sets the default SecurityContextProvider

public static SecurityContextProvider DefaultProvider { get; set; }

Property Value

SecurityContextProvider

The default SecurityContextProvider

Remarks

The default provider is used by configured components that require a SecurityContext and have not had one given to them.

By default this is an instance of SecurityContextProvider that returns NullSecurityContext objects.

The default provider can be set programmatically by setting the value of this property to a sub class of SecurityContextProvider that has the desired behavior.

Methods

CreateSecurityContext(object)

Create a SecurityContext for a consumer

public virtual SecurityContext CreateSecurityContext(object consumer)

Parameters

consumer object

The consumer requesting the SecurityContext

Returns

SecurityContext

An impersonation context

Remarks

The default implementation is to return a NullSecurityContext.

Subclasses should override this method to provide their own behavior.