private void RequestAuthentication(HttpApplication app)
 {
     ApplicationServices appServices = new ApplicationServices();
     app.Response.AppendHeader("WWW-Authenticate", String.Format("Basic realm=\"{0}\"", appServices.Realm));
     app.Response.StatusCode = 401;
     app.CompleteRequest();
 }
 private void contextAuthenticateRequest(object sender, EventArgs e)
 {
     HttpApplication app = ((HttpApplication)(sender));
     ApplicationServices appServices = new ApplicationServices();
     if (!(appServices.RequiresAuthentication(app.Context.Request)))
         return;
     if (appServices.AuthenticateRequest(app.Context))
         return;
     HttpCookie c = app.Request.Cookies[FormsAuthentication.FormsCookieName];
     if (c != null)
     {
         FormsAuthenticationTicket t = FormsAuthentication.Decrypt(c.Value);
         if (!(String.IsNullOrEmpty(t.Name)))
             return;
     }
     string authorization = app.Request.Headers["Authorization"];
     if (String.IsNullOrEmpty(authorization))
         RequestAuthentication(app);
     else
         if (authorization.StartsWith("Basic", StringComparison.CurrentCultureIgnoreCase))
             ValidateUserIdentity(app, authorization);
         else
             RequestAuthentication(app);
 }
 public object Themes()
 {
     return(ApplicationServices.Themes());
 }
 public string[] Roles()
 {
     return(ApplicationServices.Roles());
 }
 public void Logout()
 {
     ApplicationServices.Logout();
 }
 public object Login(string username, string password, bool createPersistentCookie)
 {
     return(ApplicationServices.Login(username, password, createPersistentCookie));
 }