#region Copyright & License
//
// Copyright 2001-2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion
using System;
using log4net.Util;
namespace log4net.Core
{
///
/// The providers default instances.
///
///
///
/// A configured component that interacts with potentially protected system
/// resources uses a to provide the elevated
/// privileges required. If the object has
/// been not been explicitly provided to the component then the component
/// will request one from this .
///
///
/// By default the is
/// an instance of which returns only
/// 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
/// and overriding the method to return
/// the desired objects. The default provider
/// can be replaced by programmatically setting the value of the
/// 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 as an argument.
///
///
/// Nicko Cadell
public class SecurityContextProvider
{
///
/// The default provider
///
private static SecurityContextProvider s_defaultProvider = new SecurityContextProvider();
///
/// Gets or sets the default SecurityContextProvider
///
///
/// The default SecurityContextProvider
///
///
///
/// The default provider is used by configured components that
/// require a and have not had one
/// given to them.
///
///
/// By default this is an instance of
/// that returns objects.
///
///
/// The default provider can be set programmatically by setting
/// the value of this property to a sub class of
/// that has the desired behavior.
///
///
public static SecurityContextProvider DefaultProvider
{
get { return s_defaultProvider; }
set { s_defaultProvider = value; }
}
///
/// Protected default constructor to allow subclassing
///
///
///
/// Protected default constructor to allow subclassing
///
///
protected SecurityContextProvider()
{
}
///
/// Create a SecurityContext for a consumer
///
/// The consumer requesting the SecurityContext
/// An impersonation context
///
///
/// The default implementation is to return a .
///
///
/// Subclasses should override this method to provide their own
/// behavior.
///
///
public virtual SecurityContext CreateSecurityContext(object consumer)
{
return NullSecurityContext.Instance;
}
}
}