Example #1
0
        public void OnFileRequested(HttpRequest request, IDirectory directory)
        {
            request.Response.ResponseContent = new MemoryStream();
            StreamWriter writer = new StreamWriter(request.Response.ResponseContent);

            StreamReader reader = new StreamReader(request.PostData);
            string       post   = reader.ReadToEnd();

            reader.Dispose();
            Dictionary <string, string> POST = AjaxLife.PostDecode(post);

            Hashtable hash = new Hashtable();

            hash.Add("SESSION_ID", POST["sid"]);
            hash.Add("STATIC_ROOT", AjaxLife.STATIC_ROOT);

            Html.Template.Parser parser = new Html.Template.Parser(hash);
            writer.Write(parser.Parse(File.ReadAllText("client/Templates/iPhone.html")));;
            writer.Flush();
        }
Example #2
0
        public void OnFileRequested(HttpRequest request, IDirectory directory)
        {
            request.Response.ResponseContent = new MemoryStream();
            StreamWriter writer = new StreamWriter(request.Response.ResponseContent);

            try{
                Hashtable hash = new Hashtable();
                // Set up the template with useful details and the challenge and public key.
                hash.Add("STATIC_ROOT", AjaxLife.STATIC_ROOT);
                hash.Add("API_ROOT", AjaxLife.API_ROOT);
                if (AjaxLife.HANDLE_CONTENT_ENCODING)
                {
                    hash.Add("ENCODING", "identity");
                    // S3 doesn't support Accept-Encoding, so we do it ourselves.
                    if (request.Headers["Accept-Encoding"] != null)
                    {
                        string[] accept = request.Headers["Accept-Encoding"].Split(',');
                        foreach (string encoding in accept)
                        {
                            string parsedencoding = encoding.Split(';')[0].Trim();
                            if (parsedencoding == "gzip" || parsedencoding == "*") // Should we really honour "*"? Specs aside, it's never going to be true.
                            {
                                hash["ENCODING"] = "gzip";
                                break;
                            }
                        }
                    }
                }
                Html.Template.Parser parser = new Html.Template.Parser(hash);
                writer.Write(parser.Parse(File.ReadAllText("client/Templates/index.html")));
            }catch (Exception exception) {
                this.contenttype = "text/plain";
                writer.WriteLine("Error: " + exception.Message);
            }
            writer.Flush();
        }
Example #3
0
 public void OnFileRequested(HttpRequest request, IDirectory directory)
 {
     request.Response.ResponseContent = new MemoryStream();
     StreamWriter writer = new StreamWriter(request.Response.ResponseContent);
     try{
         Hashtable hash = new Hashtable();
         // Set up the template with useful details and the challenge and public key.
         hash.Add("STATIC_ROOT", AjaxLife.STATIC_ROOT);
         if (AjaxLife.HANDLE_CONTENT_ENCODING)
         {
             hash.Add("ENCODING", "identity");
             // S3 doesn't support Accept-Encoding, so we do it ourselves.
             if (request.Headers["Accept-Encoding"] != null)
             {
                 string[] accept = request.Headers["Accept-Encoding"].Split(',');
                 foreach (string encoding in accept)
                 {
                     string parsedencoding = encoding.Split(';')[0].Trim();
                     if (parsedencoding == "gzip" || parsedencoding == "*") // Should we really honour "*"? Specs aside, it's never going to be true.
                     {
                         hash["ENCODING"] = "gzip";
                         break;
                     }
                 }
             }
         }
         Html.Template.Parser parser = new Html.Template.Parser(hash);
         writer.Write(parser.Parse(File.ReadAllText("Html/Templates/index.html")));
     }catch(Exception exception){
         this.contenttype = "text/plain";
         writer.WriteLine("Error: " + exception.Message);
     }
     writer.Flush();
 }
