GetXml() 공개 메소드

Returns the XML representation of the this object
public GetXml ( ) : XmlElement
리턴 System.Xml.XmlElement
예제 #1
4
        private void InjectXadesXInformation(XadesSignedXml xadesSignedXml)
        {
            TimeStamp xadesXTimeStamp;
            ArrayList signatureValueElementXpaths;            
            byte[] signatureValueHash;            
            byte[] tsaTimeStamp;

            signatureValueElementXpaths = new ArrayList();

            signatureValueElementXpaths.Add("ds:Object/xsd:QualifyingProperties/xsd:UnsignedProperties/xsd:UnsignedSignatureProperties/xsd:CompleteCertificateRefs");
            signatureValueElementXpaths.Add("ds:Object/xsd:QualifyingProperties/xsd:UnsignedProperties/xsd:UnsignedSignatureProperties/xsd:CompleteRevocationRefs");
            
            signatureValueHash = ComputeHashValueOfElementList(xadesSignedXml.GetXml(), signatureValueElementXpaths);

            //jbonilla
            tsaTimeStamp = this.tspSource.GetTimeStampToken(signatureValueHash);
            xadesXTimeStamp = new TimeStamp("RefsOnlyTimeStamp");

            xadesXTimeStamp.EncapsulatedTimeStamp.PkiData = tsaTimeStamp;
            xadesXTimeStamp.CanonicalizationMethod.Algorithm = SignedXml.XmlDsigExcC14NTransformUrl;
            //xadesXTimeStamp.EncapsulatedTimeStamp.Id = "";

            //jbonilla Deprecated
            //foreach (string elementIdValue in elementIdValues)
            //{
            //    hashDataInfo = new HashDataInfo();
            //    hashDataInfo.UriAttribute = "#" + elementIdValue;
            //    xadesXTimeStamp.HashDataInfoCollection.Add(hashDataInfo);
            //}

            UnsignedProperties unsignedProperties = xadesSignedXml.UnsignedProperties;

            unsignedProperties.UnsignedSignatureProperties.RefsOnlyTimeStampFlag = true;
            unsignedProperties.UnsignedSignatureProperties.RefsOnlyTimeStampCollection.Add(xadesXTimeStamp);

            xadesSignedXml.UnsignedProperties = unsignedProperties;

        }
예제 #2
0
        private void RequestTimeStamp(XadesSignedXml xadesSignedXml)
        {
            TimeStamp signatureTimeStamp;
            ArrayList signatureValueElementXpaths;
            byte[] signatureValueHash;
            byte[] tsaTimeStamp;

            signatureValueElementXpaths = new ArrayList();
            signatureValueElementXpaths.Add("ds:SignatureValue");            
            signatureValueHash = ComputeHashValueOfElementList(xadesSignedXml.GetXml(), signatureValueElementXpaths);

            //jbonilla
            tsaTimeStamp = this.tspSource.GetTimeStampToken(signatureValueHash);

            signatureTimeStamp = new TimeStamp("SignatureTimeStamp");
            //signatureTimeStamp.EncapsulatedTimeStamp.Id = "SignatureTimeStamp" + this.uid;
            signatureTimeStamp.EncapsulatedTimeStamp.PkiData = tsaTimeStamp;
            signatureTimeStamp.CanonicalizationMethod.Algorithm = SignedXml.XmlDsigExcC14NTransformUrl;

            //jbonilla Deprecated
            //HashDataInfo hashDataInfo = new HashDataInfo();
            //hashDataInfo.UriAttribute = "#" + elementIdValues[0];
            //signatureTimeStamp.HashDataInfoCollection.Add(hashDataInfo);

            UnsignedProperties unsignedProperties = xadesSignedXml.UnsignedProperties;
            unsignedProperties.UnsignedSignatureProperties.SignatureTimeStampCollection.Add(signatureTimeStamp);
            xadesSignedXml.UnsignedProperties = unsignedProperties;

            //TODO jbonilla - Delete?
            XmlElement xml = xadesSignedXml.XadesObject.GetXml();
            XmlElement xml1 = xadesSignedXml.GetXml();
        }
