Exemplo n.º 1
0
        private void GrabClientResponseMessageBeforeDeserialization(SoapMessage message)
        {
            AgentMessageTable ctx2      = AgentMessageTable.Instance;
            AgentMessageTable hashtable = AgentMessageTable.Instance;

            if (localhashcode == -1)
            {
                return;
            }
            MessageCorrelator mc = AgentMessageTable.GetRequestbyHash(localhashcode);

            if (mc != null)


            {
                try
                {
                    mc.ResponseMessage = StreamtoString(message.Stream);
                    if (mc.ResponseHeaders == null)
                    {
                        mc.ResponseHeaders = new NameValueCollection();
                    }
                    mc.ResponseHeaders.Add("Content-Encoding", message.ContentEncoding);
                    mc.ResponseHeaders.Add("Content-Type", message.ContentType);
                }
                catch (Exception ex)
                {
                    Logger.debug(ex);
                }
            }
        }
Exemplo n.º 2
0
        private void InsertHeadersOutbound(SoapMessage message, bool isclient)
        {
            MessageProcessor mp = MessageProcessor.Instance;

            if (MessageProcessor.GetConfig.DependencyInjectionEnabled)
            {
                string thread        = "";
                string thismessageid = "";
                if (localhashcode != -1)
                {
                    MessageCorrelator mc = AgentMessageTable.GetRequestbyHash(localhashcode);
                    if (mc != null)
                    {
                        mc.threadid = MessageProcessor.GetTransactionThreadId(Thread.CurrentContext.ContextID.ToString() + Thread.CurrentThread.ManagedThreadId.ToString() + ":" + Thread.GetDomainID().ToString() + Thread.CurrentThread.Name);
                        if (String.IsNullOrEmpty(mc.threadid))
                        {
                            mc.threadid = Guid.NewGuid().ToString();
                        }
                        thread        = mc.threadid;
                        thismessageid = mc.MessageID;
                        message.Headers.Add(new FGSMSSoapHeaderRelatedMessageASPNET(thismessageid));
                        message.Headers.Add(new FGSMSSoapHeaderTransactionThreadIdASPNET(thread));
                    }
                }
            }
        }
Exemplo n.º 3
0
        public override void Write(byte[] buffer, int offset, int count)
        {
            if (HttpContext.Current == null)
            {
                Logger.warn(this.GetType().FullName + " SniiferFilter, http context is null, calling assembly must be outside of IIS");
            }
            else
            {
                string strBuffer = System.Text.UTF8Encoding.UTF8.GetString(buffer, offset, count);
                responseHtml.Append(strBuffer);
                string response = responseHtml.ToString();



                try
                {
                    int k = System.Web.HttpContext.Current.Request.GetHashCode();
                    MessageCorrelator mc = AgentMessageTable.GetRequestbyHash(k);
                    //DateTime start = AgentMessageTable.GetRequestHash(k);
                    //if (start == null || start == DateTime.MinValue)
                    if (mc == null)
                    {
                        Logger.warn(this.GetType().FullName + " SniiferFilter unable to find corresponding request message to this response, it will be ignored.");
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(mc.soapAction))
                        {
                            string action = "urn:undeterminable";

                            action = System.Web.HttpContext.Current.Request.Headers["SOAPAction"];
                            if (!String.IsNullOrEmpty(action))
                            {
                                action = action.Replace("\"", "");
                                action = action.Replace("'", "");
                                if (String.IsNullOrEmpty(action))
                                {
                                    action = "urn:undeterminable";
                                }
                            }
                            if (action == "urn:undeterminable")
                            {
                                action = System.Web.HttpContext.Current.Request.HttpMethod;
                                action = action.Replace("\"", "");
                                action = action.Replace("'", "");
                                if (String.IsNullOrEmpty(action))
                                {
                                    action = "urn:undeterminable";
                                }
                            }
                        }

                        //string user = null;
                        if (mc.identity == null)
                        {
                            mc.identity = new List <string>();
                        }
                        if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
                        {
                            mc.identity.Add(System.Web.HttpContext.Current.User.Identity.Name);
                        }
                        mc.CompletedAt     = DateTime.Now;
                        mc.ResponseMessage = response;
                        mc.responsesize    = mc.ResponseMessage.Length;
                        mc.identity.Add(mc.ipaddress);
                        mc.agenttype = "org.miloss.fgsms.agents.AgentSoapExtension";
                        mc.IsFault   = AgentSoapExtension.IsFault(response);
                        try
                        {
                            //mc.ResponseHeaders = HttpContext.Current.Response.
                            try
                            {
                                mc.ResponseHeaders = HttpContext.Current.Response.Headers;
                            }
                            catch
                            {
                                mc.ResponseHeaders = new NameValueCollection();
                                mc.ResponseHeaders.Add("charset", HttpContext.Current.Response.Charset);
                                mc.ResponseHeaders.Add("ContentEncoding", HttpContext.Current.Response.ContentEncoding.WebName);
                                mc.ResponseHeaders.Add("ContentType", HttpContext.Current.Response.ContentType);
                                mc.ResponseHeaders.Add("soapAction", mc.soapAction);
                            }
                            mc.ipaddress = HttpContext.Current.Request.UserHostAddress;
                            if (HttpContext.Current.Request.ClientCertificate != null)
                            {
                                mc.ClientCertificate = new X509Certificate2(HttpContext.Current.Request.ClientCertificate.Certificate);
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.warn(ex, this.GetType().FullName + " SniiferFilter configuration error for " +
                                        mc.URL + " you'll have to enable IIS Intergrated Pipeline Mode when running IIS 7+. Items such as headers, remote requestor ips and certificate info will not be recorded");
                        }


                        MessageProcessor.ProcessMessage(mc);

                        /*
                         * MessageProcessor.ProcessMessage(System.Web.HttpContext.Current.Request.Url.ToString(),
                         *  start,
                         *  DateTime.Now,
                         *  action,
                         *  AgentMessageTable.GetRequestMessage(System.Web.HttpContext.Current.Request.GetHashCode()),
                         *  response,
                         *  System.Web.HttpContext.Current.Request.GetHashCode().ToString(),
                         *  AgentSoapExtension.IsFault(response),
                         *  System.Web.HttpContext.Current,
                         *  System.Web.HttpContext.Current.Request.UserHostAddress, "org.miloss.fgsms.agents.AgentSoapExtension",
                         *  user
                         *  );*/
                        AgentMessageTable.RemoveMessage(System.Web.HttpContext.Current.Request.GetHashCode());
                        Logger.debug(this.GetType().FullName + "SniiferFilter success to " + System.Web.HttpContext.Current.Request.Url.ToString());
                    }
                }
                catch (Exception ex)
                {
                    Logger.error(ex, "Error aquiring data from asp.net sniffer filter agent. please report.");

                    AgentMessageTable.RemoveMessage(System.Web.HttpContext.Current.Request.GetHashCode());
                }
                //byte[] data = System.Text.UTF8Encoding.UTF8.GetBytes(response);
            }
            responseStream.Write(buffer, offset, count);
        }