Beispiel #1
0
 public virtual void SubmitChild(WebServer server, WebComponent source, WebSubmission values)
 {
     if (!string.IsNullOrEmpty(this.ID) && null != server.GetSubmitHandler(values.RawUrl, this.ID))
     {
         server.GetSubmitHandler(values.RawUrl, this.ID)(source, values);
     }
 }
Beispiel #2
0
 private void OnOptions(WebComponent source, WebSubmission values)
 {
     foreach (KeyValuePair <string, Tuple <WebOptionComponentDelegate, WebOptionSubmitDelegate> > kv in this._options_defaults)
     {
         kv.Value.Item2(values);
     }
     throw new WebRedirectException("/");
 }
Beispiel #3
0
 public override void SubmitContainer(WebServer server, WebComponent source, WebSubmission values)
 {
     if (null != server.GetSubmitHandler(values.RawUrl, "."))
     {
         server.GetSubmitHandler(values.RawUrl, ".")(source, values);
     }
     this.SubmitChildren(server, source, values);
 }
Beispiel #4
0
 protected void SubmitChildren(WebServer server, WebComponent source, WebSubmission values)
 {
     foreach (WebComponent child in this._children)
     {
         if (child.GetType().IsSubclassOf(typeof(WebContainer)))
         {
             ((WebContainer)child).SubmitContainer(server, source, values);
         }
         child.SubmitChild(server, source, values);
     }
 }
Beispiel #5
0
        private void OnOptionsRender(WebComponent source, WebSubmission values)
        {
            WebPage outpage = (WebPage)source;
            WebForm outform = (WebForm)outpage.Children.Find(o => !String.IsNullOrEmpty(o.ID) && o.ID.Equals("options"));

            foreach (KeyValuePair <string, Tuple <WebOptionComponentDelegate, WebOptionSubmitDelegate> > kv in this._options_defaults)
            {
                WebComponent comp = kv.Value.Item1(values);
                outform.Children.Add(new WebDiv("wrapper_" + kv.Key, "options_wrapper", comp));
            }

            outform.Children.Add(new WebDiv("wrapper_submit", "options_wrapper", new WebSubmit("Submit", "Submit", this.OnOptions)));
        }
Beispiel #6
0
        public override void SubmitContainer(WebServer server, WebComponent source, WebSubmission values)
        {
            string proc_xsrf_key    = String.Format("proc_xsrf_{0}", this.ID);
            string proc_xsrf_cookie = values.GetCookieIn(proc_xsrf_key).Value;
            string proc_xsrf_form   = values.PostData[proc_xsrf_key][0];

            if (!proc_xsrf_form.Equals(proc_xsrf_cookie))
            {
                throw new WebHTTPException(WebHTTPResponseCode.WEB_HTTP_403_ACCESS_DENIED, values.RawUrl);
            }
            else
            {
                this.SubmitChildren(server, source, values);
            }
        }
Beispiel #7
0
        private void OnLogin(WebComponent source, WebSubmission values)
        {
            string username   = values.PostData["username"][0];
            string password   = values.PostData["password"][0];
            bool   auth_valid = false;

            if (!this.AuthRequired)
            {
                return;
            }

            using (LdapConnection ldc = new LdapConnection(this.AuthDomainController)) {
                try {
                    NetworkCredential cred = new NetworkCredential(username, password, this.AuthDomain);
                    ldc.Credential = cred;
                    ldc.Bind();
                    auth_valid = true;
                } catch (LdapException ex) {
                    Trace.TraceError(ex.ServerErrorMessage);
                    Trace.TraceError(ex.Message);
                    auth_valid = false;
                }
            }

            if (!auth_valid)
            {
                throw new WebHTTPException(WebHTTPResponseCode.WEB_HTTP_401_BAD_AUTH, values.RawUrl);
            }
            else
            {
                string auth_token = Guid.NewGuid().ToString();
                values.SetCookieOut("auth_token", auth_token);
                this._auth_pairs.Add(new Tuple <string, string>(values.ClientHostname, auth_token));
                throw new WebRedirectException("/");
            }
        }
Beispiel #8
0
 public WebTableHeadCell(WebComponent c) : base(c)
 {
     this._tagname = "th";
 }
Beispiel #9
0
 public WebCell(WebComponent c)
 {
     this._tagname = "td";
     this.Children.Add(c);
 }
Beispiel #10
0
 public virtual void SubmitContainer(WebServer server, WebComponent source, WebSubmission values)
 {
     this.SubmitChildren(server, source, values);
 }