예제 #3
0
        protected internal override void ExtendSignatureTag(XadesSignedXml xadesSignedXml)
        {
            base.ExtendSignatureTag(xadesSignedXml);

            X509Certificate signingCertificate = DotNetUtilities.FromX509Certificate(
                xadesSignedXml.GetSigningCertificate());

            DateTime signingTime = xadesSignedXml.XadesObject.QualifyingProperties
                .SignedProperties.SignedSignatureProperties.SigningTime;

            ValidationContext ctx = certificateVerifier.ValidateCertificate(signingCertificate
                , signingTime, new XAdESCertificateSource(xadesSignedXml.GetXml(), false), null, null);

            UnsignedProperties unsignedProperties = null;
            //int certificateValuesCounter;
            CertificateValues certificateValues;
            EncapsulatedX509Certificate encapsulatedX509Certificate;
            RevocationValues revocationValues;
            CRLValue newCRLValue;
            OCSPValue newOCSPValue;

            unsignedProperties = xadesSignedXml.UnsignedProperties;

            //TODO jbonilla Validate certificate refs.
            {                
                unsignedProperties.UnsignedSignatureProperties.CertificateValues = new CertificateValues();
                certificateValues = unsignedProperties.UnsignedSignatureProperties.CertificateValues;
                //certificateValues.Id = this.certificateValuesIdTextBox.Text;
                //certificateValuesCounter = 0;

                foreach (CertificateAndContext certificate in ctx.GetNeededCertificates())
                {
                    encapsulatedX509Certificate = new EncapsulatedX509Certificate();
                    //encapsulatedX509Certificate.Id = this.certificateValuesIdTextBox.Text + certificateValuesCounter.ToString();
                    encapsulatedX509Certificate.PkiData = certificate.GetCertificate().GetEncoded();
                    //certificateValuesCounter++;
                    certificateValues.EncapsulatedX509CertificateCollection.Add(encapsulatedX509Certificate);
                }             
            }
            
            unsignedProperties = xadesSignedXml.UnsignedProperties;
            unsignedProperties.UnsignedSignatureProperties.RevocationValues = new RevocationValues();
            revocationValues = unsignedProperties.UnsignedSignatureProperties.RevocationValues;
            //revocationValues.Id = this.revocationValuesIdTextBox.Text;           

            if (ctx.GetNeededOCSPResp().Count > 0)
            {
                foreach(BasicOcspResp ocsp in ctx.GetNeededOCSPResp())
                {
                    newOCSPValue = new OCSPValue();
                    newOCSPValue.PkiData = OCSPUtils.FromBasicToResp(ocsp).GetEncoded();
                    revocationValues.OCSPValues.OCSPValueCollection.Add(newOCSPValue);
                }               
            }

            if (ctx.GetNeededCRL().Count > 0)
            {
                foreach (X509Crl crl in ctx.GetNeededCRL())
                {
                    newCRLValue = new CRLValue();
                    newCRLValue.PkiData = crl.GetEncoded();
                    revocationValues.CRLValues.CRLValueCollection.Add(newCRLValue);
                }                
            }           

            xadesSignedXml.UnsignedProperties = unsignedProperties;
        }
예제 #4
0
        public static Document ToDocument(XmlDocument originalDocument, XadesSignedXml xadesSignedXml)
        {
            XmlElement xmlElementToSave;

            originalDocument.DocumentElement.AppendChild(originalDocument.ImportNode(xadesSignedXml.GetXml(), true));
            xmlElementToSave = originalDocument.DocumentElement;

            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.PreserveWhitespace = true; //Needed
            xmlDocument.LoadXml(xmlElementToSave.OuterXml);

            MemoryStream buf = new MemoryStream();
            xmlDocument.Save(buf);
            buf.Seek(0, SeekOrigin.Begin);

            return new InMemoryDocument(buf.ToArray());
        }
예제 #5
0
        protected internal override void ExtendSignatureTag(XadesSignedXml xadesSignedXml)
        {
            base.ExtendSignatureTag(xadesSignedXml);

            X509Certificate signingCertificate = DotNetUtilities.FromX509Certificate(
                xadesSignedXml.GetSigningCertificate());

            DateTime signingTime = xadesSignedXml.XadesObject.QualifyingProperties
                .SignedProperties.SignedSignatureProperties.SigningTime;

            ValidationContext ctx = certificateVerifier.ValidateCertificate(signingCertificate
                , signingTime, new XAdESCertificateSource(xadesSignedXml.GetXml(), false), null, null);

            UnsignedProperties unsignedProperties = xadesSignedXml.UnsignedProperties;

            var completeCertificateRefs = new CompleteCertificateRefs();
            IncorporateCertificateRefs(completeCertificateRefs, ctx);
            unsignedProperties.UnsignedSignatureProperties.CompleteCertificateRefs = completeCertificateRefs;

            var completeRevocationRefs = new CompleteRevocationRefs();
            IncorporateOCSPRefs(completeRevocationRefs, ctx);           
            IncorporateCRLRefs(completeRevocationRefs, ctx);
            unsignedProperties.UnsignedSignatureProperties.CompleteRevocationRefs = completeRevocationRefs;

            xadesSignedXml.UnsignedProperties = unsignedProperties;   
        }