public ValidationItemModel(ValidationItem vi)
 {
     Type    = vi.Type;
     Message = vi.Message;
     Detail  = vi.Detail;
     InnerValidationResults = vi.InnerValidationResults != null ? new ValidationResultsModel(vi.InnerValidationResults) : null;
 }
示例#2
0
        public XmlSignatureModel(XmlSignature signature, IXmlPolicyMapperBySignature policyMapper = null)
        {
            Type        = signature.SignedEntityType;
            SigningTime = signature.SigningTime;
            if (signature.SignedElement != null)
            {
                SignedElement = new XmlElementModel(signature.SignedElement);
            }
            if (signature.SignatureAlgorithm != null && signature.SignatureValue != null)
            {
                Signature = new SignatureAlgorithmAndValueModel(signature.SignatureAlgorithm, signature.SignatureValue);
            }
            if (signature.PolicyIdentifier != null)
            {
                SignaturePolicy = new SignaturePolicyIdentifierModel(signature.PolicyIdentifier);
            }
            if (signature.SigningCertificate != null)
            {
                Certificate = new CertificateModel(signature.SigningCertificate);
            }
            if (signature.SignatureTimestamps.Any())
            {
                CertifiedDateReference = signature.SignatureTimestamps.First().EncapsulatedTimestamp.GenTime;
                Timestamps             = signature.SignatureTimestamps.Select(ts => new CadesTimestampModel(ts.EncapsulatedTimestamp)).ToList();
            }

            // Validate signature according to the provided policy.
            if (policyMapper != null)
            {
                var vr = signature.Validate(policyMapper);
                ValidationResults = new ValidationResultsModel(vr);
            }
        }