private WsAuthToken GetWsAuthToken(Message message)
        {
            WsAuthToken wsAuthToken = null;

            for (var i = 0; i < message.Headers.Count; i++)
            {
                if (message.Headers[i].Name.ToUpper() == "REQUESTORSYSTEM")
                {
                    using var reader = message.Headers.GetReaderAtHeader(i);
                    reader.Read();
                    var serializer = new XmlSerializer(typeof(string));
                    wsAuthToken.Requestor = (string)serializer.Deserialize(reader);
                }

                if (message.Headers[i].Name.ToUpper() == "SUBSCRIBERSYSTEM")
                {
                    using var reader = message.Headers.GetReaderAtHeader(i);
                    reader.Read();
                    var serializer = new XmlSerializer(typeof(string));
                    wsAuthToken.Subscriber = (string)serializer.Deserialize(reader);
                }
            }

            if (wsAuthToken == null)
            {
                throw new Exception();
            }
            else
            {
                Console.WriteLine("Request message header" + wsAuthToken.Requestor);
            }


            return(wsAuthToken);
        }
Beispiel #2
0
 private bool ValidateWsAuthToken(WsAuthToken wsAuthToken)
 {
     if (wsAuthToken.Requestor != _requestor)
     {
         return(false);
     }
     if (wsAuthToken.Subscriber != _subscriber)
     {
         return(false);
     }
     return(true);
 }
Beispiel #3
0
        private WsAuthToken GetWsAuthToken(Message message)
        {
            WsAuthToken wsAuthToken = new WsAuthToken();

            for (var i = 0; i < message.Headers.Count; i++)
            {
                Console.WriteLine($" **********************************************************");
                Console.WriteLine($" *** Found Header: {message.Headers[i].Name.ToUpper()} ");
                Console.WriteLine($" **********************************************************");
                if (message.Headers[i].Name.ToUpper() == "REQUESTORSYSTEM")
                {
                    using var reader = message.Headers.GetReaderAtHeader(i);
                    reader.Read();
                    //var serializer = new XmlSerializer(typeof(string));
                    //wsAuthToken.Requestor = (string)serializer.Deserialize(reader);
                    wsAuthToken.Requestor = message.Headers.GetHeader <string>(i);
                }

                if (message.Headers[i].Name.ToUpper() == "SUBSCRIBERSYSTEM")
                {
                    using var reader = message.Headers.GetReaderAtHeader(i);
                    reader.Read();
                    //var serializer = new XmlSerializer(typeof(string));
                    //wsAuthToken.Subscriber = (string)serializer.Deserialize(reader);
                    wsAuthToken.Subscriber = message.Headers.GetHeader <string>(i);
                }
            }

            // Temporary: bypass by hard-coding valid values
            if (wsAuthToken == null)
            {
                wsAuthToken.Requestor  = "SI";
                wsAuthToken.Subscriber = "PI";
            }
            //wsAuthToken.RequestTime = System.Xml.XmlDateTimeSerializationMode.Local;

            if (wsAuthToken == null)
            {
                throw new Exception();
            }
            else
            {
                Console.WriteLine("Request message header: " + wsAuthToken.Requestor);
            }


            return(wsAuthToken);
        }