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.GetString(SR.InvalidOrUnrecognizedAction, action), System.Globalization.CultureInfo.CurrentCulture); MessageFault fault = MessageFault.CreateFault(senderCode, reason); if (isForSignature) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.NoSignaturePartsSpecified, action), null, fault)); } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.NoEncryptionPartsSpecified, action), null, fault)); } }
public ChannelProtectionRequirements() { in_enc = new ScopedMessagePartSpecification(); out_enc = new ScopedMessagePartSpecification(); in_sign = new ScopedMessagePartSpecification(); out_sign = new ScopedMessagePartSpecification(); }
public ChannelProtectionRequirements() { _incomingSignatureParts = new ScopedMessagePartSpecification(); _incomingEncryptionParts = new ScopedMessagePartSpecification(); _outgoingSignatureParts = new ScopedMessagePartSpecification(); _outgoingEncryptionParts = new ScopedMessagePartSpecification(); }
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"); }
internal ScopedMessagePartSpecification(ScopedMessagePartSpecification other, bool newIncludeBody) : this(other) { _channelParts.IsBodyIncluded = newIncludeBody; foreach (string action in _actionParts.Keys) _actionParts[action].IsBodyIncluded = newIncludeBody; }
public void DefaultValues () { ScopedMessagePartSpecification s = new ScopedMessagePartSpecification (); Assert.IsNotNull (s.ChannelParts, "#1"); Assert.AreEqual (0, s.Actions.Count, "#2"); }
public ChannelProtectionRequirements () { in_enc = new ScopedMessagePartSpecification (); out_enc = new ScopedMessagePartSpecification (); in_sign = new ScopedMessagePartSpecification (); out_sign = new ScopedMessagePartSpecification (); }
public ChannelProtectionRequirements() { _incomingSignatureParts = new ScopedMessagePartSpecification(); _incomingEncryptionParts = new ScopedMessagePartSpecification(); _outgoingSignatureParts = new ScopedMessagePartSpecification(); _outgoingEncryptionParts = new ScopedMessagePartSpecification(); }
internal ScopedMessagePartSpecification(ScopedMessagePartSpecification other, bool newIncludeBody) : this(other) { this.channelParts.IsBodyIncluded = newIncludeBody; foreach (string str in this.actionParts.Keys) { this.actionParts[str].IsBodyIncluded = newIncludeBody; } }
internal ScopedMessagePartSpecification(ScopedMessagePartSpecification other, bool newIncludeBody) : this(other) { this.channelParts.IsBodyIncluded = newIncludeBody; foreach (string str in this.actionParts.Keys) { this.actionParts[str].IsBodyIncluded = newIncludeBody; } }
public ScopedMessagePartSpecification( ScopedMessagePartSpecification other) { XmlQualifiedName [] array = new XmlQualifiedName [other.parts.HeaderTypes.Count]; other.parts.HeaderTypes.CopyTo(array, 0); parts = new MessagePartSpecification( other.parts.IsBodyIncluded, array); table = new Dictionary <string, MessagePartSpecification> (other.table); }
internal ScopedMessagePartSpecification(ScopedMessagePartSpecification other, bool newIncludeBody) : this(other) { ChannelParts.IsBodyIncluded = newIncludeBody; foreach (string action in _actionParts.Keys) { _actionParts[action].IsBodyIncluded = newIncludeBody; } }
public ScopedMessagePartSpecification ( ScopedMessagePartSpecification other) { XmlQualifiedName [] array = new XmlQualifiedName [other.parts.HeaderTypes.Count]; other.parts.HeaderTypes.CopyTo (array, 0); parts = new MessagePartSpecification ( other.parts.IsBodyIncluded, array); table = new Dictionary<string,MessagePartSpecification> (other.table); }
public ChannelProtectionRequirements(ChannelProtectionRequirements other) { if (other == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("other")); _incomingSignatureParts = new ScopedMessagePartSpecification(other._incomingSignatureParts); _incomingEncryptionParts = new ScopedMessagePartSpecification(other._incomingEncryptionParts); _outgoingSignatureParts = new ScopedMessagePartSpecification(other._outgoingSignatureParts); _outgoingEncryptionParts = new ScopedMessagePartSpecification(other._outgoingEncryptionParts); }
internal ChannelProtectionRequirements(ChannelProtectionRequirements other, ProtectionLevel newBodyProtectionLevel) { if (other == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("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); }
public ChannelProtectionRequirements ( ChannelProtectionRequirements other) { if (other == null) throw new ArgumentNullException ("other"); in_enc = new ScopedMessagePartSpecification (other.in_enc); out_enc = new ScopedMessagePartSpecification (other.out_enc); in_sign = new ScopedMessagePartSpecification (other.in_sign); out_sign = new ScopedMessagePartSpecification (other.out_sign); }
public ChannelProtectionRequirements(ChannelProtectionRequirements other) { if (other == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("other")); } this.incomingSignatureParts = new ScopedMessagePartSpecification(other.incomingSignatureParts); this.incomingEncryptionParts = new ScopedMessagePartSpecification(other.incomingEncryptionParts); this.outgoingSignatureParts = new ScopedMessagePartSpecification(other.outgoingSignatureParts); this.outgoingEncryptionParts = new ScopedMessagePartSpecification(other.outgoingEncryptionParts); }
private static void AddActionParts(ScopedMessagePartSpecification to, ScopedMessagePartSpecification from) { foreach (string str in from.Actions) { MessagePartSpecification specification; if (from.TryGetParts(str, true, out specification)) { to.AddParts(specification, str); } } }
internal ChannelProtectionRequirements(ChannelProtectionRequirements other, ProtectionLevel newBodyProtectionLevel) { if (other == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("other")); } this.incomingSignatureParts = new ScopedMessagePartSpecification(other.incomingSignatureParts, newBodyProtectionLevel != ProtectionLevel.None); this.incomingEncryptionParts = new ScopedMessagePartSpecification(other.incomingEncryptionParts, newBodyProtectionLevel == ProtectionLevel.EncryptAndSign); this.outgoingSignatureParts = new ScopedMessagePartSpecification(other.outgoingSignatureParts, newBodyProtectionLevel != ProtectionLevel.None); this.outgoingEncryptionParts = new ScopedMessagePartSpecification(other.outgoingEncryptionParts, newBodyProtectionLevel == ProtectionLevel.EncryptAndSign); }
private static void AddActionParts(ScopedMessagePartSpecification to, ScopedMessagePartSpecification from) { foreach (string str in from.Actions) { MessagePartSpecification specification; if (from.TryGetParts(str, true, out specification)) { to.AddParts(specification, str); } } }
private static void AddActionParts(ScopedMessagePartSpecification to, ScopedMessagePartSpecification from) { foreach (string action in from.Actions) { MessagePartSpecification p; if (from.TryGetParts(action, true, out p)) { to.AddParts(p, action); } } }
public ChannelProtectionRequirements( ChannelProtectionRequirements other) { if (other == null) { throw new ArgumentNullException("other"); } in_enc = new ScopedMessagePartSpecification(other.in_enc); out_enc = new ScopedMessagePartSpecification(other.out_enc); in_sign = new ScopedMessagePartSpecification(other.in_sign); out_sign = new ScopedMessagePartSpecification(other.out_sign); }
void AddScopedParts(ScopedMessagePartSpecification src, ScopedMessagePartSpecification dst, bool channelOnly) { dst.AddParts(src.ChannelParts); if (channelOnly) { return; } foreach (string a in src.Actions) { MessagePartSpecification m; src.TryGetParts(a, out m); src.AddParts(m); } }
public ScopedMessagePartSpecification(ScopedMessagePartSpecification other) : this() { if (other == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("other")); } this.channelParts.Union(other.channelParts); if (other.actionParts != null) { foreach (string str in other.actionParts.Keys) { MessagePartSpecification specification = new MessagePartSpecification(); specification.Union(other.actionParts[str]); this.actionParts[str] = specification; } } }
public ScopedMessagePartSpecification(ScopedMessagePartSpecification other) : this() { if (other == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("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; } } }
public ScopedMessagePartSpecification(ScopedMessagePartSpecification other) : this() { if (other == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("other")); } this.channelParts.Union(other.channelParts); if (other.actionParts != null) { foreach (string str in other.actionParts.Keys) { MessagePartSpecification specification = new MessagePartSpecification(); specification.Union(other.actionParts[str]); this.actionParts[str] = specification; } } }
internal void CopyTo(ScopedMessagePartSpecification target) { if (target == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("target"); } target.ChannelParts.IsBodyIncluded = this.ChannelParts.IsBodyIncluded; foreach (XmlQualifiedName name in this.ChannelParts.HeaderTypes) { if (!target.channelParts.IsHeaderIncluded(name.Name, name.Namespace)) { target.ChannelParts.HeaderTypes.Add(name); } } foreach (string str in this.actionParts.Keys) { target.AddParts(this.actionParts[str], str); } }
internal void CopyTo(ScopedMessagePartSpecification target) { if (target == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("target"); } target.ChannelParts.IsBodyIncluded = this.ChannelParts.IsBodyIncluded; foreach (XmlQualifiedName name in this.ChannelParts.HeaderTypes) { if (!target.channelParts.IsHeaderIncluded(name.Name, name.Namespace)) { target.ChannelParts.HeaderTypes.Add(name); } } foreach (string str in this.actionParts.Keys) { target.AddParts(this.actionParts[str], str); } }
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(nameof(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); } }
private static MessagePartSpecification ExtractMessageParts(string action, ScopedMessagePartSpecification scopedParts, bool isForSignature) { MessagePartSpecification parts = null; if (scopedParts.TryGetParts(action, out parts)) { return parts; } if (scopedParts.TryGetParts("*", out parts)) { return parts; } SecurityVersion securityVersion = MessageSecurityVersion.Default.SecurityVersion; FaultCode subCode = new FaultCode(securityVersion.InvalidSecurityFaultCode.Value, securityVersion.HeaderNamespace.Value); FaultCode code = FaultCode.CreateSenderFaultCode(subCode); FaultReason reason = new FaultReason(System.ServiceModel.SR.GetString("InvalidOrUnrecognizedAction", new object[] { action }), CultureInfo.CurrentCulture); MessageFault fault = MessageFault.CreateFault(code, reason); if (isForSignature) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(System.ServiceModel.SR.GetString("NoSignaturePartsSpecified", new object[] { action }), null, fault)); } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(System.ServiceModel.SR.GetString("NoEncryptionPartsSpecified", new object[] { action }), null, fault)); }
private static MessagePartSpecification ExtractMessageParts(string action, ScopedMessagePartSpecification scopedParts, bool isForSignature) { MessagePartSpecification parts = (MessagePartSpecification)null; if (scopedParts.TryGetParts(action, out parts) || scopedParts.TryGetParts("*", out parts)) { return(parts); } SecurityVersion securityVersion = MessageSecurityVersion.Default.SecurityVersion; MessageFault fault = MessageFault.CreateFault(FaultCode.CreateSenderFaultCode(new FaultCode(securityVersion.InvalidSecurityFaultCode.Value, securityVersion.HeaderNamespace.Value)), new FaultReason(SR.GetString("InvalidOrUnrecognizedAction", new object[1] { (object)action }), CultureInfo.CurrentCulture)); if (isForSignature) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception) new MessageSecurityException(SR.GetString("NoSignaturePartsSpecified", new object[1] { (object)action }), (Exception)null, fault)); } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception) new MessageSecurityException(SR.GetString("NoEncryptionPartsSpecified", new object[1] { (object)action }), (Exception)null, fault)); }
private static MessagePartSpecification UnionMessagePartSpecifications(ScopedMessagePartSpecification actionParts) { MessagePartSpecification specification = new MessagePartSpecification(false); foreach (string str in actionParts.Actions) { MessagePartSpecification specification2; if (actionParts.TryGetParts(str, out specification2)) { if (specification2.IsBodyIncluded) { specification.IsBodyIncluded = true; } foreach (XmlQualifiedName name in specification2.HeaderTypes) { if (!specification.IsHeaderIncluded(name.Name, name.Namespace)) { specification.HeaderTypes.Add(name); } } } } return(specification); }
private static MessagePartSpecification UnionMessagePartSpecifications(ScopedMessagePartSpecification actionParts) { MessagePartSpecification result = new MessagePartSpecification(false); foreach (string action in actionParts.Actions) { MessagePartSpecification parts; if (actionParts.TryGetParts(action, out 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); }
void AddScopedParts (ScopedMessagePartSpecification src, ScopedMessagePartSpecification dst, bool channelOnly) { dst.AddParts (src.ChannelParts); if (channelOnly) return; foreach (string a in src.Actions) { MessagePartSpecification m; src.TryGetParts (a, out m); src.AddParts (m); } }
private static MessagePartSpecification UnionMessagePartSpecifications(ScopedMessagePartSpecification actionParts) { MessagePartSpecification specification = new MessagePartSpecification(false); foreach (string str in actionParts.Actions) { MessagePartSpecification specification2; if (actionParts.TryGetParts(str, out specification2)) { if (specification2.IsBodyIncluded) { specification.IsBodyIncluded = true; } foreach (XmlQualifiedName name in specification2.HeaderTypes) { if (!specification.IsHeaderIncluded(name.Name, name.Namespace)) { specification.HeaderTypes.Add(name); } } } } return specification; }
public void AddPartsNull2 () { ScopedMessagePartSpecification s = new ScopedMessagePartSpecification (); s.AddParts (null, "urn:foo"); }
public void AddPartsNull3 () { ScopedMessagePartSpecification s = new ScopedMessagePartSpecification (); s.AddParts (new MessagePartSpecification (), null); }
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.GetString(SR.InvalidOrUnrecognizedAction, action), System.Globalization.CultureInfo.CurrentCulture); MessageFault fault = MessageFault.CreateFault(senderCode, reason); if (isForSignature) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.NoSignaturePartsSpecified, action), null, fault)); } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.NoEncryptionPartsSpecified, action), null, fault)); } }
private static MessagePartSpecification UnionMessagePartSpecifications(ScopedMessagePartSpecification actionParts) { MessagePartSpecification result = new MessagePartSpecification(false); foreach (string action in actionParts.Actions) { MessagePartSpecification parts; if (actionParts.TryGetParts(action, out 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; }
private static void AddActionParts(ScopedMessagePartSpecification to, ScopedMessagePartSpecification from) { foreach (string action in from.Actions) { MessagePartSpecification p; if (from.TryGetParts(action, true, out p)) to.AddParts(p, action); } }
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)); }
public void AddToReadOnlyCollection () { ScopedMessagePartSpecification s = new ScopedMessagePartSpecification (); s.MakeReadOnly (); Assert.AreEqual (true, s.IsReadOnly, "#1"); s.AddParts (new MessagePartSpecification (), "urn:myaction"); }