Example #4
0
 public void OnFileRequested(HttpRequest request, IDirectory directory)
 {
     request.Response.ResponseContent = new MemoryStream();
     StreamWriter writer = new StreamWriter(request.Response.ResponseContent);
     try
     {
         // Generate a new session ID.
         Guid key = Guid.NewGuid();
         // Create a new User.
         User user = new User();
         // Set the user session properties.
         user.LastRequest = DateTime.Now;
         user.Rotation = -Math.PI;
         // Generate a single-use challenge key.
         user.Challenge = "123";
         // Add the session to the users.
         lock (users) users.Add(key, user);
         Hashtable hash = new Hashtable();
         // Set up the template with useful details and the challenge and public key.
         hash.Add("STATIC_ROOT", deviMobile.STATIC_ROOT);
         hash.Add("SESSION_ID", key.ToString("D"));
         hash.Add("CHALLENGE", user.Challenge);
         // Make the grid list, ensuring the default one is selected.
         string grids = "";
         foreach (string server in deviMobile.LOGIN_SERVERS.Keys)
         {
             grids += "<option value=\"" + System.Web.HttpUtility.HtmlAttributeEncode(server) +
                 "\"" + (server == deviMobile.DEFAULT_LOGIN_SERVER ? " selected=\"selected\"" : "") + ">" +
                 System.Web.HttpUtility.HtmlEncode(server) + "</option>\n";
         }
         hash.Add("GRID_OPTIONS", grids);
         if (deviMobile.HANDLE_CONTENT_ENCODING)
         {
             hash.Add("ENCODING", "identity");
             // S3 doesn't support Accept-Encoding, so we do it ourselves.
             if (request.Headers["Accept-Encoding"] != null)
             {
                 string[] accept = request.Headers["Accept-Encoding"].Split(',');
                 foreach (string encoding in accept)
                 {
                     string parsedencoding = encoding.Split(';')[0].Trim();
                     if (parsedencoding == "gzip" || parsedencoding == "*") // Should we really honour "*"? Specs aside, it's never going to be true.
                     {
                         hash["ENCODING"] = "gzip";
                         break;
                     }
                 }
             }
         }
         // Parse the template.
         Html.Template.Parser parser = new Html.Template.Parser(hash);
         writer.Write(parser.Parse(File.ReadAllText("Html/Templates/index.html")));
     }
     catch (Exception exception)
     {
         this.contenttype = "text/plain";
         writer.WriteLine("Error: " + exception.Message);
     }
     writer.Flush();
 }
Example #5
0
        public void OnFileRequested(HttpRequest request, IDirectory directory)
        {
            request.Response.ResponseContent = new MemoryStream();
            StreamWriter writer = new StreamWriter(request.Response.ResponseContent);

            StreamReader reader = new StreamReader(request.PostData);
            string post = reader.ReadToEnd();
            reader.Dispose();
            Dictionary<string, string> POST = AjaxLife.PostDecode(post);

            Hashtable hash = new Hashtable();
            hash.Add("SESSION_ID", POST["sid"]);
            hash.Add("STATIC_ROOT", AjaxLife.STATIC_ROOT);

            Html.Template.Parser parser = new Html.Template.Parser(hash);
            writer.Write(parser.Parse(File.ReadAllText("Html/Templates/iPhone.html")));;
            writer.Flush();
        }
Example #6
0
        public void OnFileRequested(HttpRequest request, IDirectory directory)
        {
            request.Response.ResponseContent = new MemoryStream();
            StreamWriter writer = new StreamWriter(request.Response.ResponseContent);

            try
            {
                // Generate a new session ID.
                Guid key = Guid.NewGuid();
                // Create a new User.
                User user = new User();
                // Set the user session properties.
                user.LastRequest = DateTime.Now;
                user.Rotation    = -Math.PI;
                // Generate a single-use challenge key.
                user.Challenge = RSACrypto.CreateChallengeString(AjaxLife.RSAp);
                // Add the session to the users.
                lock (users) users.Add(key, user);
                Hashtable hash = new Hashtable();
                // Set up the template with useful details and the challenge and public key.
                hash.Add("STATIC_ROOT", AjaxLife.STATIC_ROOT);
                hash.Add("SESSION_ID", key.ToString("D"));
                hash.Add("CHALLENGE", user.Challenge);
                hash.Add("RSA_EXPONENT", StringHelper.BytesToHexString(AjaxLife.RSAp.Exponent));
                hash.Add("RSA_MODULUS", StringHelper.BytesToHexString(AjaxLife.RSAp.Modulus));
                // Make the grid list, ensuring the default one is selected.
                string grids = "";
                foreach (string server in AjaxLife.LOGIN_SERVERS.Keys)
                {
                    grids += "<option value=\"" + System.Web.HttpUtility.HtmlAttributeEncode(server) +
                             "\"" + (server == AjaxLife.DEFAULT_LOGIN_SERVER ? " selected=\"selected\"" : "") + ">" +
                             System.Web.HttpUtility.HtmlEncode(server) + "</option>\n";
                }
                hash.Add("GRID_OPTIONS", grids);
                if (AjaxLife.HANDLE_CONTENT_ENCODING)
                {
                    hash.Add("ENCODING", "identity");
                    // S3 doesn't support Accept-Encoding, so we do it ourselves.
                    if (request.Headers["Accept-Encoding"] != null)
                    {
                        string[] accept = request.Headers["Accept-Encoding"].Split(',');
                        foreach (string encoding in accept)
                        {
                            string parsedencoding = encoding.Split(';')[0].Trim();
                            if (parsedencoding == "gzip" || parsedencoding == "*") // Should we really honour "*"? Specs aside, it's never going to be true.
                            {
                                hash["ENCODING"] = "gzip";
                                break;
                            }
                        }
                    }
                }
                // Parse the template.
                Html.Template.Parser parser = new Html.Template.Parser(hash);
                writer.Write(parser.Parse(File.ReadAllText("Html/Templates/AjaxLife.html")));
            }
            catch (Exception exception)
            {
                this.contenttype = "text/plain";
                writer.WriteLine("Error: " + exception.Message);
            }
            writer.Flush();
        }