示例#1
0
        public static SignedSignaturePropertiesType SetSigningTime(this SignedSignaturePropertiesType signedSignatureProperties)
        {
            signedSignatureProperties.SigningTime          = DateTime.Now;
            signedSignatureProperties.SigningTimeSpecified = true;

            return(signedSignatureProperties);
        }
示例#2
0
        public static SignedSignaturePropertiesType SetSigningCertificate(this SignedSignaturePropertiesType signedSignatureProperties
                                                                          , X509Certificate2 certificate)
        {
            Debug.Assert(certificate != null);

            signedSignatureProperties.SigningCertificate = new CertIDType[]
            {
                new CertIDType
                {
                    CertDigest = new DigestAlgAndValueType
                    {
                        DigestMethod = new XAdES.DigestMethodType
                        {
                            Algorithm = SignedXml.XmlDsigSHA1Url
                        }
                        , DigestValue = certificate.RawData.ComputeSHA1Hash()
                    }
                    , IssuerSerial = new XAdES.X509IssuerSerialType
                    {
                        X509IssuerName     = X501.ToString(new ASN1(certificate.IssuerName.RawData)) // RFC2253 Encoded
                        , X509SerialNumber = Int64.Parse(certificate.SerialNumber, NumberStyles.HexNumber).ToString()
                    }
                }
            };

            return(signedSignatureProperties);
        }
示例#3
0
        public static SignaturePolicyIdentifierType SetSignaturePolicyIdentifier(this SignedSignaturePropertiesType signedSignatureProperties)
        {
            signedSignatureProperties.SignaturePolicyIdentifier = new SignaturePolicyIdentifierType
            {
                Item = new SignaturePolicyIdType
                {
                    SigPolicyId = new ObjectIdentifierType
                    {
                        Identifier = new IdentifierType
                        {
                            Value = PolicyIdentifier
                        }
                        , Description = "Política de Firma FacturaE v3.1"
                    }
                    ,
                    SigPolicyHash = new DigestAlgAndValueType
                    {
                        DigestMethod = new XAdES.DigestMethodType
                        {
                            Algorithm = SignedXml.XmlDsigSHA1Url
                        }
                        , DigestValue = ReadPolicyFile().ComputeSHA1Hash()
                    }
                }
            };

            return(signedSignatureProperties.SignaturePolicyIdentifier);
        }
示例#4
0
        public static SignedSignaturePropertiesType SetSigningTime(this SignedSignaturePropertiesType signedSignatureProperties)
        {
            // signedSignatureProperties.SigningTime = XsdSchemas.NowInCanonicalRepresentation();
            signedSignatureProperties.SigningTime = DateTime.Now;

            return(signedSignatureProperties);
        }
示例#5
0
        public static SignedSignaturePropertiesType SetSignerRole(this SignedSignaturePropertiesType signedSignatureProperties
                                                                  , ClaimedRole signerRole)
        {
            signedSignatureProperties.SignerRole = new SignerRoleType
            {
                ClaimedRoles = new List <ClaimedRole> {
                    signerRole
                }
            };

            return(signedSignatureProperties);
        }