internal SignedXml(SignedInfo signedInfo, DictionaryManager dictionaryManager, SecurityTokenSerializer tokenSerializer) { if (signedInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("signedInfo")); } if (dictionaryManager == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dictionaryManager"); } if (tokenSerializer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("tokenSerializer"); } this.transformFactory = StandardTransformFactory.Instance; this.tokenSerializer = tokenSerializer; this.signature = new Signature(this, signedInfo); this.dictionaryManager = dictionaryManager; }
public void ReadFrom(XmlDictionaryReader reader, TransformFactory transformFactory, DictionaryManager dictionaryManager) { reader.MoveToStartElement(dictionaryManager.XmlSignatureDictionary.Transforms, dictionaryManager.XmlSignatureDictionary.Namespace); this.prefix = reader.Prefix; reader.Read(); while (reader.IsStartElement(dictionaryManager.XmlSignatureDictionary.Transform, dictionaryManager.XmlSignatureDictionary.Namespace)) { string attribute = reader.GetAttribute(dictionaryManager.XmlSignatureDictionary.Algorithm, null); Transform transform = transformFactory.CreateTransform(attribute); transform.ReadFrom(reader, dictionaryManager); this.Add(transform); } reader.MoveToContent(); reader.ReadEndElement(); if (this.TransformCount == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CryptographicException(System.IdentityModel.SR.GetString("AtLeastOneTransformRequired"))); } }
public override void ReadFrom(XmlDictionaryReader reader, TransformFactory transformFactory, DictionaryManager dictionaryManager) { base.SendSide = false; if (reader.CanCanonicalize) { base.CanonicalStream = new MemoryStream(); reader.StartCanonicalization(base.CanonicalStream, false, null); } reader.MoveToStartElement(dictionaryManager.XmlSignatureDictionary.SignedInfo, dictionaryManager.XmlSignatureDictionary.Namespace); this.prefix = reader.Prefix; base.Id = reader.GetAttribute(dictionaryManager.UtilityDictionary.IdAttribute, null); reader.Read(); base.ReadCanonicalizationMethod(reader, dictionaryManager); base.ReadSignatureMethod(reader, dictionaryManager); while (reader.IsStartElement(dictionaryManager.XmlSignatureDictionary.Reference, dictionaryManager.XmlSignatureDictionary.Namespace)) { Reference reference = new Reference(dictionaryManager); reference.ReadFrom(reader, transformFactory, dictionaryManager); this.AddReference(reference); } reader.ReadEndElement(); if (reader.CanCanonicalize) { reader.EndCanonicalization(); } string[] inclusivePrefixes = base.GetInclusivePrefixes(); if (inclusivePrefixes != null) { base.CanonicalStream = null; this.context = new Dictionary <string, string>(inclusivePrefixes.Length); for (int i = 0; i < inclusivePrefixes.Length; i++) { this.context.Add(inclusivePrefixes[i], reader.LookupNamespace(inclusivePrefixes[i])); } } }
public override void ReadFrom(XmlDictionaryReader reader, TransformFactory transformFactory, DictionaryManager dictionaryManager) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); // sender side use only }
public void ReadFrom(XmlDictionaryReader reader, TransformFactory transformFactory, DictionaryManager dictionaryManager) { reader.MoveToStartElement(dictionaryManager.XmlSignatureDictionary.Reference, dictionaryManager.XmlSignatureDictionary.Namespace); this.prefix = reader.Prefix; this.Id = reader.GetAttribute("Id", null); this.Uri = reader.GetAttribute(dictionaryManager.XmlSignatureDictionary.URI, null); this.Type = reader.GetAttribute(dictionaryManager.XmlSignatureDictionary.Type, null); reader.Read(); if (reader.IsStartElement(dictionaryManager.XmlSignatureDictionary.Transforms, dictionaryManager.XmlSignatureDictionary.Namespace)) { this.transformChain.ReadFrom(reader, transformFactory, dictionaryManager); } this.digestMethodElement.ReadFrom(reader, dictionaryManager); this.digestValueElement.ReadFrom(reader, dictionaryManager); reader.MoveToContent(); reader.ReadEndElement(); }
public override void ReadFrom(XmlDictionaryReader reader, TransformFactory transformFactory, DictionaryManager dictionaryManager) { reader.MoveToStartElement(XmlSignatureConstants.Elements.SignedInfo, XmlSignatureConstants.Namespace); SendSide = false; _defaultNamespace = reader.LookupNamespace(String.Empty); _bufferedStream = new MemoryStream(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = Encoding.UTF8; settings.NewLineHandling = NewLineHandling.None; using (XmlWriter bufferWriter = XmlTextWriter.Create(_bufferedStream, settings)) { bufferWriter.WriteNode(reader, true); bufferWriter.Flush(); } _bufferedStream.Position = 0; // // We are creating a XmlDictionaryReader with a hard-coded Max XmlDictionaryReaderQuotas. This is a reader that we // are creating over an already buffered content. The content was initially read off user provided XmlDictionaryReader // with the correct quotas and hence we know the data is valid. // Note: effectiveReader will close _bufferedStream on Dispose. // using (XmlDictionaryReader effectiveReader = XmlDictionaryReader.CreateTextReader(_bufferedStream, XmlDictionaryReaderQuotas.Max)) { CanonicalStream = new MemoryStream(); effectiveReader.StartCanonicalization(CanonicalStream, false, null); effectiveReader.MoveToStartElement(XmlSignatureConstants.Elements.SignedInfo, XmlSignatureConstants.Namespace); Prefix = effectiveReader.Prefix; Id = effectiveReader.GetAttribute(WSSecurityUtilityConstants.Attributes.Id, null); effectiveReader.Read(); ReadCanonicalizationMethod(effectiveReader, DictionaryManager); ReadSignatureMethod(effectiveReader, DictionaryManager); while (effectiveReader.IsStartElement(XmlSignatureConstants.Elements.Reference, XmlSignatureConstants.Namespace)) { Reference reference = new Reference(DictionaryManager); reference.ReadFrom(effectiveReader, transformFactory, DictionaryManager); AddReference(reference); } effectiveReader.ReadEndElement(); effectiveReader.EndCanonicalization(); } string[] inclusivePrefixes = GetInclusivePrefixes(); if (inclusivePrefixes != null) { // Clear the canonicalized stream. We cannot use this while inclusive prefixes are // specified. CanonicalStream = null; Context = new Dictionary<string, string>(inclusivePrefixes.Length); for (int i = 0; i < inclusivePrefixes.Length; i++) { Context.Add(inclusivePrefixes[i], reader.LookupNamespace(inclusivePrefixes[i])); } } }
public override void ReadFrom(XmlDictionaryReader reader, TransformFactory transformFactory, DictionaryManager dictionaryManager) { this.SendSide = false; if (reader.CanCanonicalize) { this.CanonicalStream = new MemoryStream(); reader.StartCanonicalization(this.CanonicalStream, false, null); } reader.MoveToStartElement(dictionaryManager.XmlSignatureDictionary.SignedInfo, dictionaryManager.XmlSignatureDictionary.Namespace); this.prefix = reader.Prefix; this.Id = reader.GetAttribute(dictionaryManager.UtilityDictionary.IdAttribute, null); reader.Read(); ReadCanonicalizationMethod(reader, dictionaryManager); ReadSignatureMethod(reader, dictionaryManager); while (reader.IsStartElement(dictionaryManager.XmlSignatureDictionary.Reference, dictionaryManager.XmlSignatureDictionary.Namespace)) { Reference reference = new Reference(dictionaryManager); reference.ReadFrom(reader, transformFactory, dictionaryManager); AddReference(reference); } reader.ReadEndElement(); // SignedInfo if (reader.CanCanonicalize) reader.EndCanonicalization(); string[] inclusivePrefixes = GetInclusivePrefixes(); if (inclusivePrefixes != null) { // Clear the canonicalized stream. We cannot use this while inclusive prefixes are // specified. this.CanonicalStream = null; this.context = new Dictionary<string, string>(inclusivePrefixes.Length); for (int i = 0; i < inclusivePrefixes.Length; i++) { this.context.Add(inclusivePrefixes[i], reader.LookupNamespace(inclusivePrefixes[i])); } } }
public abstract void ReadFrom(XmlDictionaryReader reader, TransformFactory transformFactory, DictionaryManager dictionaryManager);
public void ReadFrom(XmlDictionaryReader reader, TransformFactory transformFactory, DictionaryManager dictionaryManager, bool preserveComments) { reader.MoveToStartElement(dictionaryManager.XmlSignatureDictionary.Transforms, dictionaryManager.XmlSignatureDictionary.Namespace); this.prefix = reader.Prefix; reader.Read(); while (reader.IsStartElement(dictionaryManager.XmlSignatureDictionary.Transform, dictionaryManager.XmlSignatureDictionary.Namespace)) { string transformAlgorithmUri = reader.GetAttribute(dictionaryManager.XmlSignatureDictionary.Algorithm, null); Transform transform = transformFactory.CreateTransform(transformAlgorithmUri); transform.ReadFrom(reader, dictionaryManager, preserveComments); Add(transform); } reader.MoveToContent(); reader.ReadEndElement(); // Transforms if (this.TransformCount == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CryptographicException(SR.GetString(SR.AtLeastOneTransformRequired))); } }
public abstract void ReadFrom(XmlDictionaryReader reader, TransformFactory transformFactory, System.IdentityModel.DictionaryManager dictionaryManager);