Ejemplo n.º 1
0
        public void Add(string messageId, SequenceHeader header, UnfinishedSignatureValidationProof unfinishedSignatureValidationProof)
        {
            string sequenceId = header.SequenceId;
            List <UnfinishedSignatureValidationProof> sequenceUnfinishedSignatureValidationProofs = null;

            lock (lockObject) {
                // Add the unfinished signature validaton proof to the dictinary using MessageID as key
                this.messageIdUnfinishedSignaturesCache.Set(messageId, unfinishedSignatureValidationProof);

                // Add the unfinished signature validaton proof to the dictinary using SessionID as key
                if (!this.sequenceIdUnfinishedSignaturesCache.TryGetValue(sequenceId, out sequenceUnfinishedSignatureValidationProofs))
                {
                    sequenceUnfinishedSignatureValidationProofs = new List <UnfinishedSignatureValidationProof>();
                    this.sequenceIdUnfinishedSignaturesCache.Add(sequenceId, sequenceUnfinishedSignatureValidationProofs);
                }
                else
                {
                    // the list already exist in the cache
                }
            }

            lock (sequenceUnfinishedSignatureValidationProofs)
            {
                Predicate <UnfinishedSignatureValidationProof> doesSignatureValidationProofForThisMessageAlreadyExist = delegate(UnfinishedSignatureValidationProof usvp) { return(usvp.Headers.MessageId.ToString() == messageId); };
                UnfinishedSignatureValidationProof             duplicateSignatureValidationProof = sequenceUnfinishedSignatureValidationProofs.Find(doesSignatureValidationProofForThisMessageAlreadyExist);
                if (duplicateSignatureValidationProof != null)
                {
                    sequenceUnfinishedSignatureValidationProofs.Remove(duplicateSignatureValidationProof);
                }

                sequenceUnfinishedSignatureValidationProofs.Add(unfinishedSignatureValidationProof);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Intercepts the request, storing the unfinished signatures.
        /// </summary>
        /// <param name="message"></param>
        public override void InterceptRequest(InterceptorMessage message)
        {
            try {
                Headers        headers        = new Headers(message);
                SequenceHeader sequenceHeader = headers.SequenceHeader;
                string         messageId      = string.Empty;
                if (message.IsFault)
                {
                    // ? nothing to do??
                }
                else if (sequenceHeader == null)
                {
                    // ? nothing to do??
                }
                else if (sequenceHeader.IsLastMessage)
                {
                    // ? nothing to do??
                }
                else
                {
                    messageId = headers.MessageId.ToString();
                    UnfinishedSignatureValidationProof unfinishedSignature = new UnfinishedSignatureValidationProof(headers);

                    //System.Diagnostics.Debug.WriteLine("\n\n\nAdding unfinished signature - id:" + messageId + ";unfinished signature validation proof: " + unfinishedSignature.SignatureValidationProof + "\n\n\n");
                    this.unfinishedSignaturesValidationProofStore.Add(messageId, sequenceHeader, unfinishedSignature);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        private void InterceptedMessageResponse(InterceptorMessage message, Headers headers)
        {
            lock (signatureLock)
            {
                SequenceHeader sequenceHeader = headers.SequenceHeader;
                string         relatesTo      = headers.RelatesTo.ToString();

                // Try to get the unfinished signature validation proof. If none exists return.
                UnfinishedSignatureValidationProof unfinishedSignatureValidationProof = null;
                if (this.unfinishedSignaturesValidationProofStore.TryGetValueFromMessageId(relatesTo, out unfinishedSignatureValidationProof))
                {
                    // validation proof retrived
                    //System.Diagnostics.Debug.WriteLine("InterceptedMessageResponse relatesTo " + relatesTo);
                    SignatureValidationProof signatureValidationProof = unfinishedSignatureValidationProof.SignatureValidationProof;
                    string signatureValidationProofKey = ClientSignatureValidationProofBindingExtensionElement.SignatureValidationProofKey;
                    message.AddProperty(signatureValidationProofKey, signatureValidationProof);
                }
            }
        }
Ejemplo n.º 4
0
 public bool TryGetValueFromMessageId(string messageId, out UnfinishedSignatureValidationProof unfinishedSignatureValidationProof)
 {
     return(this.messageIdUnfinishedSignaturesCache.TryGetValue(messageId, out unfinishedSignatureValidationProof));
 }