コード例 #1
0
 public static RequestSecurityToken CreateFrom(XmlReader xr)
 {
     return(RequestSecurityToken.ProcessRequestSecurityTokenElement(xr));
 }
コード例 #2
0
        private static RequestSecurityToken ProcessRequestSecurityTokenElement(XmlReader xr)
        {
            if (xr == null)
            {
                throw new ArgumentNullException("xr");
            }
            if (xr.IsEmptyElement)
            {
                throw new ArgumentException("wst:RequestSecurityToken element was empty. Unable to create RequestSecurityToken object");
            }
            int             depth         = xr.Depth;
            string          attribute     = xr.GetAttribute("Context", string.Empty);
            string          tokenType     = string.Empty;
            string          text          = string.Empty;
            int             keySize       = 0;
            string          text2         = "http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey";
            EndpointAddress appliesTo     = null;
            SecurityToken   entropy       = null;
            SecurityToken   securityToken = null;

            while (xr.Read())
            {
                if (XmlNodeType.Element == xr.NodeType)
                {
                    if ("http://schemas.xmlsoap.org/ws/2005/02/trust" == xr.NamespaceURI)
                    {
                        if ("RequestType" == xr.LocalName && !xr.IsEmptyElement)
                        {
                            xr.Read();
                            text = xr.ReadContentAsString();
                        }
                        else if ("TokenType" == xr.LocalName && !xr.IsEmptyElement)
                        {
                            xr.Read();
                            tokenType = xr.ReadContentAsString();
                        }
                        else if ("KeySize" == xr.LocalName && !xr.IsEmptyElement)
                        {
                            xr.Read();
                            keySize = xr.ReadContentAsInt();
                        }
                        else if ("KeyType" == xr.LocalName && !xr.IsEmptyElement)
                        {
                            xr.Read();
                            text2 = xr.ReadContentAsString();
                        }
                        else if ("Entropy" == xr.LocalName && !xr.IsEmptyElement)
                        {
                            entropy = RequestSecurityToken.ProcessEntropyElement(xr);
                        }
                        else
                        {
                            Console.WriteLine("Not processing element: {0}:{1}", xr.NamespaceURI, xr.LocalName);
                        }
                    }
                    else if ("http://schemas.xmlsoap.org/ws/2004/09/policy" == xr.NamespaceURI)
                    {
                        if ("AppliesTo" == xr.LocalName && !xr.IsEmptyElement)
                        {
                            appliesTo = RequestSecurityToken.ProcessAppliesToElement(xr);
                        }
                        else
                        {
                            Console.WriteLine("Not processing element: {0}:{1}", xr.NamespaceURI, xr.LocalName);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Not processing element: {0}:{1}", xr.NamespaceURI, xr.LocalName);
                    }
                }
                if ("RequestSecurityToken" == xr.LocalName && "http://schemas.xmlsoap.org/ws/2005/02/trust" == xr.NamespaceURI && xr.Depth == depth && XmlNodeType.EndElement == xr.NodeType)
                {
                    break;
                }
            }
            return(new RequestSecurityToken(attribute, tokenType, text, keySize, text2, securityToken, entropy, appliesTo));
        }