예제 #1
0
 private void InterceptedAcknowledgementResponse(InterceptorMessage message, Headers headers)
 {
     lock (signatureLock)
     {
         SequenceAcknowledgementHeader sequenceAcknowledgementHeader = headers.SequenceAcknowledgement;
         string identityName       = message.Properties.Security.ServiceSecurityContext.PrimaryIdentity.Name;
         int    index              = identityName.LastIndexOf(';');
         string certificateSubject = identityName.Substring(0, index);
         // Try to get the messages that have been acked in the RM session. If none exists return.
         List <UnfinishedSignatureValidationProof> ackedMessages = null;
         //System.Diagnostics.Debug.WriteLine("InterceptedAcknowledgementResponse sequenceID" + sequenceAcknowledgementHeader.SequenceId);
         if (this.unfinishedSignaturesValidationProofStore.TryGetValueFromSequenceAcknowledgementHeader(sequenceAcknowledgementHeader, out ackedMessages))
         {
             // message
             foreach (UnfinishedSignatureValidationProof ackedMessage in ackedMessages)
             {
                 SignatureValidationProof signatureValidationProof = ackedMessage.SignatureValidationProof;
                 if (!signatureValidationProof.Completed)
                 {
                     signatureValidationProof.CompleteValidation(certificateSubject);
                 }
             }
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Intercepts the response, finishing the signatures and adds it to the
        /// message.
        /// </summary>
        /// <param name="message"></param>
        public override void InterceptResponse(InterceptorMessage message)
        {
            try
            {
                //System.Diagnostics.Debug.Write("Intercepting the response - ");
                Headers headers = new Headers(message);
                SequenceAcknowledgementHeader sequenceAcknowledgement = headers.SequenceAcknowledgement;
                if (message.IsFault)
                {
                }
                else if (headers.SequenceHeader == null)
                {
                }
                else if (headers.RelatesTo != null)
                {
                    this.InterceptedMessageResponse(message, headers);
                }

                if (sequenceAcknowledgement != null)
                {
                    this.InterceptedAcknowledgementResponse(message, headers);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public bool TryGetValueFromSequenceAcknowledgementHeader(SequenceAcknowledgementHeader header, out List <UnfinishedSignatureValidationProof> unfinishedSignatureValidationProofs)
        {
            bool result = true;
            //System.Diagnostics.Debug.WriteLine("SequenceAcknowledgementHeader header, out List<UnfinishedSignatureValidationProof> unfinishedSignatureValidationProofs");
            string sequenceId = header.SequenceId;

            unfinishedSignatureValidationProofs = null;
            List <UnfinishedSignatureValidationProof>      sequenceUnfinishedSignatureValidationProofs = null;
            Predicate <UnfinishedSignatureValidationProof> isMessageNumberWithinAckRange = delegate(UnfinishedSignatureValidationProof unfinishedSignatureValidationProof) { return(header.IsMessageNumberWithinRange(unfinishedSignatureValidationProof.Headers.SequenceHeader.MessageNumber)); };

            result = this.sequenceIdUnfinishedSignaturesCache.TryGetValue(sequenceId, out sequenceUnfinishedSignatureValidationProofs);

            if (sequenceUnfinishedSignatureValidationProofs != null)
            {
                lock (sequenceUnfinishedSignatureValidationProofs)
                {
                    unfinishedSignatureValidationProofs = sequenceUnfinishedSignatureValidationProofs.FindAll(isMessageNumberWithinAckRange);
                }
            }

            return(result);
        }