public void AddPartsNull3()
        {
            ScopedMessagePartSpecification s =
                new ScopedMessagePartSpecification();

            s.AddParts(new MessagePartSpecification(), null);
        }
        public void AddParts()
        {
            ScopedMessagePartSpecification s =
                new ScopedMessagePartSpecification();

            Assert.IsFalse(s.ChannelParts.IsBodyIncluded, "#1");
            s.AddParts(new MessagePartSpecification(true));
            Assert.AreEqual(0, s.Actions.Count, "#2");
            Assert.IsTrue(s.ChannelParts.IsBodyIncluded, "#3");

            XmlQualifiedName foo = new XmlQualifiedName("foo");
            XmlQualifiedName bar = new XmlQualifiedName("bar");

            s.AddParts(new MessagePartSpecification(new XmlQualifiedName [] { foo }), "urn:foo");
            Assert.AreEqual(1, s.Actions.Count, "#4");
            MessagePartSpecification m;

            s.TryGetParts("urn:foo", out m);
            Assert.IsNotNull(m, "#5");
            Assert.AreEqual(1, m.HeaderTypes.Count, "#6");

            s.AddParts(new MessagePartSpecification(true, new XmlQualifiedName [] { bar }), "urn:foo");
            Assert.AreEqual(1, s.Actions.Count, "#7");
            s.TryGetParts("urn:foo", out m);
            Assert.IsNotNull(m, "#8");
            //List<XmlQualifiedName> l = new List<XmlQualifiedName> (m.HeaderTypes);
            Assert.AreEqual(2, m.HeaderTypes.Count, "#9");
            Assert.IsTrue(m.IsBodyIncluded, "#10");
        }
        public void AddPartsNull2()
        {
            ScopedMessagePartSpecification s =
                new ScopedMessagePartSpecification();

            s.AddParts(null, "urn:foo");
        }
 static void ProtectProtocolMessage(
     ScopedMessagePartSpecification signaturePart,
     ScopedMessagePartSpecification encryptionPart,
     string action)
 {
     signaturePart.AddParts(BodyOnly, action);
     encryptionPart.AddParts(MessagePartSpecification.NoParts, action);
 }
        public void DefaultValues()
        {
            ScopedMessagePartSpecification s =
                new ScopedMessagePartSpecification();

            Assert.IsNotNull(s.ChannelParts, "#1");
            Assert.AreEqual(0, s.Actions.Count, "#2");
        }
        public void AddToReadOnlyCollection()
        {
            ScopedMessagePartSpecification s =
                new ScopedMessagePartSpecification();

            s.MakeReadOnly();
            Assert.AreEqual(true, s.IsReadOnly, "#1");
            s.AddParts(new MessagePartSpecification(), "urn:myaction");
        }
Пример #7
0
        private void ApplySigningRequirements(ScopedMessagePartSpecification spec)
        {
            MessagePartSpecification parts = new MessagePartSpecification(new XmlQualifiedName[] { new XmlQualifiedName("PeerVia", "http://schemas.microsoft.com/net/2006/05/peer"), new XmlQualifiedName("FloodMessage", "http://schemas.microsoft.com/net/2006/05/peer"), new XmlQualifiedName("PeerTo", "http://schemas.microsoft.com/net/2006/05/peer"), new XmlQualifiedName("MessageID", "http://schemas.microsoft.com/net/2006/05/peer") });

            foreach (string str in spec.Actions)
            {
                spec.AddParts(parts, str);
            }
            spec.AddParts(parts, "*");
        }
 private bool HasProtectionRequirements(ScopedMessagePartSpecification scopedParts)
 {
     foreach (string str in scopedParts.Actions)
     {
         MessagePartSpecification specification;
         if (scopedParts.TryGetParts(str, out specification) && !specification.IsEmpty())
         {
             return(true);
         }
     }
     return(false);
 }
