private static MessagePartSpecification ExtractMessageParts(string action,
                                                                    ScopedMessagePartSpecification scopedParts, bool isForSignature)
        {
            MessagePartSpecification parts = null;

            if (scopedParts.TryGetParts(action, out parts))
            {
                return(parts);
            }
            else if (scopedParts.TryGetParts(MessageHeaders.WildcardAction, out parts))
            {
                return(parts);
            }

            // send back a fault indication that the action is unknown
            SecurityVersion wss        = MessageSecurityVersion.Default.SecurityVersion;
            FaultCode       subCode    = new FaultCode(wss.InvalidSecurityFaultCode.Value, wss.HeaderNamespace.Value);
            FaultCode       senderCode = FaultCode.CreateSenderFaultCode(subCode);
            FaultReason     reason     = new FaultReason(SR.Format(SR.InvalidOrUnrecognizedAction, action), System.Globalization.CultureInfo.CurrentCulture);
            MessageFault    fault      = MessageFault.CreateFault(senderCode, reason);

            if (isForSignature)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.Format(SR.NoSignaturePartsSpecified, action), null, fault));
            }
            else
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.Format(SR.NoEncryptionPartsSpecified, action), null, fault));
            }
        }
示例#2
0
 public ChannelProtectionRequirements()
 {
     IncomingSignatureParts  = new ScopedMessagePartSpecification();
     IncomingEncryptionParts = new ScopedMessagePartSpecification();
     OutgoingSignatureParts  = new ScopedMessagePartSpecification();
     OutgoingEncryptionParts = new ScopedMessagePartSpecification();
 }
 internal ScopedMessagePartSpecification(ScopedMessagePartSpecification other, bool newIncludeBody)
     : this(other)
 {
     channelParts.IsBodyIncluded = newIncludeBody;
     foreach (string action in actionParts.Keys)
     {
         actionParts[action].IsBodyIncluded = newIncludeBody;
     }
 }
示例#4
0
 private static void AddActionParts(ScopedMessagePartSpecification to, ScopedMessagePartSpecification from)
 {
     foreach (string action in from.Actions)
     {
         if (from.TryGetParts(action, true, out MessagePartSpecification p))
         {
             to.AddParts(p, action);
         }
     }
 }
示例#5
0
 static void AddActionParts(ScopedMessagePartSpecification to, ScopedMessagePartSpecification from)
 {
     foreach (var action in from.Actions)
     {
         MessagePartSpecification p;
         if (from.TryGetParts(action, true, out p))
         {
             to.AddParts(p, action);
         }
     }
 }
示例#6
0
        internal ChannelProtectionRequirements(ChannelProtectionRequirements other, ProtectionLevel newBodyProtectionLevel)
        {
            if (other == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(other));
            }

            IncomingSignatureParts  = new ScopedMessagePartSpecification(other.IncomingSignatureParts, newBodyProtectionLevel != ProtectionLevel.None);
            IncomingEncryptionParts = new ScopedMessagePartSpecification(other.IncomingEncryptionParts, newBodyProtectionLevel == ProtectionLevel.EncryptAndSign);
            OutgoingSignatureParts  = new ScopedMessagePartSpecification(other.OutgoingSignatureParts, newBodyProtectionLevel != ProtectionLevel.None);
            OutgoingEncryptionParts = new ScopedMessagePartSpecification(other.OutgoingEncryptionParts, newBodyProtectionLevel == ProtectionLevel.EncryptAndSign);
        }
示例#7
0
        public ChannelProtectionRequirements(ChannelProtectionRequirements other)
        {
            if (other == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(other));
            }

            IncomingSignatureParts  = new ScopedMessagePartSpecification(other.IncomingSignatureParts);
            IncomingEncryptionParts = new ScopedMessagePartSpecification(other.IncomingEncryptionParts);
            OutgoingSignatureParts  = new ScopedMessagePartSpecification(other.OutgoingSignatureParts);
            OutgoingEncryptionParts = new ScopedMessagePartSpecification(other.OutgoingEncryptionParts);
        }
        public ScopedMessagePartSpecification(ScopedMessagePartSpecification other)
            : this()
        {
            if (other == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(other)));
            }

            channelParts.Union(other.channelParts);
            if (other.actionParts != null)
            {
                foreach (string action in other.actionParts.Keys)
                {
                    MessagePartSpecification p = new MessagePartSpecification();
                    p.Union(other.actionParts[action]);
                    actionParts[action] = p;
                }
            }
        }
 internal void CopyTo(ScopedMessagePartSpecification target)
 {
     if (target == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("target");
     }
     target.ChannelParts.IsBodyIncluded = ChannelParts.IsBodyIncluded;
     foreach (XmlQualifiedName headerType in ChannelParts.HeaderTypes)
     {
         if (!target.channelParts.IsHeaderIncluded(headerType.Name, headerType.Namespace))
         {
             target.ChannelParts.HeaderTypes.Add(headerType);
         }
     }
     foreach (string action in actionParts.Keys)
     {
         target.AddParts(actionParts[action], action);
     }
 }
示例#10
0
        private static MessagePartSpecification UnionMessagePartSpecifications(ScopedMessagePartSpecification actionParts)
        {
            var result = new MessagePartSpecification(false);

            foreach (string action in actionParts.Actions)
            {
                if (actionParts.TryGetParts(action, out MessagePartSpecification parts))
                {
                    if (parts.IsBodyIncluded)
                    {
                        result.IsBodyIncluded = true;
                    }
                    foreach (XmlQualifiedName headerType in parts.HeaderTypes)
                    {
                        if (!result.IsHeaderIncluded(headerType.Name, headerType.Namespace))
                        {
                            result.HeaderTypes.Add(headerType);
                        }
                    }
                }
            }
            return(result);
        }