+2003-01-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpModulesConfigurationHandler.cs: add a default authentication
+ module at the end of the list.
+
+ * ModuleItem.cs: new constructor.
+
2002-12-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* AuthConfig.cs: LoginUrl defaults to login.aspx.
HandlersUtil.ThrowException ("Unrecognized element", child);
}
+ mapper.Add (new ModuleItem ("DefaultAuthentication", typeof (DefaultAuthenticationModule)));
return mapper;
}
}
throw new HttpException(HttpRuntime.FormatResourceString("type_not_module"));
}
+ public ModuleItem(string name, Type type) {
+ _typeName = type.ToString ();
+ _name = name;
+ _type = type;
+ if (!typeof(IHttpModule).IsAssignableFrom(_type))
+ throw new HttpException(HttpRuntime.FormatResourceString("type_not_module"));
+ }
+
public IHttpModule Create() {
return (IHttpModule) HttpRuntime.CreateInternalObject(_type);
}
+2003-01-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DefaultAuthenticationModule.cs: implemented. It just create a default
+ unauthenticated user when no one else provided one.
+
+ * FormsAuthenticationModule.cs: removed debug output.
+
2002-12-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* FormsAuthenticationModule.cs: remove debug lines.
//
using System.Web;
+using System.Security.Principal;
namespace System.Web.Security
{
public sealed class DefaultAuthenticationModule : IHttpModule
{
+ static GenericIdentity defaultIdentity = new GenericIdentity ("", "");
+
public event DefaultAuthenticationEventHandler Authenticate;
public void Dispose ()
{
}
- [MonoTODO]
public void Init (HttpApplication app)
{
- throw new NotImplementedException ();
+ app.DefaultAuthentication += new EventHandler (OnDefaultAuthentication);
+ }
+
+ void OnDefaultAuthentication (object sender, EventArgs args)
+ {
+ HttpApplication app = (HttpApplication) sender;
+ HttpContext context = app.Context;
+
+ if (context.User == null && Authenticate != null)
+ Authenticate (this, new DefaultAuthenticationEventArgs (context));
+
+ if (context.User == null)
+ context.User = new GenericPrincipal (defaultIdentity, new string [0]);
}
}
}
}
HttpCookie cookie = context.Request.Cookies [cookieName];
- if (cookie == null || (cookie.Expires != DateTime.MinValue && cookie.Expires < DateTime.Now))
+ if (cookie == null || (cookie.Expires != DateTime.MinValue && cookie.Expires < DateTime.Now)) {
return;
+ }
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt (cookie.Value);
FormsAuthentication.RenewTicketIfOld (ticket);
context.User = new GenericPrincipal (new FormsIdentity (ticket), new string [0]);
- Console.WriteLine ("name: " + ticket.Name);
cookie.Value = FormsAuthentication.Encrypt (ticket);
cookie.Path = cookiePath;
return;
AuthConfig config = (AuthConfig) context.GetConfig ("system.web/authentication");
- Console.WriteLine ("Redirecting to login page: '{0}'", config.LoginUrl);
context.Response.Redirect (config.LoginUrl);
}
+2003-01-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs:
+ (AddedControl): take the children to the same state of the parent.
+ (InitRecursive): set the page of the children.
+
+ * Page.cs: removed one line (it's done a few lines above).
+
+ * UserControl.cs:
+ (OnInit): always call InitializeAsUserControl
+ (InitializeAsUserControl): sets the page for the control.
+
2003-01-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* Control.cs: fixed bug #36037.
private bool creatingControls = false;\r
private bool bindingContainer = true;\r
private bool autoEventWireup = true;\r
+\r
+ bool inited = false;\r
+ bool loaded = false;\r
+ bool prerendered = false;\r
\r
private DataBindingCollection dataBindings = null;\r
\r
if (control.AutoID == true && control.ID == null)\r
control.ID = ID + "_ctrl_" + defaultNumberID++;\r
\r
- control.InitRecursive (_isNamingContainer ? this : NamingContainer);\r
- control.LoadRecursive ();\r
- control.PreRenderRecursiveInternal ();\r
+ if (inited)\r
+ control.InitRecursive (_isNamingContainer ? this : NamingContainer);\r
+\r
+ if (loaded)\r
+ control.LoadRecursive ();\r
+\r
+ if (prerendered)\r
+ control.PreRenderRecursiveInternal ();\r
}\r
\r
protected virtual void AddParsedSubObject(object obj) //DIT\r
protected virtual Control FindControl(string id, int pathOffset)\r
{\r
//TODO: I think there is Naming Container stuff here. Redo.\r
- int i;\r
- Control ctrl;\r
- for (i = pathOffset; i < _controls.Count; i++){\r
- ctrl = _controls [i];\r
+ EnsureChildControls ();\r
+ if (_controls == null)\r
+ return null;\r
+\r
+ for (int i = pathOffset; i < _controls.Count; i++){\r
+ Control ctrl = _controls [i];\r
\r
if (ctrl.ID == id)\r
return ctrl;\r
\r
- if (ctrl.Controls.Count > 0){\r
+ if (ctrl._controls != null && ctrl._controls.Count > 0){\r
Control other = ctrl.FindControl (id);\r
if (other != null)\r
return other;\r
{\r
OnLoad(EventArgs.Empty);\r
if (_controls != null) foreach (Control c in _controls) c.LoadRecursive();\r
+ loaded = true;\r
}\r
\r
protected void UnloadRecursive(Boolean dispose)\r
foreach (Control c in _controls)\r
c.PreRenderRecursiveInternal ();\r
}\r
+ prerendered = true;\r
}\r
\r
protected void InitRecursive(Control namingContainer)\r
{\r
- if (_controls != null) foreach (Control c in _controls) c.InitRecursive(namingContainer);\r
- OnInit(EventArgs.Empty);\r
+ if (_controls != null) {\r
+ foreach (Control c in _controls) {\r
+ c._page = Page;\r
+ c.InitRecursive (namingContainer);\r
+ }\r
+ }\r
+\r
+ OnInit (EventArgs.Empty);\r
TrackViewState ();\r
+ inited = true;\r
}\r
\r
internal object SaveViewStateRecursive()\r
WebTrace.WriteLine ("InitRecursive");
InitRecursive (null);
renderingForm = false;
- _context = context;
if (IsPostBack) {
LoadPageViewState ();
ProcessPostData (DeterminePostBackMode (), false);
if (initialized)
return;
initialized = true;
+ this.Page = page;
WireupAutomaticEvents ();
FrameworkInitialize ();
}
protected override void OnInit (EventArgs e)
{
- if (Page != null)
- InitializeAsUserControl (Page);
+ InitializeAsUserControl (Page);
base.OnInit(e);
}
+2003-01-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplication.cs: added new state to handle default authentication.
+
2003-01-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* HttpContext.cs: removed hack to get the User.
// ID objects used to indentify the event
static object AcquireRequestStateId = new Object ();
static object AuthenticateRequestId = new Object ();
+ static object DefaultAuthenticationId = new Object ();
static object EndRequestId = new Object ();
static object DisposedId = new Object ();
static object BeginRequestId = new Object ();
remove { Events.RemoveHandler (PreSendRequestHeadersId, value); }
}
+ internal event EventHandler DefaultAuthentication {
+ add { Events.AddHandler (DefaultAuthenticationId, value); }
+ remove { Events.RemoveHandler (DefaultAuthenticationId, value); }
+ }
+
public void AddOnAcquireRequestStateAsync (BeginEventHandler beg, EndEventHandler end)
{
if (null == _acquireRequestStateAsync)
_app._authenticateRequestAsync.GetAsStates (_app, states);
GetAsStates (HttpApplication.AuthenticateRequestId, states);
+ // DefaultAuthentication
+ EventHandler defaultAuthHandler = (EventHandler) _app.Events [HttpApplication.DefaultAuthenticationId];
+ states.Add (new EventState (_app, defaultAuthHandler));
+
// AuthorizeRequest
if (null != _app._authorizeRequestAsync)
_app._authorizeRequestAsync.GetAsStates (_app, states);