This class contains a roles claimed by the signer but not it is not a certified role
        /// <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;
            ClaimedRole         newClaimedRole;
            IEnumerator         enumerator;
            XmlElement          iterationXmlElement;

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

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

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

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

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

            this.claimedRoleCollection.Clear();
            xmlNodeList = xmlElement.SelectNodes("xsd:ClaimedRole", xmlNamespaceManager);
            enumerator = xmlNodeList.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    iterationXmlElement = enumerator.Current as XmlElement;
                    if (iterationXmlElement != null)
                    {
                        newClaimedRole = new ClaimedRole();
                        newClaimedRole.LoadXml(iterationXmlElement);
                        this.claimedRoleCollection.Add(newClaimedRole);
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
Exemple #4
0
        /// <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 ClaimedRole Add(ClaimedRole 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 ClaimedRole Add(ClaimedRole objectToAdd)
		{
			base.Add(objectToAdd);

			return objectToAdd;
		}