DigestMethod indicates the digest algorithm
Esempio n. 1
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public TimeStamp()
 {
     this.canonicalizationMethod = new CanonicalizationMethod();
     this.hashDataInfoCollection = new HashDataInfoCollection();
     this.encapsulatedTimeStamp  = new EncapsulatedPKIData("EncapsulatedTimeStamp");
     this.xmlTimeStamp           = null;
 }
Esempio n. 2
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;
            IEnumerator         enumerator;
            XmlElement          iterationXmlElement;
            HashDataInfo        newHashDataInfo;

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

            if (xmlElement.HasAttribute("Id"))
            {
                this.id = xmlElement.GetAttribute("Id");
            }
            else
            {
                this.id = "";
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xades", XadesSignedXml.XadesNamespaceUri);
            xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);

            this.hashDataInfoCollection.Clear();
            xmlNodeList = xmlElement.SelectNodes("xades:HashDataInfo", xmlNamespaceManager);
            enumerator  = xmlNodeList.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    iterationXmlElement = enumerator.Current as XmlElement;
                    if (iterationXmlElement != null)
                    {
                        newHashDataInfo = new HashDataInfo();
                        newHashDataInfo.LoadXml(iterationXmlElement);
                        this.hashDataInfoCollection.Add(newHashDataInfo);
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }

            XmlNode canonicalizationNode = xmlElement.SelectSingleNode("ds:CanonicalizationMethod", xmlNamespaceManager);

            if (canonicalizationNode != null)
            {
                this.canonicalizationMethod = new CanonicalizationMethod();
                this.canonicalizationMethod.LoadXml((XmlElement)canonicalizationNode);
            }

            xmlNodeList = xmlElement.SelectNodes("xades:EncapsulatedTimeStamp", xmlNamespaceManager);

            if (xmlNodeList.Count != 0)
            {
                this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp");
                this.encapsulatedTimeStamp.LoadXml((XmlElement)xmlNodeList.Item(0));
                this.xmlTimeStamp = null;
            }
            else
            {
                XmlNode nodeEncapsulatedTimeStamp = null;

                foreach (XmlNode node in xmlElement.ChildNodes)
                {
                    if (node.Name == "EncapsulatedTimeStamp")
                    {
                        nodeEncapsulatedTimeStamp = node;
                        break;
                    }
                }

                if (nodeEncapsulatedTimeStamp != null)
                {
                    this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp");
                    this.encapsulatedTimeStamp.LoadXml((XmlElement)nodeEncapsulatedTimeStamp);
                    this.xmlTimeStamp = null;
                }
                else
                {
                    xmlNodeList = xmlElement.SelectNodes("xades:XMLTimeStamp", xmlNamespaceManager);
                    if (xmlNodeList.Count != 0)
                    {
                        this.xmlTimeStamp = new XMLTimeStamp();
                        this.xmlTimeStamp.LoadXml((XmlElement)xmlNodeList.Item(0));
                        this.encapsulatedTimeStamp = null;
                    }
                    else
                    {
                        throw new CryptographicException("EncapsulatedTimeStamp or XMLTimeStamp missing");
                    }
                }
            }
        }
Esempio n. 3
0
		/// <summary>
		/// Default constructor
		/// </summary>
		public TimeStamp()
		{
            this.canonicalizationMethod = new CanonicalizationMethod();
			this.hashDataInfoCollection = new HashDataInfoCollection();
			this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp");
			this.xmlTimeStamp = null;
		}