Beispiel #1
0
        private XmlElement GetKeyIdentifierClause(X509SecurityToken certToken)

        {
            using (XmlDocumentWriterHelper documentWriterHelper = new XmlDocumentWriterHelper())

            {
                // The key is located in the same XML document, so referencing that

                // with a local key identifier.

                var keyIdentifierClause =

                    certToken.CreateKeyIdentifierClause <LocalIdKeyIdentifierClause>();

                Debug.Assert(keyIdentifierClause != null);



                _tokenSerializer.WriteKeyIdentifierClause(

                    documentWriterHelper.CreateDocumentWriter(), keyIdentifierClause);



                XmlDocument xmlDocument = documentWriterHelper.ReadDocument();



                return(xmlDocument.DocumentElement);
            }
        }
Beispiel #2
0
        private static XmlDocument GetXmlMessage(Message request)

        {
            using (XmlDocumentWriterHelper documentWriterHelper = new XmlDocumentWriterHelper())

            {
                request.WriteMessage(documentWriterHelper.CreateDocumentWriter());

                return(documentWriterHelper.ReadDocument());
            }
        }
Beispiel #3
0
        private XmlElement GetKeyIdentifierClause(XmlElement samlToken)

        {
            if (samlToken == null)
            {
                throw new ArgumentNullException("samlToken");
            }



            using (XmlDocumentWriterHelper documentWriterHelper = new XmlDocumentWriterHelper())

            {
                // The key is located in the SAML token. The identifier is to the SAML token.



                XmlNode idAttribute = samlToken.Attributes.GetNamedItem("ID");



                if (idAttribute == null)

                {
                    throw new InvalidDataException("The SAML token does not have an ID attribute.");
                }



                string samlTokenId = idAttribute.Value;



                SecurityKeyIdentifierClause keyIdentifierClause = new Saml2AssertionKeyIdentifierClause(samlTokenId);



                Saml2SecurityTokenHandler handler = new Saml2SecurityTokenHandler();

                handler.KeyInfoSerializer.WriteKeyIdentifierClause(documentWriterHelper.CreateDocumentWriter(),

                                                                   keyIdentifierClause);



                XmlDocument xmlDocument = documentWriterHelper.ReadDocument();



                return(xmlDocument.DocumentElement);
            }
        }
Beispiel #4
0
        private static XmlDocument ToXmlDocument(SecurityHeader value)

        {
            using (XmlDocumentWriterHelper documentWriterHelper = new XmlDocumentWriterHelper())

            {
                SecurityHeaderSerializer.Serialize(documentWriterHelper.CreateDocumentWriter(), value);



                return(documentWriterHelper.ReadDocument());
            }
        }
Beispiel #5
0
        private XmlElement ToXmlElement(SecurityToken token)

        {
            using (XmlDocumentWriterHelper documentWriterHelper = new XmlDocumentWriterHelper())

            {
                _tokenSerializer.WriteToken(documentWriterHelper.CreateDocumentWriter(), token);

                XmlDocument xmlDocument = documentWriterHelper.ReadDocument();



                return(xmlDocument.DocumentElement);
            }
        }