private void LoadStreamInput(Stream stream) { XmlResolver resolver = (ResolverSet ? _xmlResolver : new XmlSecureResolver(new XmlUrlResolver(), BaseURI)); XmlReader valReader = Utils.PreProcessStreamInput(stream, resolver, BaseURI); _document = new XmlDocument(); _document.PreserveWhitespace = true; _document.Load(valReader); }
private void LoadStreamInput(Stream stream) { XmlResolver resolver = (ResolverSet ? _xmlResolver : XmlResolverHelper.GetThrowingResolver()); XmlReader valReader = Utils.PreProcessStreamInput(stream, resolver, BaseURI); _document = new XmlDocument(); _document.PreserveWhitespace = true; _document.Load(valReader); }
// private static string defaultXPathWithoutComments = "(//. | //@* | //namespace::*)[not(self::comment())]"; // private static string defaultXPathWithoutComments = "(//. | //@* | //namespace::*)"; // private static string defaultXPathWithComments = "(//. | //@* | //namespace::*)"; // private static string defaultXPathWithComments = "(//. | //@* | //namespace::*)"; internal CanonicalXml(Stream inputStream, bool includeComments, XmlResolver resolver, string strBaseUri) { if (inputStream == null) { throw new ArgumentNullException(nameof(inputStream)); } _c14nDoc = new CanonicalXmlDocument(true, includeComments); _c14nDoc.XmlResolver = resolver; _c14nDoc.Load(Utils.PreProcessStreamInput(inputStream, resolver, strBaseUri)); _ancMgr = new C14NAncestralNamespaceContextManager(); }
internal ExcCanonicalXml(Stream inputStream, bool includeComments, string inclusiveNamespacesPrefixList, XmlResolver resolver, string strBaseUri) { if (inputStream == null) { throw new ArgumentNullException("inputStream"); } m_c14nDoc = new CanonicalXmlDocument(true, includeComments); m_c14nDoc.XmlResolver = resolver; m_c14nDoc.Load(Utils.PreProcessStreamInput(inputStream, resolver, strBaseUri)); m_ancMgr = new ExcAncestralNamespaceContextManager(inclusiveNamespacesPrefixList); }
private void LoadStreamInput(Stream stream) { XmlDocument document = new XmlDocument(); document.PreserveWhitespace = true; XmlResolver resolver = (ResolverSet ? _xmlResolver : new XmlSecureResolver(new XmlUrlResolver(), BaseURI)); XmlReader xmlReader = Utils.PreProcessStreamInput(stream, resolver, BaseURI); document.Load(xmlReader); _containingDocument = document; _nsm = new XmlNamespaceManager(_containingDocument.NameTable); _nsm.AddNamespace("enc", EncryptedXml.XmlEncNamespaceUrl); // select all EncryptedData elements _encryptedDataList = document.SelectNodes("//enc:EncryptedData", _nsm); }
private void LoadStreamInput(Stream stream) { XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; XmlResolver resolver = (ResolverSet ? _xmlResolver : new XmlSecureResolver(new XmlUrlResolver(), BaseURI)); XmlReader xmlReader = Utils.PreProcessStreamInput(stream, resolver, BaseURI); doc.Load(xmlReader); _containingDocument = doc; if (_containingDocument == null) { throw new CryptographicException(SR.Cryptography_Xml_EnvelopedSignatureRequiresContext); } _nsm = new XmlNamespaceManager(_containingDocument.NameTable); _nsm.AddNamespace("dsig", SignedXml.XmlDsigNamespaceUrl); }
// The goal behind this method is to pump the input stream through the transforms and get back something that // can be hashed internal Stream TransformToOctetStream(object inputObject, Type inputType, XmlResolver resolver, string baseUri) { object currentInput = inputObject; foreach (Transform transform in _transforms) { if (currentInput == null || transform.AcceptsType(currentInput.GetType())) { //in this case, no translation necessary, pump it through transform.Resolver = resolver; transform.BaseURI = baseUri; transform.LoadInput(currentInput); currentInput = transform.GetOutput(); } else { // We need translation // For now, we just know about Stream->{XmlNodeList,XmlDocument} and {XmlNodeList,XmlDocument}->Stream if (currentInput is Stream) { if (transform.AcceptsType(typeof(XmlDocument))) { Stream currentInputStream = currentInput as Stream; XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; XmlReader valReader = Utils.PreProcessStreamInput(currentInputStream, resolver, baseUri); doc.Load(valReader); transform.LoadInput(doc); currentInputStream.Close(); currentInput = transform.GetOutput(); continue; } else { throw new CryptographicException(SR.Cryptography_Xml_TransformIncorrectInputType); } } if (currentInput is XmlNodeList) { if (transform.AcceptsType(typeof(Stream))) { CanonicalXml c14n = new CanonicalXml((XmlNodeList)currentInput, resolver, false); MemoryStream ms = new MemoryStream(c14n.GetBytes()); transform.LoadInput(ms); currentInput = transform.GetOutput(); ms.Close(); continue; } else { throw new CryptographicException(SR.Cryptography_Xml_TransformIncorrectInputType); } } if (currentInput is XmlDocument) { if (transform.AcceptsType(typeof(Stream))) { CanonicalXml c14n = new CanonicalXml((XmlDocument)currentInput, resolver); MemoryStream ms = new MemoryStream(c14n.GetBytes()); transform.LoadInput(ms); currentInput = transform.GetOutput(); ms.Close(); continue; } else { throw new CryptographicException(SR.Cryptography_Xml_TransformIncorrectInputType); } } throw new CryptographicException(SR.Cryptography_Xml_TransformIncorrectInputType); } } // Final processing, either we already have a stream or have to canonicalize if (currentInput is Stream) { return(currentInput as Stream); } if (currentInput is XmlNodeList) { CanonicalXml c14n = new CanonicalXml((XmlNodeList)currentInput, resolver, false); MemoryStream ms = new MemoryStream(c14n.GetBytes()); return(ms); } if (currentInput is XmlDocument) { CanonicalXml c14n = new CanonicalXml((XmlDocument)currentInput, resolver); MemoryStream ms = new MemoryStream(c14n.GetBytes()); return(ms); } throw new CryptographicException(SR.Cryptography_Xml_TransformIncorrectInputType); }