Пример #9
0
        private ChannelProtectionRequirements GetProtectionRequirements()
        {
            ChannelProtectionRequirements requirements = new ChannelProtectionRequirements();
            MessagePartSpecification      signedReliabilityMessageParts = WsrmIndex.GetSignedReliabilityMessageParts(this.reliableMessagingVersion);

            requirements.IncomingSignatureParts.AddParts(signedReliabilityMessageParts);
            requirements.OutgoingSignatureParts.AddParts(signedReliabilityMessageParts);
            if (this.reliableMessagingVersion == System.ServiceModel.ReliableMessagingVersion.WSReliableMessagingFebruary2005)
            {
                ScopedMessagePartSpecification signaturePart  = requirements.IncomingSignatureParts;
                ScopedMessagePartSpecification encryptionPart = requirements.IncomingEncryptionParts;
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/AckRequested");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/SequenceAcknowledgement");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence");
                signaturePart  = requirements.OutgoingSignatureParts;
                encryptionPart = requirements.OutgoingEncryptionParts;
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/SequenceAcknowledgement");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence");
                return(requirements);
            }
            if (this.reliableMessagingVersion != System.ServiceModel.ReliableMessagingVersion.WSReliableMessaging11)
            {
                throw Fx.AssertAndThrow("Reliable messaging version not supported.");
            }
            ScopedMessagePartSpecification incomingSignatureParts  = requirements.IncomingSignatureParts;
            ScopedMessagePartSpecification incomingEncryptionParts = requirements.IncomingEncryptionParts;

            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/AckRequested");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequence");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequenceResponse");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/CreateSequence");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/fault");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/TerminateSequence");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/TerminateSequenceResponse");
            incomingSignatureParts  = requirements.OutgoingSignatureParts;
            incomingEncryptionParts = requirements.OutgoingEncryptionParts;
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/AckRequested");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequence");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequenceResponse");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/CreateSequenceResponse");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/fault");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/TerminateSequence");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/TerminateSequenceResponse");
            return(requirements);
        }
