The commitment type can be indicated in the electronic signature by either explicitly using a commitment type indication in the electronic signature or implicitly or explicitly from the semantics of the signed data object. If the indicated commitment type is explicit by means of a commitment type indication in the electronic signature, acceptance of a verified signature implies acceptance of the semantics of that commitment type. The semantics of explicit commitment types indications shall be specified either as part of the signature policy or may be registered for generic use across multiple policies.
Esempio n. 1
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;
			DataObjectFormat newDataObjectFormat;
			CommitmentTypeIndication newCommitmentTypeIndication;
			TimeStamp newTimeStamp;
			
			if (xmlElement == null)
			{
				throw new ArgumentNullException(nameof(xmlElement));
			}

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

			this.dataObjectFormatCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd:DataObjectFormat", xmlNamespaceManager);
			enumerator = xmlNodeList.GetEnumerator();
			try 
			{
				while (enumerator.MoveNext()) 
				{
					iterationXmlElement = enumerator.Current as XmlElement;
					if (iterationXmlElement != null)
					{
						newDataObjectFormat = new DataObjectFormat();
						newDataObjectFormat.LoadXml(iterationXmlElement);
						this.dataObjectFormatCollection.Add(newDataObjectFormat);
					}
				}
			}
			finally 
			{
                if (enumerator is IDisposable disposable)
                    disposable.Dispose();
            }

			//this.dataObjectFormatCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd:CommitmentTypeIndication", xmlNamespaceManager);
			enumerator = xmlNodeList.GetEnumerator();
			try 
			{
				while (enumerator.MoveNext()) 
				{
					iterationXmlElement = enumerator.Current as XmlElement;
					if (iterationXmlElement != null)
					{
						newCommitmentTypeIndication = new CommitmentTypeIndication();
						newCommitmentTypeIndication.LoadXml(iterationXmlElement);
						this.commitmentTypeIndicationCollection.Add(newCommitmentTypeIndication);
					}
				}
			}
			finally 
			{
                if (enumerator is IDisposable disposable)
                {
                    disposable.Dispose();
                }
            }

			//this.dataObjectFormatCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd:AllDataObjectsTimeStamp", xmlNamespaceManager);
			enumerator = xmlNodeList.GetEnumerator();
			try 
			{
				while (enumerator.MoveNext()) 
				{
					iterationXmlElement = enumerator.Current as XmlElement;
					if (iterationXmlElement != null)
					{
						newTimeStamp = new TimeStamp("AllDataObjectsTimeStamp");
						newTimeStamp.LoadXml(iterationXmlElement);
						this.allDataObjectsTimeStampCollection.Add(newTimeStamp);
					}
				}
			}
			finally 
			{
                if (enumerator is IDisposable disposable)
                {
                    disposable.Dispose();
                }
            }

			//this.dataObjectFormatCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd:IndividualDataObjectsTimeStamp", xmlNamespaceManager);
			enumerator = xmlNodeList.GetEnumerator();
			try 
			{
				while (enumerator.MoveNext()) 
				{
					iterationXmlElement = enumerator.Current as XmlElement;
					if (iterationXmlElement != null)
					{
						newTimeStamp = new TimeStamp("IndividualDataObjectsTimeStamp");
						newTimeStamp.LoadXml(iterationXmlElement);
						this.individualDataObjectsTimeStampCollection.Add(newTimeStamp);
					}
				}
			}
			finally 
			{
                if (enumerator is IDisposable disposable)
                    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;
			DataObjectFormat newDataObjectFormat;
			CommitmentTypeIndication newCommitmentTypeIndication;
			TimeStamp newTimeStamp;
			
			if (xmlElement == null)
			{
				throw new ArgumentNullException("xmlElement");
			}

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

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

			this.dataObjectFormatCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd:CommitmentTypeIndication", xmlNamespaceManager);
			enumerator = xmlNodeList.GetEnumerator();
			try 
			{
				while (enumerator.MoveNext()) 
				{
					iterationXmlElement = enumerator.Current as XmlElement;
					if (iterationXmlElement != null)
					{
						newCommitmentTypeIndication = new CommitmentTypeIndication();
						newCommitmentTypeIndication.LoadXml(iterationXmlElement);
						this.commitmentTypeIndicationCollection.Add(newCommitmentTypeIndication);
					}
				}
			}
			finally 
			{
				IDisposable disposable = enumerator as IDisposable;
				if (disposable != null)
				{
					disposable.Dispose();
				}
			}

			this.dataObjectFormatCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd:AllDataObjectsTimeStamp", xmlNamespaceManager);
			enumerator = xmlNodeList.GetEnumerator();
			try 
			{
				while (enumerator.MoveNext()) 
				{
					iterationXmlElement = enumerator.Current as XmlElement;
					if (iterationXmlElement != null)
					{
						newTimeStamp = new TimeStamp("AllDataObjectsTimeStamp");
						newTimeStamp.LoadXml(iterationXmlElement);
						this.allDataObjectsTimeStampCollection.Add(newTimeStamp);
					}
				}
			}
			finally 
			{
				IDisposable disposable = enumerator as IDisposable;
				if (disposable != null)
				{
					disposable.Dispose();
				}
			}

			this.dataObjectFormatCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd:IndividualDataObjectsTimeStamp", xmlNamespaceManager);
			enumerator = xmlNodeList.GetEnumerator();
			try 
			{
				while (enumerator.MoveNext()) 
				{
					iterationXmlElement = enumerator.Current as XmlElement;
					if (iterationXmlElement != null)
					{
						newTimeStamp = new TimeStamp("IndividualDataObjectsTimeStamp");
						newTimeStamp.LoadXml(iterationXmlElement);
						this.individualDataObjectsTimeStampCollection.Add(newTimeStamp);
					}
				}
			}
			finally 
			{
				IDisposable disposable = enumerator as IDisposable;
				if (disposable != null)
				{
					disposable.Dispose();
				}
			}
		}
