// The validation process will scan each endpoint to see if it's bindings have binding elements // that are secure. These elements consist of: Transport, Asymmetric, Symmetric, // HttpsTransport, WindowsStream and SSLStream. public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { // Loop through each endpoint individually gathering their binding elements. foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints) { secureElementFound = false; // Retrieve the endpoint's binding element collection. BindingElementCollection bindingElements = endpoint.Binding.CreateBindingElements(); // Look to see if the binding elements collection contains any secure binding // elements. Transport, Asymmetric and Symmetric binding elements are all // derived from SecurityBindingElement. if ((bindingElements.Find <SecurityBindingElement>() != null) || (bindingElements.Find <HttpsTransportBindingElement>() != null) || (bindingElements.Find <WindowsStreamSecurityBindingElement>() != null) || (bindingElements.Find <SslStreamSecurityBindingElement>() != null)) { secureElementFound = true; } // Send a message to the system event viewer whhen an endpoint is deemed insecure. if (!secureElementFound) { throw new Exception(System.DateTime.Now.ToString() + ": The endpoint \"" + endpoint.Name + "\" has no secure bindings."); } } }
private void ValidateNoMSMQandTransactionFlow(ServiceEndpoint endpoint) { BindingElementCollection elements = endpoint.Binding.CreateBindingElements(); if ((elements.Find <TransactionFlowBindingElement>() != null) && (elements.Find <MsmqTransportBindingElement>() != null)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxTransactionFlowAndMSMQ", new object[] { endpoint.Address.Uri.AbsoluteUri }))); } }
/// <summary> /// /// </summary> /// <param name="accountCredentials"></param> /// <returns>A disposable object you should wrap in using() statement</returns> public static DocuSignWeb.APIServiceSoap CreateApiProxy(AccountCredentials accountCredentials) { #if true // the envelope is finally constructed we are ready to send it in DocuSignWeb.APIServiceSoapClient apiService = new DocuSignWeb.APIServiceSoapClient("APIServiceSoap", accountCredentials.ApiUrl); apiService.ClientCredentials.UserName.UserName = accountCredentials.UserName; apiService.ClientCredentials.UserName.Password = accountCredentials.Password; return(apiService); #else // this is a security token configuration // this is required for certain calls like RequestRecipientToken // you need to get a certificate from Thawte or VeriSign first and install it DocuSignWeb.APIServiceSoapClient apiService = new DocuSignWeb.APIServiceSoapClient("APIServiceSoap1", accountCredentials.ApiUrl); apiService.ClientCredentials.UserName.UserName = "******" + ConfigurationManager.AppSettings["IntegratorsKey"] + "]" + ConfigurationManager.AppSettings["APIUserEmail"]; apiService.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["Password"]; // // need to add the supporting token since DocuSign uses dual authentication for // for critical calls CustomBinding binding = (CustomBinding)apiService.Endpoint.Binding; BindingElementCollection elements = binding.CreateBindingElements(); SecurityBindingElement security = elements.Find <SecurityBindingElement>(); UserNameSecurityTokenParameters tokenParameters = new UserNameSecurityTokenParameters(); tokenParameters.InclusionMode = SecurityTokenInclusionMode.AlwaysToRecipient; tokenParameters.RequireDerivedKeys = false; security.EndpointSupportingTokenParameters.SignedEncrypted.Add( tokenParameters); apiService.Endpoint.Binding = new CustomBinding(elements.ToArray());; return(apiService); #endif }
static Binding CreateResponseBinding(Binding binding, Guid ConversationGroupId) { BindingElementCollection bindingElements = binding.CreateBindingElements(); bindingElements.Find <SsbBindingElement>().ConversationGroupId = ConversationGroupId; return(new CustomBinding(bindingElements)); }
public async Task OnConnectedAsync(FramingConnection connection) { if (!_transportSettingsCache.TryGetValue(connection.ServiceDispatcher, out ITransportFactorySettings settings)) { BindingElementCollection be = connection.ServiceDispatcher.Binding.CreateBindingElements(); TransportBindingElement tbe = be.Find <TransportBindingElement>(); settings = new NetFramingTransportSettings { CloseTimeout = connection.ServiceDispatcher.Binding.CloseTimeout, OpenTimeout = connection.ServiceDispatcher.Binding.OpenTimeout, ReceiveTimeout = connection.ServiceDispatcher.Binding.ReceiveTimeout, SendTimeout = connection.ServiceDispatcher.Binding.SendTimeout, ManualAddressing = tbe.ManualAddressing, BufferManager = connection.BufferManager, MaxReceivedMessageSize = tbe.MaxReceivedMessageSize, MessageEncoderFactory = connection.MessageEncoderFactory }; } var channel = new ServerFramingDuplexSessionChannel(connection, settings, false, _servicesScopeFactory.CreateScope().ServiceProvider); channel.ChannelDispatcher = await connection.ServiceDispatcher.CreateServiceChannelDispatcherAsync(channel); await channel.StartReceivingAsync(); }
public RightNowService(IGlobalContext _gContext) { // Set up SOAP API request to retrieve Endpoint Configuration - // Get the SOAP API url of current site as SOAP Web Service endpoint EndpointAddress endPointAddr = new EndpointAddress(_gContext.GetInterfaceServiceUrl(ConnectServiceType.Soap)); // Minimum required BasicHttpBinding binding2 = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding2.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; // Optional depending upon use cases binding2.MaxReceivedMessageSize = 1024 * 1024; binding2.MaxBufferSize = 1024 * 1024; binding2.MessageEncoding = WSMessageEncoding.Mtom; // Create client proxy class _rnowClient = new RightNowSyncPortClient(binding2, endPointAddr); BindingElementCollection elements = _rnowClient.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; _rnowClient.Endpoint.Binding = new CustomBinding(elements); // Add SOAP msg inspector behavior //_rnowClient.Endpoint.Behaviors.Add(new LogMsgBehavior()); // Ask the Add-In framework the handle the session logic _gContext.PrepareConnectSession(_rnowClient.ChannelFactory); // Set up query and set request _rnowClientInfoHeader = new ClientInfoHeader(); _rnowClientInfoHeader.AppID = "Case Management Accelerator Services"; }
internal static new bool TryCreate(BindingElementCollection bindingElements, out Binding binding) { if (bindingElements == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements"); } binding = null; ContextBindingElement contextBindingElement = bindingElements.Find <ContextBindingElement>(); if (contextBindingElement != null && contextBindingElement.ContextExchangeMechanism != ContextExchangeMechanism.HttpCookie) { BindingElementCollection bindingElementsWithoutContext = new BindingElementCollection(bindingElements); bindingElementsWithoutContext.Remove <ContextBindingElement>(); Binding netTcpBinding; if (NetTcpBinding.TryCreate(bindingElementsWithoutContext, out netTcpBinding)) { NetTcpContextBinding contextBinding = new NetTcpContextBinding((NetTcpBinding)netTcpBinding); contextBinding.ContextProtectionLevel = contextBindingElement.ProtectionLevel; contextBinding.ContextManagementEnabled = contextBindingElement.ContextManagementEnabled; binding = contextBinding; } } return(binding != null); }
public Boolean initializeLogger(IGlobalContext globalContext) { EndpointAddress endPointAddr = new EndpointAddress(globalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap)); // Minimum required BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; // Optional depending upon use cases binding.MaxReceivedMessageSize = 1024 * 1024; binding.MaxBufferSize = 1024 * 1024; binding.MessageEncoding = WSMessageEncoding.Mtom; // Create client proxy class RightNowSyncPortClient client = new RightNowSyncPortClient(binding, endPointAddr); // Ask the client to not send the timestamp BindingElementCollection elements = client.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; client.Endpoint.Binding = new CustomBinding(elements); // Ask the Add-In framework the handle the session logic globalContext.PrepareConnectSession(client.ChannelFactory); this.client = client; this.extObject = getExtension(); return(true); }
internal static void SetRawContentTypeMapperIfNecessary(ServiceEndpoint endpoint, bool isDispatch) { Binding binding = endpoint.Binding; ContractDescription contract = endpoint.Contract; if (binding == null) { return; } CustomBinding customBinding = new CustomBinding(binding); BindingElementCollection bec = customBinding.Elements; WebMessageEncodingBindingElement encodingElement = bec.Find <WebMessageEncodingBindingElement>(); if (encodingElement == null || encodingElement.ContentTypeMapper != null) { return; } bool areAllOperationsRawMapperCompatible = true; int numStreamOperations = 0; foreach (OperationDescription operation in contract.Operations) { bool isCompatible = (isDispatch) ? IsRawContentMapperCompatibleDispatchOperation(operation, ref numStreamOperations) : IsRawContentMapperCompatibleClientOperation(operation, ref numStreamOperations); if (!isCompatible) { areAllOperationsRawMapperCompatible = false; break; } } if (areAllOperationsRawMapperCompatible && numStreamOperations > 0) { encodingElement.ContentTypeMapper = RawContentTypeMapper.Instance; endpoint.Binding = customBinding; } }
internal static bool TryCreate(BindingElementCollection bindingElements, out Binding binding) { if (bindingElements == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements"); } binding = null; ContextBindingElement element = bindingElements.Find <ContextBindingElement>(); if ((element != null) && (element.ContextExchangeMechanism != ContextExchangeMechanism.HttpCookie)) { Binding binding2; BindingElementCollection elements = new BindingElementCollection(bindingElements); elements.Remove <ContextBindingElement>(); if (NetTcpBinding.TryCreate(elements, out binding2)) { NetTcpContextBinding binding3 = new NetTcpContextBinding((NetTcpBinding)binding2) { ContextProtectionLevel = element.ProtectionLevel, ContextManagementEnabled = element.ContextManagementEnabled }; binding = binding3; } } return(binding != null); }
/// <summary> /// Writes custom Web Services Description Language (WSDL) elements into the generated WSDL for an endpoint. /// </summary> /// <param name="exporter">The <see cref="T:System.ServiceModel.Description.WsdlExporter" /> that exports the endpoint information.</param> /// <param name="context">Provides mappings from exported WSDL elements to the endpoint description.</param> public void ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context) { BindingElementCollection bindingElements = context.Endpoint.Binding.CreateBindingElements(); MessageEncodingBindingElement encodingBindingElement = bindingElements.Find <MessageEncodingBindingElement>() ?? new TextMessageEncodingBindingElement(); if (context.WsdlPort != null) { AddAddressToWsdlPort(context.WsdlPort, context.Endpoint.Address, encodingBindingElement.MessageVersion.Addressing); } }
public Boolean initializeLogger(RightNowSyncPortClient client) { // Ask the client to not send the timestamp BindingElementCollection elements = client.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; client.Endpoint.Binding = new CustomBinding(elements); this.client = client; this.extObject = getExtension(); return(true); }
static bool BindingRequiresAuthentication(BindingElementCollection elements) { SecurityBindingElement element = elements.Find<SecurityBindingElement>(); if (element != null) { foreach (SecurityTokenParameters parameters in EnumerateNestedTokenParameters(element)) { if (parameters is SspiSecurityTokenParameters) return true; } } return false; }
public BindingElementCollection Extend(BindingElementCollection bindingElementCollection) { MessageEncodingBindingElement item = bindingElementCollection.Find<MessageEncodingBindingElement>(); if (item != null) { ConfigureFromMessageEncodingBindingElement(item); int index = bindingElementCollection.IndexOf(item); bindingElementCollection.RemoveAt(index); bindingElementCollection.Insert(index, this); return bindingElementCollection; } bindingElementCollection.Insert(0, this); return bindingElementCollection; }
internal static bool TryCreate(BindingElementCollection bindingElements, out Binding binding) { if (bindingElements == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements"); } binding = null; ContextBindingElement element = bindingElements.Find<ContextBindingElement>(); if ((element != null) && (element.ContextExchangeMechanism != ContextExchangeMechanism.HttpCookie)) { Binding binding2; BindingElementCollection elements = new BindingElementCollection(bindingElements); elements.Remove<ContextBindingElement>(); if (NetTcpBinding.TryCreate(elements, out binding2)) { NetTcpContextBinding binding3 = new NetTcpContextBinding((NetTcpBinding) binding2) { ContextProtectionLevel = element.ProtectionLevel, ContextManagementEnabled = element.ContextManagementEnabled }; binding = binding3; } } return (binding != null); }
static bool UsesTransactionFlowProperties(BindingElementCollection bindingElements, ContractDescription contract) { BindingElementCollection bindingElementCollection = new BindingElementCollection(bindingElements); TransactionFlowBindingElement txBE = bindingElementCollection.Find<TransactionFlowBindingElement>(); if (txBE == null) { return false; } return txBE.IsFlowEnabled(contract); }
static bool EndpointAllowsTransactionFlow(ServiceEndpoint endpoint, BindingElementCollection elements) { TransactionFlowBindingElement flow = elements.Find<TransactionFlowBindingElement>(); return flow != null && ContractAllowsTransactionFlow(endpoint.Contract); }
internal static new bool TryCreate(BindingElementCollection bindingElements, out Binding binding) { if (bindingElements == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements"); } binding = null; ContextBindingElement contextBindingElement = bindingElements.Find<ContextBindingElement>(); if (contextBindingElement != null) { BindingElementCollection bindingElementsWithoutContext = new BindingElementCollection(bindingElements); bindingElementsWithoutContext.Remove<ContextBindingElement>(); Binding wsHttpBinding; if (WSHttpBinding.TryCreate(bindingElementsWithoutContext, out wsHttpBinding)) { bool allowCookies = ((WSHttpBinding)wsHttpBinding).AllowCookies; if (allowCookies && contextBindingElement.ContextExchangeMechanism == ContextExchangeMechanism.HttpCookie || !allowCookies && contextBindingElement.ContextExchangeMechanism == ContextExchangeMechanism.ContextSoapHeader) { WSHttpContextBinding contextBinding = new WSHttpContextBinding((WSHttpBinding)wsHttpBinding); contextBinding.ContextProtectionLevel = contextBindingElement.ProtectionLevel; contextBinding.ContextManagementEnabled = contextBindingElement.ContextManagementEnabled; binding = contextBinding; } } } return binding != null; }
internal static bool TryCreate(BindingElementCollection bindingElements, out Binding binding) { if (bindingElements == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements"); } binding = null; ContextBindingElement element = bindingElements.Find<ContextBindingElement>(); if (element != null) { Binding binding2; BindingElementCollection elements = new BindingElementCollection(bindingElements); elements.Remove<ContextBindingElement>(); if (WSHttpBindingBase.TryCreate(elements, out binding2)) { bool allowCookies = ((WSHttpBinding) binding2).AllowCookies; if ((allowCookies && (element.ContextExchangeMechanism == ContextExchangeMechanism.HttpCookie)) || (!allowCookies && (element.ContextExchangeMechanism == ContextExchangeMechanism.ContextSoapHeader))) { WSHttpContextBinding binding3 = new WSHttpContextBinding((WSHttpBinding) binding2) { ContextProtectionLevel = element.ProtectionLevel, ContextManagementEnabled = element.ContextManagementEnabled }; binding = binding3; } } } return (binding != null); }
internal static new bool TryCreate(BindingElementCollection bindingElements, out Binding binding) { if (bindingElements == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements"); } binding = null; ContextBindingElement contextBindingElement = bindingElements.Find<ContextBindingElement>(); if (contextBindingElement != null && contextBindingElement.ContextExchangeMechanism != ContextExchangeMechanism.HttpCookie) { BindingElementCollection bindingElementsWithoutContext = new BindingElementCollection(bindingElements); bindingElementsWithoutContext.Remove<ContextBindingElement>(); Binding netTcpBinding; if (NetTcpBinding.TryCreate(bindingElementsWithoutContext, out netTcpBinding)) { NetTcpContextBinding contextBinding = new NetTcpContextBinding((NetTcpBinding)netTcpBinding); contextBinding.ContextProtectionLevel = contextBindingElement.ProtectionLevel; contextBinding.ContextManagementEnabled = contextBindingElement.ContextManagementEnabled; binding = contextBinding; } } return binding != null; }