예제 #1
0
        /// <summary>
        /// See IDigitalSignatureProvider
        /// </summary>
        void IDigitalSignatureProvider.UnsignDocument(Guid id)
        {
            AssertIsSignable();

            foreach (DigitalSignature signature in DigitalSignatureList)
            {
                if (signature.GuidID == id)
                {
                    // Remove the associated XpsDigitalSignature from the
                    // document
                    if (signature.XpsDigitalSignature != null)
                    {
                        XpsDocument.RemoveSignature(signature.XpsDigitalSignature);
                        signature.XpsDigitalSignature = null;
                    }

                    // Check if the document contains a signature definition
                    // corresponding to this signature
                    bool matchesDefinition = (FindSignatureDefinition(id) != null);

                    // If the signature matches a signature definition in the
                    // document, mark the signature as NotSigned (i.e. an
                    // unsigned request) but leave it in the list
                    if (matchesDefinition)
                    {
                        signature.SignatureState = SignatureStatus.NotSigned;
                    }
                    else
                    {
                        // Remove the signature from the list
                        DigitalSignatureList.Remove(signature);
                    }

                    // It is safe to remove an element from the list that we're
                    // currently enumerating because we stop enumerating as soon
                    // as we find the element we're looking for.
                    break;
                }
            }
        }