Esempio n. 3
0
        private void AddSignedSignatureProperties(SignedSignatureProperties signedSignatureProperties, SignedDataObjectProperties signedDataObjectProperties,
            UnsignedSignatureProperties unsignedSignatureProperties)
        {
            XmlDocument xmlDocument;
            Cert cert;

            xmlDocument = new XmlDocument();

            cert = new Cert();
            cert.IssuerSerial.X509IssuerName = this.Certificate.IssuerName.Name;
            cert.IssuerSerial.X509SerialNumber = this.Certificate.SerialNumber;
            cert.CertDigest.DigestMethod.Algorithm = SignedXml.XmlDsigSHA1Url;
            cert.CertDigest.DigestValue = this.Certificate.GetCertHash();
            signedSignatureProperties.SigningCertificate.CertCollection.Add(cert);

            signedSignatureProperties.SigningTime = DateTime.Parse(this.signingTimeTextBox.Text);

            signedSignatureProperties.SignaturePolicyIdentifier.SignaturePolicyImplied = true;

            if (this.includeSignatureProductionPlaceCheckBox.Checked)
            {
                signedSignatureProperties.SignatureProductionPlace.City = this.signatureCityTextBox.Text;
                signedSignatureProperties.SignatureProductionPlace.StateOrProvince = this.signatureStateOrProvinceTextBox.Text;
                signedSignatureProperties.SignatureProductionPlace.PostalCode = this.signaturePostalCodeTextBox.Text;
                signedSignatureProperties.SignatureProductionPlace.CountryName = this.signatureCountryNameTextBox.Text;
            }

            if (this.includeSignerRoleCheckBox.Checked)
            {
                ClaimedRole newClaimedRole = new ClaimedRole();

                xmlDocument.LoadXml(this.claimedRoleTextBox.Text);
                newClaimedRole.AnyXmlElement = (XmlElement)xmlDocument.FirstChild;
                signedSignatureProperties.SignerRole.ClaimedRoles.ClaimedRoleCollection.Add(newClaimedRole);
            }

            if (this.includeCommitmentTypeIndicationCheckBox.Checked)
            {
                CommitmentTypeIndication newCommitmentTypeIndication = new CommitmentTypeIndication();

                newCommitmentTypeIndication.CommitmentTypeId.Identifier.IdentifierUri = this.commitmentTypeIdentifierURITextBox.Text;
                switch (this.commitmentTypeIndicatorQualifierComboBox.Text)
                {
                    case "":
                        newCommitmentTypeIndication.CommitmentTypeId.Identifier.Qualifier = KnownQualifier.Uninitalized;
                        break;
                    case "OIDAsURI":
                        newCommitmentTypeIndication.CommitmentTypeId.Identifier.Qualifier = KnownQualifier.OIDAsURI;
                        break;
                    case "OIDAsURN":
                        newCommitmentTypeIndication.CommitmentTypeId.Identifier.Qualifier = KnownQualifier.OIDAsURN;
                        break;
                }
                newCommitmentTypeIndication.CommitmentTypeId.Description = this.commitmentTypeIndicationIdTextBox.Text;
                newCommitmentTypeIndication.AllSignedDataObjects = true;

                signedDataObjectProperties.CommitmentTypeIndicationCollection.Add(newCommitmentTypeIndication);
            }

            if (this.includeDataObjectFormatCheckBox.Checked)
            {
                DataObjectFormat newDataObjectFormat = new DataObjectFormat();

                newDataObjectFormat.Description = this.dataObjectDescriptionTextBox.Text;
                newDataObjectFormat.MimeType = this.dataObjectFormatMimetypeTextBox.Text;
                newDataObjectFormat.ObjectReferenceAttribute = this.dataObjectReferenceTextBox.Text;
                signedDataObjectProperties.DataObjectFormatCollection.Add(newDataObjectFormat);
            }
        }
        /// <summary>
        /// Add typed object to the collection
        /// </summary>
        /// <param name="objectToAdd">Typed object to be added to collection</param>
        /// <returns>The object that has been added to collection</returns>
        public CommitmentTypeIndication Add(CommitmentTypeIndication objectToAdd)
        {
            base.Add(objectToAdd);

            return(objectToAdd);
        }
        /// <summary>
        /// Add typed object to the collection
        /// </summary>
        /// <param name="objectToAdd">Typed object to be added to collection</param>
        /// <returns>The object that has been added to collection</returns>
        public CommitmentTypeIndication Add(CommitmentTypeIndication objectToAdd)
        {
            base.Add(objectToAdd);

            return objectToAdd;
        }