Пример #10
0
        void ApplySigningRequirements(ScopedMessagePartSpecification spec)
        {
            //following are the headers that we add and want signed.
            MessagePartSpecification partSpec = new MessagePartSpecification(
                new XmlQualifiedName(PeerStrings.Via, PeerStrings.Namespace),
                new XmlQualifiedName(PeerOperationNames.Flood, PeerStrings.Namespace),
                new XmlQualifiedName(PeerOperationNames.PeerTo, PeerStrings.Namespace),
                new XmlQualifiedName(PeerStrings.MessageId, PeerStrings.Namespace));

            foreach (string action in spec.Actions)
            {
                spec.AddParts(partSpec, action);
            }
            spec.AddParts(partSpec, MessageHeaders.WildcardAction);
        }
 bool HasProtectionRequirements(ScopedMessagePartSpecification scopedParts)
 {
     foreach (string action in scopedParts.Actions)
     {
         MessagePartSpecification parts;
         if (scopedParts.TryGetParts(action, out parts))
         {
             if (!parts.IsEmpty())
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        public void TryGetParts()
        {
            ScopedMessagePartSpecification s =
                new ScopedMessagePartSpecification();
            MessagePartSpecification ret;

            Assert.IsFalse(s.TryGetParts("urn:myaction", out ret));
            Assert.IsFalse(s.TryGetParts("urn:myaction", true, out ret));
            Assert.IsFalse(s.TryGetParts("urn:myaction", false, out ret));

            s.AddParts(new MessagePartSpecification(), "urn:myaction");
            Assert.IsTrue(s.TryGetParts("urn:myaction", out ret));
            Assert.IsTrue(s.TryGetParts("urn:myaction", true, out ret));
            Assert.IsTrue(s.TryGetParts("urn:myaction", false, out ret));
        }
        ChannelProtectionRequirements GetProtectionRequirements()
        {
            // Listing headers that must be signed.
            ChannelProtectionRequirements result = new ChannelProtectionRequirements();
            MessagePartSpecification      signedReliabilityMessageParts = MakeConnectionUtility.GetSignedReliabilityMessageParts();

            result.IncomingSignatureParts.AddParts(signedReliabilityMessageParts);
            result.OutgoingSignatureParts.AddParts(signedReliabilityMessageParts);

            // From the Client to the Service
            ScopedMessagePartSpecification signaturePart  = result.IncomingSignatureParts;
            ScopedMessagePartSpecification encryptionPart = result.IncomingEncryptionParts;

            ProtectProtocolMessage(signaturePart, encryptionPart, MakeConnectionConstants.MakeConnectionMessage.Action);

            return(result);
        }
Пример #14
0
 void DumpParts(ScopedMessagePartSpecification smp)
 {
     foreach (string name in smp.Actions)
     {
         MessagePartSpecification mp;
         smp.TryGetParts(name, out mp);
         Console.WriteLine("{0}: {1}", name, mp.IsBodyIncluded);
         foreach (XmlQualifiedName qn in mp.HeaderTypes)
         {
             Console.WriteLine(qn);
         }
     }
     Console.WriteLine("ChannelParts: {0}", smp.ChannelParts.IsBodyIncluded);
     foreach (XmlQualifiedName qn in smp.ChannelParts.HeaderTypes)
     {
         Console.WriteLine(qn);
     }
 }
        private ChannelProtectionRequirements GetProtectionRequirements()
        {
            // Listing headers that must be signed.
            ChannelProtectionRequirements result = new ChannelProtectionRequirements();
            MessagePartSpecification      signedReliabilityMessageParts = WsrmIndex.GetSignedReliabilityMessageParts(
                _reliableMessagingVersion);

            result.IncomingSignatureParts.AddParts(signedReliabilityMessageParts);
            result.OutgoingSignatureParts.AddParts(signedReliabilityMessageParts);

            if (_reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
            {
                // Adding RM protocol message actions so that each RM protocol message's body will be
                // signed and encrypted.
                // From the Client to the Service
                ScopedMessagePartSpecification signaturePart  = result.IncomingSignatureParts;
                ScopedMessagePartSpecification encryptionPart = result.IncomingEncryptionParts;
                ProtectProtocolMessage(signaturePart, encryptionPart, WsrmFeb2005Strings.AckRequestedAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, WsrmFeb2005Strings.CreateSequenceAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, WsrmFeb2005Strings.SequenceAcknowledgementAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, WsrmFeb2005Strings.LastMessageAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, WsrmFeb2005Strings.TerminateSequenceAction);

                // From the Service to the Client
                signaturePart  = result.OutgoingSignatureParts;
                encryptionPart = result.OutgoingEncryptionParts;
                ProtectProtocolMessage(signaturePart, encryptionPart, WsrmFeb2005Strings.CreateSequenceResponseAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, WsrmFeb2005Strings.SequenceAcknowledgementAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, WsrmFeb2005Strings.LastMessageAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, WsrmFeb2005Strings.TerminateSequenceAction);
            }
            else if (_reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
            {
                // Adding RM protocol message actions so that each RM protocol message's body will be
                // signed and encrypted.
                // From the Client to the Service
                ScopedMessagePartSpecification signaturePart  = result.IncomingSignatureParts;
                ScopedMessagePartSpecification encryptionPart = result.IncomingEncryptionParts;
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.AckRequestedAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.CloseSequenceAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.CloseSequenceResponseAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.CreateSequenceAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.FaultAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.SequenceAcknowledgementAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.TerminateSequenceAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.TerminateSequenceResponseAction);

                // From the Service to the Client
                signaturePart  = result.OutgoingSignatureParts;
                encryptionPart = result.OutgoingEncryptionParts;
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.AckRequestedAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.CloseSequenceAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.CloseSequenceResponseAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.CreateSequenceResponseAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.FaultAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.SequenceAcknowledgementAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.TerminateSequenceAction);
                ProtectProtocolMessage(signaturePart, encryptionPart, Wsrm11Strings.TerminateSequenceResponseAction);
            }
            else
            {
                throw Fx.AssertAndThrow("Reliable messaging version not supported.");
            }

            return(result);
        }