EncapsulatedPKIData is used to incorporate a piece of PKI data into an XML structure whereas the PKI data is encoded using an ASN.1 encoding mechanism. Examples of such PKI data that are widely used at the time include X509 certificates and revocation lists, OCSP responses, attribute certificates and time-stamps.
示例#1
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public TimeStamp()
 {
     this.canonicalizationMethod = new CanonicalizationMethod();
     this.hashDataInfoCollection = new HashDataInfoCollection();
     this.encapsulatedTimeStamp  = new EncapsulatedPKIData("EncapsulatedTimeStamp");
     this.xmlTimeStamp           = null;
 }
示例#2
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public TimeStamp(string prefix, string namespaceUri)
        {
            this.hashDataInfoCollection = new HashDataInfoCollection();
            this.encapsulatedTimeStamp  = new EncapsulatedPKIData("EncapsulatedTimeStamp");
            this.xmlTimeStamp           = null;

            this.prefix       = prefix;
            this.namespaceUri = namespaceUri;
        }
        /// <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;
            EncapsulatedPKIData newCertifiedRole;
            IEnumerator         enumerator;
            XmlElement          iterationXmlElement;

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

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            this.certifiedRoleCollection.Clear();
            xmlNodeList = xmlElement.SelectNodes("xsd:CertifiedRole", xmlNamespaceManager);
            enumerator  = xmlNodeList.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    iterationXmlElement = enumerator.Current as XmlElement;
                    if (iterationXmlElement != null)
                    {
                        newCertifiedRole = new EncapsulatedPKIData("CertifiedRole");
                        newCertifiedRole.LoadXml(iterationXmlElement);
                        this.certifiedRoleCollection.Add(newCertifiedRole);
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
        /// <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");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            this.hashDataInfoCollection.Clear();
            xmlNodeList = xmlElement.SelectNodes("xsd: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();
                }
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:EncapsulatedTimeStamp", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp");
                this.encapsulatedTimeStamp.LoadXml((XmlElement)xmlNodeList.Item(0));
                this.xmlTimeStamp = null;
            }
            else
            {
                xmlNodeList = xmlElement.SelectNodes("xsd: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");
                }
            }
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 public TimeStamp()
 {
     this.hashDataInfoCollection = new HashDataInfoCollection();
     this.encapsulatedTimeStamp  = new EncapsulatedPKIData("EncapsulatedTimeStamp");
     this.xmlTimeStamp           = null;
 }
示例#6
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(nameof(xmlElement));
            }

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

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

            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
            {
                if (enumerator is IDisposable disposable)
                {
                    disposable.Dispose();
                }
            }

            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 element is missing");
                    }
                }
            }
        }
示例#7
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");
			}

			xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
			xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

			this.hashDataInfoCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd: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();
				}
			}

			xmlNodeList = xmlElement.SelectNodes("xsd:EncapsulatedTimeStamp", xmlNamespaceManager);
			if (xmlNodeList.Count != 0)
			{
				this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp");
				this.encapsulatedTimeStamp.LoadXml((XmlElement)xmlNodeList.Item(0));
				this.xmlTimeStamp = null;
			}
			else
			{
				xmlNodeList = xmlElement.SelectNodes("xsd: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");
				}
			}
		}
示例#8
0
		/// <summary>
		/// Default constructor
		/// </summary>
		public TimeStamp()
		{
			this.hashDataInfoCollection = new HashDataInfoCollection();
			this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp");
			this.xmlTimeStamp = null;
		}
示例#9
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;
			EncapsulatedPKIData newCertifiedRole;
			IEnumerator enumerator;
			XmlElement iterationXmlElement;
			
			if (xmlElement == null)
			{
				throw new ArgumentNullException("xmlElement");
			}

			xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
			xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

			this.certifiedRoleCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd:CertifiedRole", xmlNamespaceManager);
			enumerator = xmlNodeList.GetEnumerator();
			try 
			{
				while (enumerator.MoveNext()) 
				{
					iterationXmlElement = enumerator.Current as XmlElement;
					if (iterationXmlElement != null)
					{
						newCertifiedRole = new EncapsulatedPKIData("CertifiedRole");
						newCertifiedRole.LoadXml(iterationXmlElement);
						this.certifiedRoleCollection.Add(newCertifiedRole);
					}
				}
			}
			finally 
			{
				IDisposable disposable = enumerator as IDisposable;
				if (disposable != null)
				{
					disposable.Dispose();
				}
			}
		}
示例#10
0
		/// <summary>
		/// Default constructor
		/// </summary>
		public TimeStamp()
		{
            this.canonicalizationMethod = new CanonicalizationMethod();
			this.hashDataInfoCollection = new HashDataInfoCollection();
			this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp");
			this.xmlTimeStamp = null;
		}