public void ProcessAndDigest(object input, SignatureResourcePool resourcePool, HashAlgorithm hash, DictionaryManager dictionaryManger)
 {
     HashStream hashStream = resourcePool.TakeHashStream(hash);
     XmlReader reader = input as XmlReader;
     if (reader != null)
     {
         this.ProcessReaderInput(reader, resourcePool, hashStream);
     }
     else
     {
         if (!(input is ISecurityElement))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(System.IdentityModel.SR.GetString("UnsupportedInputTypeForTransform", new object[] { input.GetType() })));
         }
         XmlDictionaryWriter writer = resourcePool.TakeUtf8Writer();
         writer.StartCanonicalization(hashStream, this.IncludeComments, this.GetInclusivePrefixes());
         (input as ISecurityElement).WriteTo(writer, dictionaryManger);
         writer.EndCanonicalization();
     }
     hashStream.FlushHash();
 }
Esempio n. 2
0
        public void ProcessAndDigest(object input, SignatureResourcePool resourcePool, HashAlgorithm hash, DictionaryManager dictionaryManger)
        {
            HashStream hashStream = resourcePool.TakeHashStream(hash);
            XmlReader  reader     = input as XmlReader;

            if (reader != null)
            {
                this.ProcessReaderInput(reader, resourcePool, hashStream);
            }
            else
            {
                if (!(input is ISecurityElement))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(System.IdentityModel.SR.GetString("UnsupportedInputTypeForTransform", new object[] { input.GetType() })));
                }
                XmlDictionaryWriter writer = resourcePool.TakeUtf8Writer();
                writer.StartCanonicalization(hashStream, this.IncludeComments, this.GetInclusivePrefixes());
                (input as ISecurityElement).WriteTo(writer, dictionaryManger);
                writer.EndCanonicalization();
            }
            hashStream.FlushHash();
        }
 internal override SecurityTimestamp ReadTimestamp(XmlDictionaryReader reader, string digestAlgorithm, SignatureResourcePool resourcePool)
 {
     DateTime maxUtcDateTime;
     byte[] buffer;
     bool flag = (digestAlgorithm != null) && reader.CanCanonicalize;
     HashStream stream = null;
     reader.MoveToStartElement(System.ServiceModel.XD.UtilityDictionary.Timestamp, System.ServiceModel.XD.UtilityDictionary.Namespace);
     if (flag)
     {
         stream = resourcePool.TakeHashStream(digestAlgorithm);
         reader.StartCanonicalization(stream, false, null);
     }
     string attribute = reader.GetAttribute(System.ServiceModel.XD.UtilityDictionary.IdAttribute, System.ServiceModel.XD.UtilityDictionary.Namespace);
     reader.ReadStartElement();
     reader.ReadStartElement(System.ServiceModel.XD.UtilityDictionary.CreatedElement, System.ServiceModel.XD.UtilityDictionary.Namespace);
     DateTime creationTimeUtc = reader.ReadContentAsDateTime().ToUniversalTime();
     reader.ReadEndElement();
     if (reader.IsStartElement(System.ServiceModel.XD.UtilityDictionary.ExpiresElement, System.ServiceModel.XD.UtilityDictionary.Namespace))
     {
         reader.ReadStartElement();
         maxUtcDateTime = reader.ReadContentAsDateTime().ToUniversalTime();
         reader.ReadEndElement();
     }
     else
     {
         maxUtcDateTime = System.ServiceModel.Security.SecurityUtils.MaxUtcDateTime;
     }
     reader.ReadEndElement();
     if (flag)
     {
         reader.EndCanonicalization();
         buffer = stream.FlushHashAndGetValue();
     }
     else
     {
         buffer = null;
     }
     return new SecurityTimestamp(creationTimeUtc, maxUtcDateTime, attribute, digestAlgorithm, buffer);
 }