SecurityContext.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #region Apache License
  2. //
  3. // Licensed to the Apache Software Foundation (ASF) under one or more
  4. // contributor license agreements. See the NOTICE file distributed with
  5. // this work for additional information regarding copyright ownership.
  6. // The ASF licenses this file to you under the Apache License, Version 2.0
  7. // (the "License"); you may not use this file except in compliance with
  8. // the License. You may obtain a copy of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // Unless required by applicable law or agreed to in writing, software
  13. // distributed under the License is distributed on an "AS IS" BASIS,
  14. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. // See the License for the specific language governing permissions and
  16. // limitations under the License.
  17. //
  18. #endregion
  19. using System;
  20. namespace log4net.Core
  21. {
  22. /// <summary>
  23. /// A SecurityContext used by log4net when interacting with protected resources
  24. /// </summary>
  25. /// <remarks>
  26. /// <para>
  27. /// A SecurityContext used by log4net when interacting with protected resources
  28. /// for example with operating system services. This can be used to impersonate
  29. /// a principal that has been granted privileges on the system resources.
  30. /// </para>
  31. /// </remarks>
  32. /// <author>Nicko Cadell</author>
  33. public abstract class SecurityContext
  34. {
  35. /// <summary>
  36. /// Impersonate this SecurityContext
  37. /// </summary>
  38. /// <param name="state">State supplied by the caller</param>
  39. /// <returns>An <see cref="IDisposable"/> instance that will
  40. /// revoke the impersonation of this SecurityContext, or <c>null</c></returns>
  41. /// <remarks>
  42. /// <para>
  43. /// Impersonate this security context. Further calls on the current
  44. /// thread should now be made in the security context provided
  45. /// by this object. When the <see cref="IDisposable"/> result
  46. /// <see cref="IDisposable.Dispose"/> method is called the security
  47. /// context of the thread should be reverted to the state it was in
  48. /// before <see cref="Impersonate"/> was called.
  49. /// </para>
  50. /// </remarks>
  51. public abstract IDisposable Impersonate(object state);
  52. }
  53. }