internal static void DemandClientConnectionPermissions(ServiceEndpoint endpoint) { PermissionSet connectionSet = new PermissionSet(PermissionState.None); if (endpoint.Binding is NetTcpBinding) { connectionSet.AddPermission(new SocketPermission(NetworkAccess.Connect, TransportType.Tcp, endpoint.Address.Uri.Host, endpoint.Address.Uri.Port)); connectionSet.AddPermission(new DnsPermission(PermissionState.Unrestricted)); } if (endpoint.Binding is WebHttpBinding || endpoint.Binding is WSHttpBinding || endpoint.Binding is BasicHttpBinding || endpoint.Binding is WSDualHttpBinding) { connectionSet.AddPermission(new WebPermission(NetworkAccess.Connect, endpoint.Address.Uri.AbsoluteUri)); } //On the client, demand hosting permission for duplex over HTTP if (endpoint.Binding is WSDualHttpBinding) { connectionSet.AddPermission(new AspNetHostingPermission(AspNetHostingPermissionLevel.Minimal)); WSDualHttpBinding binding = endpoint.Binding as WSDualHttpBinding; Uri callbackUri = binding.ClientBaseAddress ?? new Uri("http://localhost:80/"); connectionSet.AddPermission(new WebPermission(NetworkAccess.Accept, callbackUri.AbsoluteUri)); } if (endpoint.Binding is NetMsmqBinding) { string path = QueuedServiceHelper.GetQueueFromUri(endpoint.Address.Uri); connectionSet.AddPermission(new MessageQueuePermission(MessageQueuePermissionAccess.Send, path)); } connectionSet.Demand(); }
void PurgeQueues() { foreach (ServiceEndpoint endpoint in Description.Endpoints) { QueuedServiceHelper.PurgeQueue(endpoint); } }
protected override void OnOpening() { foreach (IServiceBehavior behavior in m_ErrorHandlers) { Description.Behaviors.Add(behavior); } foreach (ServiceEndpoint endpoint in Description.Endpoints) { QueuedServiceHelper.VerifyQueue(endpoint); } base.OnOpening(); }
public ResponseScope(NetMsmqBinding binding) { ResponseContext responseContext = ResponseContext.Current; Debug.Assert(responseContext != null); EndpointAddress address = new EndpointAddress(responseContext.ResponseAddress); ChannelFactory <T> factory = new ChannelFactory <T>(binding, address); QueuedServiceHelper.VerifyQueue(factory.Endpoint); Response = factory.CreateChannel(); //Switching context now m_Scope = new OperationContextScope(Response as IContextChannel); ResponseContext.Current = responseContext; }
internal static void DemandHostConnectionPermissions(ServiceEndpoint endpoint) { PermissionSet connectionSet = new PermissionSet(PermissionState.None); if (endpoint.Binding is NetTcpBinding) { connectionSet.AddPermission(new SocketPermission(NetworkAccess.Accept, TransportType.Tcp, endpoint.Address.Uri.Host, endpoint.Address.Uri.Port)); } if (endpoint.Binding is WebHttpBinding || endpoint.Binding is WSHttpBinding || endpoint.Binding is BasicHttpBinding || endpoint.Binding is WSDualHttpBinding) { connectionSet.AddPermission(new WebPermission(NetworkAccess.Accept, endpoint.Address.Uri.AbsoluteUri)); } if (endpoint.Binding is NetMsmqBinding) { string path = QueuedServiceHelper.GetQueueFromUri(endpoint.Address.Uri); connectionSet.AddPermission(new MessageQueuePermission(MessageQueuePermissionAccess.Receive, path)); } connectionSet.Demand(); }
public ResponseClientBase(string responseAddress, NetMsmqBinding binding, EndpointAddress remoteAddress) : base(binding, remoteAddress) { ResponseAddress = responseAddress; QueuedServiceHelper.VerifyQueue(Endpoint); }
public ResponseClientBase(string responseAddress, string endpointName, EndpointAddress remoteAddress) : base(endpointName, remoteAddress) { ResponseAddress = responseAddress; QueuedServiceHelper.VerifyQueue(Endpoint); Debug.Assert(Endpoint.Binding is NetMsmqBinding); }