public void Init() { // Proxy to decrypt DO https _proxy = new XProxy(true); _proxy.ProxyFilters.Add(new MapsFilter()); _proxy.ProxyFilters.Add(new InternalMapFilter()); _proxy.Start(); // Gets the client connection Task.Run(new Action(InitiateConnection)); }
/* * * * [Route("mt100.asp")] * public HttpResponseMessage mt100() * { * var response = new HttpResponseMessage(HttpStatusCode.Forbidden); * try * { * Log.Info("Entered Into: " + "mt100.asp"); * return Get(Set(UriResolver("mt100.asp"),Request).GetResponse()); * } * catch (Exception e) * { * Log.Fatal(e); * Log.Info("Exception caused 403 in" + " mt100.asp"); * return response; * * } * } * * [Route("mt940.asp")] * public HttpResponseMessage mt940() * { * var response = new HttpResponseMessage(HttpStatusCode.Forbidden); * try * { * Log.Info("Entered Into: " + "mt940.asp"); * return Get(Set(UriResolver("mt940.asp"), Request).GetResponse()); * } * catch (Exception e) * { * Log.Fatal(e); * Log.Info("Exception caused 403 in" + " mt940.asp"); * return response; * * } * } * * * [Route("mt100")] * public HttpResponseMessage newmt100() * { * var response = new HttpResponseMessage(HttpStatusCode.Forbidden); * try * { * Log.Info("Entered Into: " + "newmt100"); * return Get(Set(UriResolver("newmt100"), Request).GetResponse()); * } * catch (Exception e) * { * Log.Fatal(e); * Log.Info("Exception caused 403 in" + " newmt100"); * return response; * * } * } * * * [Route("prmsg.asp")] * public HttpResponseMessage prmsg() * { * var response = new HttpResponseMessage(HttpStatusCode.Forbidden); * try * { * Log.Info("Entered Into: " + "prmsg.asp"); * return Get(Set(UriResolver("prmsg.asp"), Request).GetResponse()); * } * catch (Exception e) * { * Log.Fatal(e); * Log.Info("Exception caused 403 in" + " prmsg.asp"); * return response; * * } * } * * [Route("prreq.asp")] * public HttpResponseMessage prreq() * { * var response = new HttpResponseMessage(HttpStatusCode.ServiceUnavailable); * try * { * Log.Info("Entered Into: " + "prreq.asp"); * return Get(Set(UriResolver("prreq.asp"), Request).GetResponse()); * } * catch (HttpResponseException hre) * { * Log.Fatal(hre); * response = new HttpResponseMessage(hre.Response.StatusCode); * return response; * } * catch (Exception e) * { * Log.Fatal(e); * return response; * } * } * * [Route("sadad/bill")] * public HttpResponseMessage sadadbill() * { * var response = new HttpResponseMessage(HttpStatusCode.Forbidden); * try * { * Log.Info("Entered Into: " + "sadadbill"); * return Get(Set(UriResolver("sadadbill"), Request).GetResponse()); * } * catch (Exception e) * { * Log.Fatal(e); * Log.Info("Exception caused 403 in" + " sadadbill"); * return response; * * } * } * * [Route("sadad/moi")] * public HttpResponseMessage sadadmoi() * { * var response = new HttpResponseMessage(HttpStatusCode.Forbidden); * try * { * Log.Info("Entered Into: " + "sadadmoi"); * return Get(Set(UriResolver("sadadmoi"), Request).GetResponse()); * } * catch (Exception e) * { * Log.Fatal(e); * Log.Info("Exception caused 403 in" + " sadadmoi"); * return response; * * } * } * * * [Route("account/balance")] * public HttpResponseMessage accountbalance() * { * var response = new HttpResponseMessage(HttpStatusCode.Forbidden); * try * { * Log.Info("Entered Into: " + "accountbalance"); * return Get(Set(UriResolver("accountbalance"), Request).GetResponse()); * } * catch (Exception e) * { * Log.Fatal(e); * Log.Info("Exception caused 403 in" + " accountbalance"); * return response; * * } * } * * * [Route("payment/stop")] * public HttpResponseMessage paymentstop() * { * var response = new HttpResponseMessage(HttpStatusCode.Forbidden); * try * { * Log.Info("Entered Into: " + "paymentstop"); * return Get(Set(UriResolver("paymentstop"), Request).GetResponse()); * } * catch (Exception e) * { * Log.Fatal(e); * Log.Info("Exception caused 403 in" + " paymentstop"); * return response; * * } * } */ private static HttpWebRequest Set(XProxy xp, HttpRequestMessage m) { string clientCert = ""; Log.Info("Received Inbound request to uri" + xp.In); HttpWebRequest myrequest = (HttpWebRequest)HttpWebRequest.Create(xp.Out); if (m.GetClientCertificate() != null && myrequest.ClientCertificates.Count > 0) { Log.Info("Inbound request has certificate with serial number: " + System.Text.Encoding.ASCII.GetString(m.GetClientCertificate().GetSerialNumber())); clientCert = Base64Encode(ExportToPEM(m.GetClientCertificate())); myrequest.Headers.Add(xp.CertHeader + ": " + clientCert); myrequest.ClientCertificates.Add(m.GetClientCertificate()); } if (myrequest.ClientCertificates != null && myrequest.ClientCertificates.Count > 0) { Log.Debug("Outbound Request is having certificate with serial number: " + myrequest.ClientCertificates[0].GetSerialNumber()); Log.Debug("Outbound request passing certificate in header variable [" + xp.CertHeader + "]: " + myrequest.Headers[xp.CertHeader]); } if (m.Headers.Contains(xp.CertHeader)) { if (m.Headers.GetValues(xp.CertHeader).FirstOrDefault() != null) { Log.Info("Inbound request has variable [" + xp.CertHeader + "] in header"); myrequest.Headers.Add(xp.CertHeader + ": " + m.Headers.GetValues(xp.CertHeader).FirstOrDefault()); Log.Debug("Outbound request passing certificate in header variable [" + xp.CertHeader + "]: " + myrequest.Headers[xp.CertHeader]); } else { Log.Info("Inbound request has no variable [" + xp.CertHeader + "] in header"); } } else { Log.Warn("Inbound request has no client certificate," + " no certificate attached to Outbound request in header or request object"); } myrequest.Method = xp.HttpMethod.Trim(); Log.Debug("Setting Outbound request Verb: " + myrequest.Method); myrequest.ContentType = xp.ContentType.Trim(); Log.Debug("Setting Outboud request ContentType: " + myrequest.ContentType); if (Convert.ToInt32(xp.TimeOut.Trim()) == 0) { myrequest.Timeout = Timeout.Infinite; myrequest.ReadWriteTimeout = Timeout.Infinite; Log.Debug("Setting Outboud request time out to: Infinite"); Log.Debug("Setting Outboud ReadWrite time out to: Infinite"); } else { myrequest.Timeout = Convert.ToInt32(xp.TimeOut.Trim()); myrequest.ReadWriteTimeout = Convert.ToInt32(xp.TimeOut.Trim()); Log.Debug("Setting Outboud request time out to: " + myrequest.Timeout + " ms"); Log.Debug("Setting Outboud ReadWrite time out to: " + myrequest.ReadWriteTimeout + " ms"); } if (string.IsNullOrWhiteSpace(xp.HTTPUserAgent)) { myrequest.UserAgent = xp.HTTPUserAgent; } Log.Debug("Setting Outboud request user agent to: " + myrequest.UserAgent); if (xp.HTTPKeepAlive) { myrequest.KeepAlive = true; } else { myrequest.KeepAlive = false; } Log.Debug("Setting Outboud request KeepAlive to: " + myrequest.KeepAlive); using (Stream ds = myrequest.GetRequestStream()) { ds.Write(Get(m.Content.ReadAsStreamAsync().Result), 0, Convert.ToInt32(m.Content.ReadAsStreamAsync().Result.Length)); } Log.Debug("Outbound request Content Lenght is: " + myrequest.ContentLength); Log.Info("Sending Outbound request to uri" + xp.Out); return(myrequest); }