DefaultAuthenticationModule.cs 1016 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // System.Web.Security.DefaultAuthenticationModule
  3. //
  4. // Authors:
  5. // Gonzalo Paniagua Javier ([email protected])
  6. //
  7. // (C) 2002 Ximian, Inc (http://www.ximian.com)
  8. //
  9. using System.Web;
  10. using System.Security.Principal;
  11. namespace System.Web.Security
  12. {
  13. public sealed class DefaultAuthenticationModule : IHttpModule
  14. {
  15. static GenericIdentity defaultIdentity = new GenericIdentity ("", "");
  16. public event DefaultAuthenticationEventHandler Authenticate;
  17. public void Dispose ()
  18. {
  19. }
  20. public void Init (HttpApplication app)
  21. {
  22. app.DefaultAuthentication += new EventHandler (OnDefaultAuthentication);
  23. }
  24. void OnDefaultAuthentication (object sender, EventArgs args)
  25. {
  26. HttpApplication app = (HttpApplication) sender;
  27. HttpContext context = app.Context;
  28. if (context.User == null && Authenticate != null)
  29. Authenticate (this, new DefaultAuthenticationEventArgs (context));
  30. if (context.User == null)
  31. context.User = new GenericPrincipal (defaultIdentity, new string [0]);
  32. }
  33. }
  34. }