public static PeerHashToken CreateHashTokenFrom(Message message)
        {
            PeerHashToken        invalid = PeerHashToken.Invalid;
            RequestSecurityToken token2  = RequestSecurityToken.CreateFrom(message.GetReaderAtBodyContents());

            if (token2.RequestSecurityTokenXml != null)
            {
                foreach (System.Xml.XmlNode node in token2.RequestSecurityTokenXml.ChildNodes)
                {
                    XmlElement child = (XmlElement)node;
                    if ((child != null) && CompareWithNS(child.LocalName, child.NamespaceURI, "RequestedSecurityToken", "http://schemas.xmlsoap.org/ws/2005/02/trust"))
                    {
                        invalid = PeerHashToken.CreateFrom(child);
                    }
                }
            }
            return(invalid);
        }
Esempio n. 2
0
        public Message Issue(Message request)
        {
            try
            {
                Console.WriteLine("Call to IWSTrust::Issue");

                // if request is null, we're toast
                if (request == null)
                {
                    throw new ArgumentNullException("request");
                }

                // Create an RST object from the request message
                RequestSecurityToken rst = RequestSecurityToken.CreateFrom(request.GetReaderAtBodyContents());

                // Check that is really is an Issue request
                if (rst.RequestType == null || rst.RequestType != Constants.Trust.RequestTypes.Issue)
                {
                    throw new InvalidOperationException(rst.RequestType);
                }

                // Create an RSTR object
                RequestSecurityTokenResponse rstr = Issue(rst);

                // Create response message
                Message response = Message.CreateMessage(request.Version, Constants.Trust.Actions.IssueReply, rstr);

                // Set RelatesTo of response to message id of request
                response.Headers.RelatesTo = request.Headers.MessageId;

                // Address response to ReplyTo of request
                request.Headers.ReplyTo.ApplyTo(response);
                return(response);
            }
            catch (Exception e)
            {
                Console.WriteLine("**** Exception thrown while processing Issue request:");
                Console.WriteLine(e.Message);
                throw;
            }
        }
Esempio n. 3
0
        public static PeerHashToken CreateHashTokenFrom(Message message)
        {
            PeerHashToken        token  = PeerHashToken.Invalid;
            XmlReader            reader = message.GetReaderAtBodyContents();
            RequestSecurityToken rst    = RequestSecurityToken.CreateFrom(reader);
            XmlElement           rstXml = rst.RequestSecurityTokenXml;

            if (rstXml != null)
            {
                //find the wrapper element
                foreach (XmlNode node in rst.RequestSecurityTokenXml.ChildNodes)
                {
                    XmlElement element = (XmlElement)node;
                    if (element == null || !PeerRequestSecurityToken.CompareWithNS(element.LocalName, element.NamespaceURI, PeerRequestSecurityToken.RequestedSecurityTokenElementName, TrustFeb2005Strings.Namespace))
                    {
                        continue;
                    }
                    token = PeerHashToken.CreateFrom(element);
                }
            }
            return(token);
        }