internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, bool isReliableSessionEnabled, out WSHttpSecurity security) { security = null; NonDualMessageSecurityOverHttp messageSecurity = null; SecurityMode securityMode = SecurityMode.None; if (sbe != null) { mode &= UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential; securityMode = SecurityModeHelper.ToSecurityMode(mode); Fx.Assert(SecurityModeHelper.IsDefined(securityMode), string.Format("Invalid SecurityMode value: {0}.", mode.ToString())); if (!MessageSecurityOverHttp.TryCreate(sbe, securityMode == SecurityMode.TransportWithMessageCredential, isReliableSessionEnabled, out messageSecurity)) { return(false); } } else { mode &= ~(UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential); securityMode = SecurityModeHelper.ToSecurityMode(mode); } Fx.Assert(SecurityModeHelper.IsDefined(securityMode), string.Format("Invalid SecurityMode value: {0}.", securityMode.ToString())); security = new WSHttpSecurity(securityMode, transportSecurity, messageSecurity); return(true); }
internal WS2007HttpBinding(WSHttpSecurity security, bool reliableSessionEnabled) : base(security, reliableSessionEnabled) { this.ReliableSessionBindingElement.ReliableMessagingVersion = s_WS2007ReliableMessagingVersion; this.TransactionFlowBindingElement.TransactionProtocol = s_WS2007TransactionProtocol; this.HttpsTransport.MessageSecurityVersion = s_WS2007MessageSecurityVersion; }
private static void GetWSHttpBindingDetails(WSHttpBinding binding, ref string name, ref string mode, ref string credentialType) { if (binding is WSHttpContextBinding) { name = GetBindingName <WSHttpContextBinding>(binding); } else if (binding is WS2007HttpBinding) { name = GetBindingName <WS2007HttpBinding>(binding); } else { name = GetBindingName <WSHttpBinding>(binding); } WSHttpSecurity wSHttpSecurity = binding.Security; mode = wSHttpSecurity?.Mode.ToString(); switch (wSHttpSecurity?.Mode) { case SecurityMode.None: credentialType = "N/A"; break; case SecurityMode.Transport: credentialType = wSHttpSecurity.Transport?.ClientCredentialType.ToString(); break; case SecurityMode.Message: case SecurityMode.TransportWithMessageCredential: credentialType = $"{wSHttpSecurity.Transport?.ClientCredentialType.ToString()}+{wSHttpSecurity.Message?.ClientCredentialType.ToString()}"; break; } }
internal WS2007HttpBinding(WSHttpSecurity security, bool reliableSessionEnabled) : base(security, reliableSessionEnabled) { this.ReliableSessionBindingElement.ReliableMessagingVersion = WS2007ReliableMessagingVersion; this.TransactionFlowBindingElement.TransactionProtocol = WS2007TransactionProtocol; this.HttpsTransport.MessageSecurityVersion = WS2007MessageSecurityVersion; }
private static bool TryCreateSecurity(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, bool isReliableSession, out WSHttpSecurity security) { if (!WSHttpSecurity.TryCreate(sbe, mode, transportSecurity, isReliableSession, out security)) { return(false); } return(SecurityElementBase.AreBindingsMatching(security.CreateMessageSecurity(isReliableSession, WS2007MessageSecurityVersion), sbe)); }
// This is effectively just a copy of WSHttpBinding.TryCreateSecurity(), only it passes the 2007 security version private static bool TryCreateSecurity(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, bool isReliableSession, out WSHttpSecurity security) { if (!WSHttpSecurity.TryCreate(sbe, mode, transportSecurity, isReliableSession, out security)) { return(false); } // the last check: make sure that security binding element match the incoming security return(System.ServiceModel.Configuration.SecurityElement.AreBindingsMatching(security.CreateMessageSecurity(isReliableSession, s_WS2007MessageSecurityVersion), sbe)); }
internal void InitializeFrom(WSHttpSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } this.Mode = security.Mode; this.Transport.InitializeFrom(security.Transport); this.Message.InitializeFrom(security.Message); }
internal void InitializeFrom(WSHttpSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } SetPropertyValueIfNotDefaultValue(ConfigurationStrings.Mode, security.Mode); this.Transport.InitializeFrom(security.Transport); this.Message.InitializeFrom(security.Message); }
internal void ApplyConfiguration(WSHttpSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } security.Mode = this.Mode; this.Transport.ApplyConfiguration(security.Transport); this.Message.ApplyConfiguration(security.Message); }
// This is effectively just a copy of WSHttpBinding.TryCreate(), only it news up the 2007 version internal new static bool TryCreate(SecurityBindingElement sbe, TransportBindingElement transport, ReliableSessionBindingElement rsbe, TransactionFlowBindingElement tfbe, out Binding binding) { bool isReliableSession = (rsbe != null); binding = null; // reverse GetTransport HttpTransportSecurity transportSecurity = WSHttpSecurity.GetDefaultHttpTransportSecurity(); UnifiedSecurityMode mode; if (!WSHttpBinding.GetSecurityModeFromTransport(transport, transportSecurity, out mode)) { return(false); } HttpsTransportBindingElement httpsBinding = transport as HttpsTransportBindingElement; if (httpsBinding != null && httpsBinding.MessageSecurityVersion != null) { if (httpsBinding.MessageSecurityVersion.SecurityPolicyVersion != s_WS2007MessageSecurityVersion.SecurityPolicyVersion) { return(false); } } WSHttpSecurity security; if (WS2007HttpBinding.TryCreateSecurity(sbe, mode, transportSecurity, isReliableSession, out security)) { WS2007HttpBinding ws2007HttpBinding = new WS2007HttpBinding(security, isReliableSession); bool allowCookies; if (!WSHttpBinding.TryGetAllowCookiesFromTransport(transport, out allowCookies)) { return(false); } ws2007HttpBinding.AllowCookies = allowCookies; binding = ws2007HttpBinding; } if (rsbe != null && rsbe.ReliableMessagingVersion != ReliableMessagingVersion.WSReliableMessaging11) { return(false); } if (tfbe != null && tfbe.TransactionProtocol != TransactionProtocol.WSAtomicTransaction11) { return(false); } return(binding != null); }
internal static bool GetSecurityModeFromTransport(TransportBindingElement transport, HttpTransportSecurity transportSecurity, out UnifiedSecurityMode mode) { mode = UnifiedSecurityMode.None; if (transport is HttpsTransportBindingElement) { mode = UnifiedSecurityMode.Transport | UnifiedSecurityMode.TransportWithMessageCredential; WSHttpSecurity.ApplyTransportSecurity((HttpsTransportBindingElement)transport, transportSecurity); } else if (transport is HttpTransportBindingElement) { mode = UnifiedSecurityMode.None | UnifiedSecurityMode.Message; } else { return(false); } return(true); }
internal static bool TryCreate(SecurityBindingElement sbe, TransportBindingElement transport, ReliableSessionBindingElement rsbe, TransactionFlowBindingElement tfbe, out Binding binding) { UnifiedSecurityMode mode; WSHttpSecurity security2; bool isReliableSession = rsbe != null; binding = null; HttpTransportSecurity defaultHttpTransportSecurity = WSHttpSecurity.GetDefaultHttpTransportSecurity(); if (!WSHttpBinding.GetSecurityModeFromTransport(transport, defaultHttpTransportSecurity, out mode)) { return(false); } HttpsTransportBindingElement element = transport as HttpsTransportBindingElement; if (((element != null) && (element.MessageSecurityVersion != null)) && (element.MessageSecurityVersion.SecurityPolicyVersion != WS2007MessageSecurityVersion.SecurityPolicyVersion)) { return(false); } if (TryCreateSecurity(sbe, mode, defaultHttpTransportSecurity, isReliableSession, out security2)) { bool flag2; WS2007HttpBinding binding2 = new WS2007HttpBinding(security2, isReliableSession); if (!WSHttpBinding.TryGetAllowCookiesFromTransport(transport, out flag2)) { return(false); } binding2.AllowCookies = flag2; binding = binding2; } if ((rsbe != null) && (rsbe.ReliableMessagingVersion != ReliableMessagingVersion.WSReliableMessaging11)) { return(false); } if ((tfbe != null) && (tfbe.TransactionProtocol != TransactionProtocol.WSAtomicTransaction11)) { return(false); } return(binding != null); }
internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, bool isReliableSessionEnabled, out WSHttpSecurity security) { security = null; NonDualMessageSecurityOverHttp messageSecurity = null; SecurityMode none = SecurityMode.None; if (sbe != null) { mode &= UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message; none = SecurityModeHelper.ToSecurityMode(mode); if (!MessageSecurityOverHttp.TryCreate <NonDualMessageSecurityOverHttp>(sbe, none == SecurityMode.TransportWithMessageCredential, isReliableSessionEnabled, out messageSecurity)) { return(false); } } else { mode &= ~(UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message); none = SecurityModeHelper.ToSecurityMode(mode); } security = new WSHttpSecurity(none, transportSecurity, messageSecurity); return(true); }
public WSHttpBinding(SecurityMode mode, bool reliableSessionEnabled) : base(reliableSessionEnabled) { security = new WSHttpSecurity(mode); }
internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, bool isReliableSessionEnabled, out WSHttpSecurity security) { security = null; NonDualMessageSecurityOverHttp messageSecurity = null; SecurityMode none = SecurityMode.None; if (sbe != null) { mode &= UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message; none = SecurityModeHelper.ToSecurityMode(mode); if (!MessageSecurityOverHttp.TryCreate<NonDualMessageSecurityOverHttp>(sbe, none == SecurityMode.TransportWithMessageCredential, isReliableSessionEnabled, out messageSecurity)) { return false; } } else { mode &= ~(UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message); none = SecurityModeHelper.ToSecurityMode(mode); } security = new WSHttpSecurity(none, transportSecurity, messageSecurity); return true; }
public WSHttpBinding(SecurityMode securityMode, bool reliableSessionEnabled) : base(reliableSessionEnabled) { this.security = new WSHttpSecurity(); this.security.Mode = securityMode; }
internal WSHttpBinding(WSHttpSecurity security, bool reliableSessionEnabled) : base(reliableSessionEnabled) { this.security = new WSHttpSecurity(); this.security = (security == null) ? new WSHttpSecurity() : security; }
internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, bool isReliableSessionEnabled, out WSHttpSecurity security) { security = null; NonDualMessageSecurityOverHttp messageSecurity = null; SecurityMode securityMode = SecurityMode.None; if (sbe != null) { mode &= UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential; securityMode = SecurityModeHelper.ToSecurityMode(mode); Fx.Assert(SecurityModeHelper.IsDefined(securityMode), string.Format("Invalid SecurityMode value: {0}.", mode.ToString())); if (!MessageSecurityOverHttp.TryCreate(sbe, securityMode == SecurityMode.TransportWithMessageCredential, isReliableSessionEnabled, out messageSecurity)) { return false; } } else { mode &= ~(UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential); securityMode = SecurityModeHelper.ToSecurityMode(mode); } Fx.Assert(SecurityModeHelper.IsDefined(securityMode), string.Format("Invalid SecurityMode value: {0}.", securityMode.ToString())); security = new WSHttpSecurity(securityMode, transportSecurity, messageSecurity); return true; }
public WSHttpBinding() { this.security = new WSHttpSecurity(); }
internal WS2007HttpBinding(WSHttpSecurity security, bool reliableSessionEnabled) : base(security, reliableSessionEnabled) { HttpsTransport.MessageSecurityVersion = WS2007MessageSecurityVersion; }
public static List<WSHttpBinding> GetWsHttpBindings(string exeConfigPath) { var svcSection = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath); var configs = new List<WSHttpBinding>(); foreach ( var section in svcSection.Bindings.WSHttpBinding.ConfiguredBindings .Cast<WSHttpBindingElement>()) { var df = new WSHttpBinding(); var binding = new WSHttpBinding { Name = section.Name, MaxBufferPoolSize = section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : df.MaxBufferPoolSize, MaxReceivedMessageSize = section.MaxReceivedMessageSize > 0 ? section.MaxReceivedMessageSize : df.MaxReceivedMessageSize, CloseTimeout = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : df.CloseTimeout, OpenTimeout = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : df.OpenTimeout, SendTimeout = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : df.SendTimeout, ReceiveTimeout = section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : df.ReceiveTimeout, TextEncoding = section.TextEncoding ?? df.TextEncoding, MessageEncoding = section.MessageEncoding, AllowCookies = section.AllowCookies, BypassProxyOnLocal = section.BypassProxyOnLocal, TransactionFlow = section.TransactionFlow, HostNameComparisonMode = section.HostNameComparisonMode, UseDefaultWebProxy = section.UseDefaultWebProxy, }; var readerQuotasSection = section.ReaderQuotas; var readerQuotas = new System.Xml.XmlDictionaryReaderQuotas(); if (readerQuotasSection != null && readerQuotasSection.MaxDepth > 0) { readerQuotas.MaxDepth = readerQuotasSection.MaxDepth; readerQuotas.MaxStringContentLength = readerQuotasSection.MaxStringContentLength; readerQuotas.MaxArrayLength = readerQuotasSection.MaxArrayLength; readerQuotas.MaxBytesPerRead = readerQuotasSection.MaxBytesPerRead; readerQuotas.MaxNameTableCharCount = readerQuotasSection.MaxNameTableCharCount; } else { readerQuotas = null; } var reliableSessionSection = section.ReliableSession; var dfRss = new OptionalReliableSession(); var reliableSession = new OptionalReliableSession { Enabled = reliableSessionSection.Enabled, Ordered = reliableSessionSection.Ordered, InactivityTimeout = reliableSessionSection.InactivityTimeout != TimeSpan.Zero ? reliableSessionSection.InactivityTimeout : dfRss.InactivityTimeout, }; var messageSection = section.Security.Message; var message = new NonDualMessageSecurityOverHttp { EstablishSecurityContext = messageSection.EstablishSecurityContext, ClientCredentialType = messageSection.ClientCredentialType, NegotiateServiceCredential = messageSection.NegotiateServiceCredential, AlgorithmSuite = messageSection.AlgorithmSuite }; var transportSection = section.Security.Transport; var transport = new HttpTransportSecurity { ClientCredentialType = transportSection.ClientCredentialType, ProxyCredentialType = transportSection.ProxyCredentialType }; var wsHttpSecuritySection = section.Security; var wsHttpSecurity = new WSHttpSecurity { Mode = wsHttpSecuritySection.Mode, Transport = transport, Message = message }; ; binding.Security = wsHttpSecurity; if (readerQuotas != null) { binding.ReaderQuotas = readerQuotas; } binding.ReliableSession = reliableSession; configs.Add(binding); } return configs; }
public WSHttpBinding (SecurityMode mode, bool reliableSessionEnabled) : base (reliableSessionEnabled) { security = new WSHttpSecurity (mode); }
private static bool TryCreateSecurity(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, bool isReliableSession, out WSHttpSecurity security) { if (!WSHttpSecurity.TryCreate(sbe, mode, transportSecurity, isReliableSession, out security)) { return false; } return SecurityElementBase.AreBindingsMatching(security.CreateMessageSecurity(isReliableSession, WS2007MessageSecurityVersion), sbe); }
// This is effectively just a copy of WSHttpBinding.TryCreateSecurity(), only it passes the 2007 security version static bool TryCreateSecurity(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, bool isReliableSession, out WSHttpSecurity security) { if (!WSHttpSecurity.TryCreate(sbe, mode, transportSecurity, isReliableSession, out security)) return false; // the last check: make sure that security binding element match the incoming security return SecurityElement.AreBindingsMatching(security.CreateMessageSecurity(isReliableSession, WS2007MessageSecurityVersion), sbe); }
public WSHttpBinding(SecurityMode securityMode, bool reliableSessionEnabled) : base(reliableSessionEnabled) { this.security = new WSHttpSecurity(); this.security.Mode = securityMode; }
internal WSHttpBinding(WSHttpSecurity security, bool reliableSessionEnabled) : base(reliableSessionEnabled) { this.security = new WSHttpSecurity(); this.security = (security == null) ? new WSHttpSecurity() : security; }
internal WSHttpBinding(WSHttpSecurity security, bool reliableSessionEnabled) : base(reliableSessionEnabled) { _security = security == null ? new WSHttpSecurity() : security; }
public WSHttpBinding() { this.security = new WSHttpSecurity(); }