private DSSXSDNamespace.VerificationReportType FindVerificationReport(ResponseBaseType responseBase)
        {
            if (null == responseBase.OptionalOutputs)
            {
                return(null);
            }
            foreach (XmlElement optionalOutput in responseBase.OptionalOutputs.Any)
            {
                if (optionalOutput.NamespaceURI.Equals(DSSConstants.VR_NAMESPACE) &&
                    optionalOutput.LocalName.Equals("VerificationReport"))
                {
                    DSSXSDNamespace.VerificationReportType verificationReport =
                        (DSSXSDNamespace.VerificationReportType)FromDom("VerificationReport",
                                                                        DSSConstants.VR_NAMESPACE, optionalOutput,
                                                                        typeof(DSSXSDNamespace.VerificationReportType));
                    return(verificationReport);
                }
            }

            return(null);
        }
        public List <SignatureInfo> VerifyWithSigners(byte[] signedDocument, String mimeType)
        {
            ResponseBaseType response = DoVerification(signedDocument, mimeType, false, true);

            ValidateResult(response);

            // TODO: parse verificationReport
            List <SignatureInfo> signers = new List <SignatureInfo>();

            DSSXSDNamespace.VerificationReportType verificationReport = FindVerificationReport(response);
            if (null == verificationReport)
            {
                return(signers);
            }

            foreach (DSSXSDNamespace.IndividualReportType individualReport in verificationReport.IndividualReport)
            {
                if (!DSSConstants.RESULT_MAJOR_SUCCESS.Equals(individualReport.Result.ResultMajor))
                {
                    Console.WriteLine("WARNING: invalid VR result reported: " +
                                      individualReport.Result.ResultMajor);
                    continue;
                }

                DSSXSDNamespace.SignedObjectIdentifierType signedObjectIdentifier
                    = individualReport.SignedObjectIdentifier;

                DateTime signingTime = signedObjectIdentifier.SignedProperties
                                       .SignedSignatureProperties.SigningTime;
                X509Certificate signer = null;
                String          role   = null;

                foreach (XmlElement detail in individualReport.Details.Any)
                {
                    if (detail.NamespaceURI.Equals(DSSConstants.VR_NAMESPACE) &&
                        detail.LocalName.Equals("DetailedSignatureReport"))
                    {
                        DSSXSDNamespace.DetailedSignatureReportType detailedSignatureReport =
                            (DSSXSDNamespace.DetailedSignatureReportType)FromDom("DetailedSignatureReport",
                                                                                 DSSConstants.VR_NAMESPACE, detail,
                                                                                 typeof(DSSXSDNamespace.DetailedSignatureReportType));

                        DSSXSDNamespace.CertificateValidityType certificateValidity =
                            detailedSignatureReport.CertificatePathValidity
                            .PathValidityDetail.CertificateValidity[0];

                        byte[] encodedSigner = certificateValidity.CertificateValue;
                        signer = new X509Certificate(encodedSigner);

                        if (null != detailedSignatureReport.Properties)
                        {
                            DSSXSDNamespace.SignerRoleType1 signerRole = detailedSignatureReport.Properties
                                                                         .SignedProperties.SignedSignatureProperties.SignerRole;
                            if (null != signerRole)
                            {
                                role = signerRole.ClaimedRoles[0].Any[0].Value;
                            }
                        }
                    }
                }

                if (null == signer)
                {
                    throw new SystemException("No signer certificate present in verification report.");
                }

                signers.Add(new SignatureInfo(signer, signingTime, role));
            }
            return(signers);
        }