private NetTcpBinding(TcpTransportBindingElement transport, BinaryMessageEncodingBindingElement encoding, NetTcpSecurity security) : this() { _security = security; }
private NetTcpBinding(TcpTransportBindingElement transport, BinaryMessageEncodingBindingElement encoding, NetTcpSecurity security) : this() { _security = security; }
private static void GetNetTcpBindingDetails(NetTcpBinding binding, ref string name, ref string mode, ref string credentialType) { if (binding is NetTcpContextBinding) { name = GetBindingName <NetTcpContextBinding>(binding); } else { name = GetBindingName <NetTcpBinding>(binding); } NetTcpSecurity netTcpSecurity = binding.Security; mode = netTcpSecurity?.Mode.ToString(); switch (netTcpSecurity?.Mode) { case SecurityMode.None: credentialType = "N/A"; break; case SecurityMode.Transport: credentialType = netTcpSecurity.Transport?.ClientCredentialType.ToString(); break; case SecurityMode.Message: credentialType = netTcpSecurity.Message?.ClientCredentialType.ToString(); break; case SecurityMode.TransportWithMessageCredential: credentialType = $"{netTcpSecurity.Transport?.ClientCredentialType.ToString()}+{netTcpSecurity.Message?.ClientCredentialType.ToString()}"; break; } }
internal NetTcpBinding (TcpTransportBindingElement transport, NetTcpSecurity security, bool reliableSessionEnabled) { this.transport = transport; this.security = security; }
internal NetTcpBinding(TcpTransportBindingElement transport, NetTcpSecurity security, bool reliableSessionEnabled) { this.transport = transport; this.security = security; }
private void CheckSettings() { #if FEATURE_NETNATIVE // In .NET Native, some settings for the binding security are not supported; this check is not necessary for CoreCLR NetTcpSecurity security = this.Security; if (security == null) { return; } SecurityMode mode = security.Mode; if (mode == SecurityMode.None) { return; } else if (mode == SecurityMode.Message) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.UnsupportedSecuritySetting, "Mode", mode))); } // Message.ClientCredentialType = Certificate, IssuedToken or Windows are not supported. if (mode == SecurityMode.TransportWithMessageCredential) { MessageSecurityOverTcp message = security.Message; if (message != null) { MessageCredentialType mct = message.ClientCredentialType; if ((mct == MessageCredentialType.Certificate) || (mct == MessageCredentialType.IssuedToken) || (mct == MessageCredentialType.Windows)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.UnsupportedSecuritySetting, "Message.ClientCredentialType", mct))); } } } #endif // FEATURE_NETNATIVE }
private NetTcpBinding(TcpTransportBindingElement transport, BinaryMessageEncodingBindingElement encoding, TransactionFlowBindingElement context, ReliableSessionBindingElement session, NetTcpSecurity security) : this() { _security = security; this.ReliableSession.Enabled = session != null; InitializeFrom(transport, encoding, context, session); }
NetTcpBinding(TcpTransportBindingElement transport, BinaryMessageEncodingBindingElement encoding, TransactionFlowBindingElement context, ReliableSessionBindingElement session, NetTcpSecurity security) : this() { this.security = security; this.ReliableSession.Enabled = session != null; InitializeFrom(transport, encoding, context, session); }
public static void Transport_Property_Sets() { NetTcpSecurity security = new NetTcpSecurity(); TcpTransportSecurity newSecurity = new TcpTransportSecurity(); security.Transport = newSecurity; Assert.Equal<TcpTransportSecurity>(newSecurity, security.Transport); }
static void Main(string[] args) { BinaryFormatter bFormatter = new BinaryFormatter(); FileStream inPut = new FileStream("C:\\Users\\DEVELOPER4\\Desktop\\savefile\\lolblackjagged.yup", FileMode.Open, FileAccess.Read); States state = new States(); state.gridSize = (Size)bFormatter.Deserialize(inPut); state.innerRectColor = (Color[][])bFormatter.Deserialize(inPut); state.innerShapeColor = (Color[][])bFormatter.Deserialize(inPut); state.rectColor = (Color[][])bFormatter.Deserialize(inPut); state.shapeColor = (Color[][])bFormatter.Deserialize(inPut); state.types = (int[][])bFormatter.Deserialize(inPut); state.rotation = (int[][])bFormatter.Deserialize(inPut); state.values = (int[][])bFormatter.Deserialize(inPut); state.circleGrid = (Rectangle[][])bFormatter.Deserialize(inPut); state.rectangleGrid = (Rectangle[][])bFormatter.Deserialize(inPut); state.lvls = Converter.ToJagged(new int[state.gridSize.Height,state.gridSize.Width]); state.owned = new List<Location>[4]; for (int i = 0; i < state.owned.Length; i++) { state.owned[i] = new List<Location>(); } inPut.Close(); Console.WriteLine("Number of Players?"); state.numOfPlayers = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Total Value?"); state.totalValue = Convert.ToInt32(Console.ReadLine()); //ICommandBoardService proxy; using (ServiceHost host = new ServiceHost(typeof(CommandBoardServiceLibrary.CommandBoardService))) { NetTcpBinding ntb = new NetTcpBinding(); NetTcpSecurity nts = new NetTcpSecurity(); nts.Mode = SecurityMode.None; ntb.Security = nts; host.AddServiceEndpoint(typeof( CommandBoardServiceLibrary.ICommandBoardService), new NetTcpBinding(),"net.tcp://localhost:9000/commandboard"); host.Open(); ICommandBoardService proxy = ChannelFactory<ICommandBoardService>.CreateChannel( new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:9000/commandboard")); proxy.setState(state); Console.WriteLine("Good to go"); Console.ReadLine(); } }
internal void InitializeFrom(NetTcpSecurity 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 ApplyConfiguration(NetTcpSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } security.Mode = this.Mode; this.Transport.ApplyConfiguration(security.Transport); this.Message.ApplyConfiguration(security.Message); }
internal void InitializeFrom(NetTcpSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } SetPropertyValueIfNotDefaultValue(ConfigurationStrings.Mode, security.Mode); this.Transport.InitializeFrom(security.Transport); this.Message.InitializeFrom(security.Message); }
private static bool TryCreateSecurity(SecurityBindingElement sbe, UnifiedSecurityMode mode, bool isReliableSession, BindingElement transportSecurity, TcpTransportSecurity tcpTransportSecurity, out NetTcpSecurity security) { if (sbe != null) { mode &= UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message; } else { mode &= ~(UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message); } SecurityMode mode2 = SecurityModeHelper.ToSecurityMode(mode); return(NetTcpSecurity.TryCreate(sbe, mode2, isReliableSession, transportSecurity, tcpTransportSecurity, out security)); }
// In the Win8 profile, some settings for the binding security are not supported. void CheckSettings() { if (!UnsafeNativeMethods.IsTailoredApplication.Value) { return; } NetTcpSecurity security = this.Security; if (security == null) { return; } SecurityMode mode = security.Mode; if (mode == SecurityMode.None) { return; } else if (mode == SecurityMode.Message) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.UnsupportedSecuritySetting, "Mode", mode))); } // Message.ClientCredentialType = Certificate, IssuedToken or Windows are not supported. if (mode == SecurityMode.TransportWithMessageCredential) { MessageSecurityOverTcp message = security.Message; if (message != null) { MessageCredentialType mct = message.ClientCredentialType; if ((mct == MessageCredentialType.Certificate) || (mct == MessageCredentialType.IssuedToken) || (mct == MessageCredentialType.Windows)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.UnsupportedSecuritySetting, "Message.ClientCredentialType", mct))); } } } // Transport.ClientCredentialType = Certificate is not supported. Fx.Assert((mode == SecurityMode.Transport) || (mode == SecurityMode.TransportWithMessageCredential), "Unexpected SecurityMode value: " + mode); TcpTransportSecurity transport = security.Transport; if ((transport != null) && (transport.ClientCredentialType == TcpClientCredentialType.Certificate)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.UnsupportedSecuritySetting, "Transport.ClientCredentialType", transport.ClientCredentialType))); } }
internal static bool TryCreate(SecurityBindingElement wsSecurity, SecurityMode mode, bool isReliableSessionEnabled, BindingElement transportSecurity, TcpTransportSecurity tcpTransportSecurity, out NetTcpSecurity security) { security = null; MessageSecurityOverTcp messageSecurity = null; if (mode == SecurityMode.Message) { if (!MessageSecurityOverTcp.TryCreate(wsSecurity, isReliableSessionEnabled, null, out messageSecurity)) { return false; } } else if ((mode == SecurityMode.TransportWithMessageCredential) && !MessageSecurityOverTcp.TryCreate(wsSecurity, isReliableSessionEnabled, transportSecurity, out messageSecurity)) { return false; } security = new NetTcpSecurity(mode, tcpTransportSecurity, messageSecurity); return SecurityElementBase.AreBindingsMatching(security.CreateMessageSecurity(isReliableSessionEnabled), wsSecurity, false); }
internal static bool TryCreate(SecurityBindingElement wsSecurity, SecurityMode mode, bool isReliableSessionEnabled, BindingElement transportSecurity, TcpTransportSecurity tcpTransportSecurity, out NetTcpSecurity security) { security = null; MessageSecurityOverTcp messageSecurity = null; if (mode == SecurityMode.Message) { if (!MessageSecurityOverTcp.TryCreate(wsSecurity, isReliableSessionEnabled, null, out messageSecurity)) { return(false); } } else if ((mode == SecurityMode.TransportWithMessageCredential) && !MessageSecurityOverTcp.TryCreate(wsSecurity, isReliableSessionEnabled, transportSecurity, out messageSecurity)) { return(false); } security = new NetTcpSecurity(mode, tcpTransportSecurity, messageSecurity); return(SecurityElementBase.AreBindingsMatching(security.CreateMessageSecurity(isReliableSessionEnabled), wsSecurity, false)); }
private static bool TryCreateSecurity(SecurityBindingElement sbe, UnifiedSecurityMode mode, bool isReliableSession, BindingElement transportSecurity, TcpTransportSecurity tcpTransportSecurity, out NetTcpSecurity security) { if (sbe != null) { mode &= UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential; } else { mode &= ~(UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential); } SecurityMode securityMode = SecurityModeHelper.ToSecurityMode(mode); // TODO: Fx.Assert(SecurityModeHelper.IsDefined(securityMode), string.Format("Invalid SecurityMode value: {0}.", securityMode.ToString())); if (NetTcpSecurity.TryCreate(sbe, securityMode, isReliableSession, transportSecurity, tcpTransportSecurity, out security)) { return(true); } return(false); }
public NetTcpBinding (SecurityMode securityMode, bool reliableSessionEnabled) { security = new NetTcpSecurity (securityMode); }
private static UnifiedSecurityMode GetModeFromTransportSecurity(BindingElement transport) { return(NetTcpSecurity.GetModeFromTransportSecurity(transport)); }
private static bool SetTransportSecurity(BindingElement transport, SecurityMode mode, TcpTransportSecurity transportSecurity) { return(NetTcpSecurity.SetTransportSecurity(transport, mode, transportSecurity)); }
internal static bool TryCreate(SecurityBindingElement wsSecurity, SecurityMode mode, bool isReliableSessionEnabled, BindingElement transportSecurity, TcpTransportSecurity tcpTransportSecurity, out NetTcpSecurity security) { throw ExceptionHelper.PlatformNotSupported("NetTcpSecurity.TryCreate is not supported."); }
public static List<NetTcpBinding> GetNetTcpBindings(string exeConfigPath) { var svcSection = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath); var defaultTimeout = new TimeSpan(0, 0, 60); var configs = new List<NetTcpBinding>(); foreach ( var section in svcSection.Bindings.NetTcpBinding.ConfiguredBindings .Cast<NetTcpBindingElement>()) { var dfltb = new NetTcpBinding(); var binding = new NetTcpBinding { Name = section.Name, CloseTimeout = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : defaultTimeout, OpenTimeout = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : defaultTimeout, SendTimeout = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : defaultTimeout, ReceiveTimeout = section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : defaultTimeout, MaxReceivedMessageSize = section.MaxReceivedMessageSize > 0 ? section.MaxReceivedMessageSize : dfltb.MaxReceivedMessageSize, MaxBufferPoolSize = section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : dfltb.MaxBufferPoolSize, MaxConnections = section.MaxConnections > 0 ? section.MaxConnections : dfltb.MaxConnections, ListenBacklog = section.ListenBacklog > 0 ? section.ListenBacklog : dfltb.ListenBacklog, PortSharingEnabled = section.PortSharingEnabled, TransactionFlow = section.TransactionFlow, TransferMode = section.TransferMode, HostNameComparisonMode = section.HostNameComparisonMode }; 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 netTcpSecurity = new NetTcpSecurity() { Mode = section.Security.Mode }; var tcpTransportSecurity = new TcpTransportSecurity(); var msgSecurityOverTcp = new MessageSecurityOverTcp { ClientCredentialType = section.Security.Message.ClientCredentialType, AlgorithmSuite = section.Security.Message.AlgorithmSuite }; netTcpSecurity.Message = msgSecurityOverTcp; netTcpSecurity.Transport = tcpTransportSecurity; binding.Security = netTcpSecurity; if (readerQuotas != null) { binding.ReaderQuotas = readerQuotas; } binding.ReliableSession = new OptionalReliableSession { Enabled = section.ReliableSession.Enabled, InactivityTimeout = section.ReliableSession.InactivityTimeout, Ordered = section.ReliableSession.Ordered }; configs.Add(binding); } return configs; }
public NetTcpBinding(SecurityMode securityMode, bool reliableSessionEnabled) { security = new NetTcpSecurity(securityMode); transport = new TcpTransportBindingElement(); }
public NetTcpBinding() { this.security = new NetTcpSecurity(); this.Initialize(); }
public static void Mode_Property_Sets(SecurityMode mode) { NetTcpSecurity security = new NetTcpSecurity(); security.Mode = mode; Assert.Equal<SecurityMode>(mode, security.Mode); }
public static void Mode_Property_Set_Invalid_Value_Throws() { NetTcpSecurity security = new NetTcpSecurity(); Assert.Throws<ArgumentOutOfRangeException>(() => security.Mode = (SecurityMode)999); }
public static void Ctor_Default_Initializes_Properties() { // new NetTcpSecurity() initializes correct defaults NetTcpSecurity security = new NetTcpSecurity(); Assert.Equal<SecurityMode>(SecurityMode.Transport, security.Mode); }
public NetTcpBinding(SecurityMode securityMode, bool reliableSessionEnabled) { security = new NetTcpSecurity(securityMode); }
public NetTcpBinding() { this.security = new NetTcpSecurity(); this.Initialize(); }
private static bool TryCreateSecurity(SecurityBindingElement sbe, UnifiedSecurityMode mode, bool isReliableSession, BindingElement transportSecurity, TcpTransportSecurity tcpTransportSecurity, out NetTcpSecurity security) { if (sbe != null) { mode &= UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message; } else { mode &= ~(UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message); } SecurityMode mode2 = SecurityModeHelper.ToSecurityMode(mode); return NetTcpSecurity.TryCreate(sbe, mode2, isReliableSession, transportSecurity, tcpTransportSecurity, out security); }
private static bool TryCreateSecurity(SecurityBindingElement sbe, UnifiedSecurityMode mode, bool isReliableSession, BindingElement transportSecurity, TcpTransportSecurity tcpTransportSecurity, out NetTcpSecurity security) { if (sbe != null) mode &= UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential; else mode &= ~(UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential); SecurityMode securityMode = SecurityModeHelper.ToSecurityMode(mode); Contract.Assert(SecurityModeHelper.IsDefined(securityMode), string.Format("Invalid SecurityMode value: {0}.", securityMode.ToString())); if (NetTcpSecurity.TryCreate(sbe, securityMode, isReliableSession, transportSecurity, tcpTransportSecurity, out security)) return true; return false; }
internal static bool TryCreate(SecurityBindingElement wsSecurity, SecurityMode mode, bool isReliableSessionEnabled, BindingElement transportSecurity, TcpTransportSecurity tcpTransportSecurity, out NetTcpSecurity security) { throw ExceptionHelper.PlatformNotSupported("NetTcpSecurity.TryCreate is not supported."); }
public NetTcpBinding (SecurityMode securityMode, bool reliableSessionEnabled) { security = new NetTcpSecurity (securityMode); transport = new TcpTransportBindingElement (); }
public static void Security_Property_Sets() { NetTcpBinding binding = new NetTcpBinding(); NetTcpSecurity security = new NetTcpSecurity(); binding.Security = security; Assert.Equal<NetTcpSecurity>(security, binding.Security); }
bool ImportNetTcpBinding ( WsdlImporter importer, WsdlEndpointConversionContext context, CustomBinding custom, WS.Soap12Binding soap) { TcpTransportBindingElement transportElement = null; BinaryMessageEncodingBindingElement binaryElement = null; TransactionFlowBindingElement transactionFlowElement = null; WindowsStreamSecurityBindingElement windowsStreamElement = null; SslStreamSecurityBindingElement sslStreamElement = null; bool foundUnknownElement = false; foreach (var element in custom.Elements) { if (element is TcpTransportBindingElement) transportElement = (TcpTransportBindingElement)element; else if (element is BinaryMessageEncodingBindingElement) binaryElement = (BinaryMessageEncodingBindingElement)element; else if (element is TransactionFlowBindingElement) transactionFlowElement = (TransactionFlowBindingElement)element; else if (element is WindowsStreamSecurityBindingElement) windowsStreamElement = (WindowsStreamSecurityBindingElement)element; else if (element is SslStreamSecurityBindingElement) sslStreamElement = (SslStreamSecurityBindingElement)element; else { importer.AddWarning ( "Found unknown binding element `{0}' while importing " + "binding `{1}'.", element.GetType (), custom.Name); foundUnknownElement = true; } } if (foundUnknownElement) return false; if (transportElement == null) { importer.AddWarning ( "Missing TcpTransportBindingElement while importing " + "binding `{0}'.", custom.Name); return false; } if (binaryElement == null) { importer.AddWarning ( "Missing BinaryMessageEncodingBindingElement while importing " + "binding `{0}'.", custom.Name); return false; } if ((windowsStreamElement != null) && (sslStreamElement != null)) { importer.AddWarning ( "Found both WindowsStreamSecurityBindingElement and " + "SslStreamSecurityBindingElement while importing binding `{0}.", custom.Name); return false; } NetTcpSecurity security; if (windowsStreamElement != null) { security = new NetTcpSecurity (SecurityMode.Transport); security.Transport.ProtectionLevel = windowsStreamElement.ProtectionLevel; } else if (sslStreamElement != null) { security = new NetTcpSecurity (SecurityMode.TransportWithMessageCredential); } else { security = new NetTcpSecurity (SecurityMode.None); } var netTcp = new NetTcpBinding (transportElement, security, false); netTcp.Name = context.Endpoint.Binding.Name; netTcp.Namespace = context.Endpoint.Binding.Namespace; context.Endpoint.Binding = netTcp; return true; }