Example #1
0
        protected virtual void ProcessIncomingMessageAsync1_ccp(IProtocolMessage message, CancellationToken cancellationToken)
        {
            MessageProtections appliedProtection = MessageProtections.None;

            foreach (IChannelBindingElement bindingElement in this.IncomingBindingElements)
            {
                MessageProtections?elementProtection = bindingElement.ProcessIncomingMessage(message, cancellationToken);
                if (elementProtection.HasValue)
                {
                    appliedProtection |= elementProtection.Value;
                }
            }

            //write to global object
            GloabalState.appliedProtection = appliedProtection;

            // Ensure that the message's protection requirements have been satisfied.
            int a = (int)((IndirectSignedResponse)message).RequiredProtection;
            int b = (int)appliedProtection;

            if ((a & b) != a)
            {
                Contract.Assume(false);
            }

            PositiveAssertionResponse1 _msg = (PositiveAssertionResponse1)message;

            _msg.EnsureValidMessage();
        }
Example #2
0
        public HttpResponseMessage PrepareResponseAsync_CCP(PositiveAssertionResponse1 message, CancellationToken cancellationToken = default(CancellationToken))
        {
            this.ProcessOutgoingMessageAsync_CCP(message, cancellationToken);
            HttpResponseMessage result;
            var directedMessage = message as IDirectedProtocolMessage;

            result = this.PrepareIndirectResponse(directedMessage);

            return(result);
        }
Example #3
0
        protected virtual void ProcessIncomingMessageAsync1_ccp(IProtocolMessage message, CancellationToken cancellationToken)
        {
            MessageProtections appliedProtection = MessageProtections.None;

            foreach (IChannelBindingElement bindingElement in this.IncomingBindingElements)
            {
                MessageProtections?elementProtection = bindingElement.ProcessIncomingMessage(message, cancellationToken);
                if (elementProtection.HasValue)
                {
                    appliedProtection |= elementProtection.Value;
                }
            }

            //write to global object
            GlobalState.appliedProtection = appliedProtection;

            // Ensure that the message's protection requirements have been satisfied.
            int a = (int)((IndirectSignedResponse)message).RequiredProtection;
            int b = (int)appliedProtection;

            if ((a & b) != a)
            {
                Contract.Assume(false);
            }

            PositiveAssertionResponse1 _msg = (PositiveAssertionResponse1)message;

            if (!(_msg.ReturnTo.Scheme == HttpContext.Current.Request.Url.Scheme))
            {
                Contract.Assume(false);
            }

            if (!(_msg.ReturnTo.Authority == HttpContext.Current.Request.Url.Authority))
            {
                Contract.Assume(false);
            }

            if (!(_msg.ReturnTo.AbsolutePath == HttpContext.Current.Request.Url.AbsolutePath))
            {
                Contract.Assume(false);
            }

            if (!(_msg.ReturnTo == HttpContext.Current.Request.Url))
            {
                Contract.Assume(false);
            }
        }
Example #4
0
        protected void ProcessOutgoingMessageAsync_CCP(PositiveAssertionResponse1 message, CancellationToken cancellationToken)
        {
            MessageProtections appliedProtection = MessageProtections.None;

            foreach (IChannelBindingElement bindingElement in this.outgoingBindingElements)
            {
                Assumes.True(bindingElement.Channel != null);
                MessageProtections?elementProtection = bindingElement.ProcessOutgoingMessage(message, cancellationToken);
                if (elementProtection.HasValue)
                {
                    // Ensure that only one protection binding element applies to this message
                    // for each protection type.

                    if ((appliedProtection & elementProtection.Value) != 0)
                    {
                        Contract.Assume(false);
                    }

                    appliedProtection |= elementProtection.Value;
                }
            }
            message.EnsureValidMessage();
        }