Ejemplo n.º 1
0
        /// <summary>
        /// Build the final response <code>Document</code>.<br />
        /// Before the<code>Document</code> is generated all attributes will be validated.<br />
        /// <br />
        /// A<code> Document</code> is generated each time this method is called.Calling this method multiple times will therefore return multiple objects.
        /// </summary>
        /// <returns></returns>
        public override XDocument Build()
        {
            var document = CreateDocument();

            SealUtilities.CheckAndSetSamlDsPreFix(document);
            NameSpaces.SetMissingNamespaces(document);
            if (SigningVault != null)
            {
                var signer    = new SealSignedXml(document);
                var signedXml = signer.Sign(SigningVault.GetSystemCredentials());
                var xDocument = XDocument.Parse(signedXml.OuterXml, LoadOptions.PreserveWhitespace);

                return(xDocument);
            }
            return(document);
        }