Esempio n. 1
0
        public HttpResponseMessage Dropbox(string challenge)
        //public ActionResult Dropbox(string challenge)
        {
            LogSingleton.Info(challenge);

            var resp = new HttpResponseMessage(HttpStatusCode.OK);

            resp.Content = new StringContent(challenge, System.Text.Encoding.UTF8, "text/plain");
            return(resp);

            //return Content(challenge);
            //  return challenge;
        }
Esempio n. 2
0
        // public async Task<ActionResult> Dropbox()
        public HttpResponseMessage Dropbox()
        {
            LogSingleton.Info("dropbox start");

            // Get the request signature
            var signatureHeader = Request.Headers.GetValues("X-Dropbox-Signature");

            if (signatureHeader == null || !signatureHeader.Any())
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            // Get the signature value
            string signature = signatureHeader.FirstOrDefault();

            // Extract the raw body of the request
            string body = null;

            body = Request.Content.ReadAsStringAsync().Result;

            //using (StreamReader reader = new StreamReader(Request.InputStream))
            //{
            //    body = await reader.ReadToEndAsync();
            //}

            // Check that the signature is good
            string appSecret = ConfigurationManager.AppSettings["Dropbox_AppSecret"];

            using (HMACSHA256 hmac = new HMACSHA256(Encoding.UTF8.GetBytes(appSecret)))
            {
                if (!VerifySha256Hash(hmac, body, signature))
                {
                    //     return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                    return(this.Request.CreateResponse(HttpStatusCode.BadRequest));
                }
            }

            LogSingleton.Info(body);

            // Do your thing here... e.g. store it in a queue to process later
            // ...

            // Return A-OK :)
            //          return new HttpStatusCodeResult(HttpStatusCode.OK);
            return(this.Request.CreateResponse(HttpStatusCode.OK));
        }
Esempio n. 3
0
        public HttpResponseMessage GetFormWebhook()
        {
            string body = Request.Content.ReadAsStringAsync().Result;

            LogSingleton.Info(body);

            var platoformparser = new PlatoformParser();

            try
            {
                PlatoformsWebHookResponse response = JsonConvert.DeserializeObject <PlatoformsWebHookResponse>(body);

                using (var context = new ApplicationDbContext())
                {
                    platoformparser.AddToDB(context, 1, "id", response.PFProperty[0].id);
                    platoformparser.AddToDB(context, 1, "submit_date", response.PFProperty[0].submit_date);
                    platoformparser.AddToDB(context, 1, "submit_revision", response.PFProperty[0].submit_revision);
                    platoformparser.AddToDB(context, 1, "published_form_revision", response.PFProperty[0].published_form_revision);
                    platoformparser.AddToDB(context, 1, "submit_form_sharing_creator_url", response.PFProperty[0].submit_form_sharing_creator_url);
                    platoformparser.AddToDB(context, 1, "submit_form_url", response.PFProperty[0].submit_form_url);
                    platoformparser.AddToDB(context, 1, "form.id", response.PFProperty[0].form.id);
                    platoformparser.AddToDB(context, 1, "form.name", response.PFProperty[0].form.name);
                    platoformparser.AddToDB(context, 1, "workflow_id", response.PFProperty[0].workflow_id);
                    platoformparser.AddToDB(context, 1, "workflow_step_id", response.PFProperty[0].workflow_step_id);
                    platoformparser.AddToDB(context, 1, "workflow_next_step_url", response.PFProperty[0].workflow_next_step_url);
                    platoformparser.AddToDB(context, 1, "workflow_next_step_api_url", response.PFProperty[0].workflow_next_step_api_url);
                    platoformparser.AddToDB(context, 1, "pdf.id", response.PFProperty[0].pdf[0]?.id);
                    platoformparser.AddToDB(context, 1, "pdf.template_id", response.PFProperty[0].pdf[0]?.template_id);
                    platoformparser.AddToDB(context, 1, "pdf.display_name", response.PFProperty[0].pdf[0]?.display_name);
                    platoformparser.AddToDB(context, 1, "pdf.name", response.PFProperty[0].pdf[0]?.name);
                    platoformparser.AddToDB(context, 1, "pdf.url", response.PFProperty[0].pdf[0]?.url);

                    foreach (var data in response.PFProperty[0].submit_data)
                    {
                        platoformparser.AddToDB(context, 1, data.id, data.value);
                    }
                }
            }
            catch (Exception)
            {
                LogSingleton.Error($"Platoforms body didn't deserialize..... {body}");
            }

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Esempio n. 4
0
        public void Configuration(IAppBuilder app)
        {
            LogSingleton.Info("starting up");

            app.MapSignalR();
            // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=316888

            app.UseCors(CorsOptions.AllowAll);

            OAuthAuthorizationServerOptions option = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath         = new PathString("/token"),
                Provider                  = new ApplicationOAuthProvider(),
                AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(60),
                AllowInsecureHttp         = true
            };

            app.UseOAuthAuthorizationServer(option);
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
        }