public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection parameters)
            {
                // get Contract info security needs, and put in BindingParameterCollection
                ISecurityCapabilities    isc      = null;
                BindingElementCollection elements = endpoint.Binding.CreateBindingElements();

                if (isc != null)
                {
                    // ensure existence of binding parameter
                    ChannelProtectionRequirements requirements = parameters.Find <ChannelProtectionRequirements>();
                    if (requirements == null)
                    {
                        requirements = new ChannelProtectionRequirements();
                        parameters.Add(requirements);
                    }

                    MessageEncodingBindingElement encoding = elements.Find <MessageEncodingBindingElement>();
                    // use endpoint.Binding.Version
                    if (encoding != null && encoding.MessageVersion.Addressing == AddressingVersion.None)
                    {
                        // This binding does not support response actions, so...
                        requirements.Add(ChannelProtectionRequirements.CreateFromContractAndUnionResponseProtectionRequirements(endpoint.Contract, isc, _isForClient));
                    }
                    else
                    {
                        requirements.Add(ChannelProtectionRequirements.CreateFromContract(endpoint.Contract, isc, _isForClient));
                    }
                }
            }
Exemple #2
0
        BindingParameterCollection CreateBindingParameters()
        {
            BindingParameterCollection pl =
                new BindingParameterCollection();

            ContractDescription cd = Endpoint.Contract;

#if !NET_2_1
            pl.Add(ChannelProtectionRequirements.CreateFromContract(cd));

            foreach (IEndpointBehavior behavior in Endpoint.Behaviors)
            {
                behavior.AddBindingParameters(Endpoint, pl);
            }
#endif

            return(pl);
        }
Exemple #3
0
        private void AddBindingParameters(BindingParameterCollection commonParams, ServiceEndpoint endPoint)
        {
            commonParams.Add(ChannelProtectionRequirements.CreateFromContract(endPoint.Contract));

            foreach (IContractBehavior b in endPoint.Contract.Behaviors)
            {
                b.AddBindingParameters(endPoint.Contract, endPoint, commonParams);
            }
            foreach (IEndpointBehavior b in endPoint.Behaviors)
            {
                b.AddBindingParameters(endPoint, commonParams);
            }
            foreach (OperationDescription operation in endPoint.Contract.Operations)
            {
                foreach (IOperationBehavior b in operation.Behaviors)
                {
                    b.AddBindingParameters(operation, commonParams);
                }
            }
        }
Exemple #4
0
        public static void AddBindingParametersForSecurityContractInformation(ServiceEndpoint endpoint, BindingParameterCollection parameters)
        {
            // get Contract info security needs, and put in BindingParameterCollection
            ISecurityCapabilities    isc      = null;
            BindingElementCollection elements = endpoint.Binding.CreateBindingElements();

            for (int i = 0; i < elements.Count; ++i)
            {
                if (!(elements[i] is ITransportTokenAssertionProvider))
                {
                    ISecurityCapabilities tmp = elements[i].GetIndividualProperty <ISecurityCapabilities>();
                    if (tmp != null)
                    {
                        isc = tmp;
                        break;
                    }
                }
            }
            if (isc != null)
            {
                // ensure existence of binding parameter
                ChannelProtectionRequirements requirements = parameters.Find <ChannelProtectionRequirements>();
                if (requirements == null)
                {
                    requirements = new ChannelProtectionRequirements();
                    parameters.Add(requirements);
                }

                MessageEncodingBindingElement encoding = elements.Find <MessageEncodingBindingElement>();
                // use endpoint.Binding.Version
                if (encoding != null && encoding.MessageVersion.Addressing == AddressingVersion.None)
                {
                    // This binding does not support response actions, so...
                    requirements.Add(ChannelProtectionRequirements.CreateFromContractAndUnionResponseProtectionRequirements(endpoint.Contract, isc));
                }
                else
                {
                    requirements.Add(ChannelProtectionRequirements.CreateFromContract(endpoint.Contract, isc));
                }
            }
        }
        private void CreateWorkflowManagementEndpoint(WorkflowServiceHost workflowServiceHost)
        {
            Binding          namedPipeControlEndpointBinding;
            IChannelListener listener;

            if (workflowServiceHost.InternalBaseAddresses.Contains(Uri.UriSchemeNetPipe))
            {
                namedPipeControlEndpointBinding = NamedPipeControlEndpointBinding;
            }
            else if (workflowServiceHost.InternalBaseAddresses.Contains(Uri.UriSchemeHttp))
            {
                namedPipeControlEndpointBinding = HttpControlEndpointBinding;
            }
            else
            {
                return;
            }
            Uri listenUriBaseAddress        = ServiceHostBase.GetVia(namedPipeControlEndpointBinding.Scheme, new Uri("System.ServiceModel.Activities_IWorkflowInstanceManagement", UriKind.Relative), workflowServiceHost.InternalBaseAddresses);
            XmlQualifiedName   contractName = new XmlQualifiedName("IWorkflowInstanceManagement", "http://schemas.datacontract.org/2008/10/WorkflowServices");
            EndpointAddress    address      = new EndpointAddress(listenUriBaseAddress.AbsoluteUri);
            EndpointDispatcher item         = new EndpointDispatcher(address, "IWorkflowInstanceManagement", "http://schemas.datacontract.org/2008/10/WorkflowServices", true)
            {
                ContractFilter = new ActionMessageFilter(new string[] { NamingHelper.GetMessageAction(contractName, "Abandon", null, false), NamingHelper.GetMessageAction(contractName, "Cancel", null, false), NamingHelper.GetMessageAction(contractName, "Run", null, false), NamingHelper.GetMessageAction(contractName, "Suspend", null, false), NamingHelper.GetMessageAction(contractName, "Terminate", null, false), NamingHelper.GetMessageAction(contractName, "TransactedCancel", null, false), NamingHelper.GetMessageAction(contractName, "TransactedRun", null, false), NamingHelper.GetMessageAction(contractName, "TransactedSuspend", null, false), NamingHelper.GetMessageAction(contractName, "TransactedTerminate", null, false), NamingHelper.GetMessageAction(contractName, "TransactedUnsuspend", null, false), NamingHelper.GetMessageAction(contractName, "Unsuspend", null, false) })
            };
            BindingParameterCollection parameters = new BindingParameterCollection();
            VirtualPathExtension       extension  = workflowServiceHost.Extensions.Find <VirtualPathExtension>();

            if (extension != null)
            {
                parameters.Add(extension);
            }
            ChannelProtectionRequirements requirements = new ChannelProtectionRequirements();

            requirements.Add(ChannelProtectionRequirements.CreateFromContract(WorkflowControlEndpoint.WorkflowControlServiceContract, ProtectionLevel.EncryptAndSign, ProtectionLevel.EncryptAndSign, false));
            parameters.Add(requirements);
            if (namedPipeControlEndpointBinding.CanBuildChannelListener <IDuplexSessionChannel>(new object[] { listenUriBaseAddress, parameters }))
            {
                listener = namedPipeControlEndpointBinding.BuildChannelListener <IDuplexSessionChannel>(listenUriBaseAddress, parameters);
            }
            else if (namedPipeControlEndpointBinding.CanBuildChannelListener <IReplySessionChannel>(new object[] { listenUriBaseAddress, parameters }))
            {
                listener = namedPipeControlEndpointBinding.BuildChannelListener <IReplySessionChannel>(listenUriBaseAddress, parameters);
            }
            else
            {
                listener = namedPipeControlEndpointBinding.BuildChannelListener <IReplyChannel>(listenUriBaseAddress, parameters);
            }
            foreach (OperationDescription description in WorkflowControlEndpoint.WorkflowControlServiceContract.Operations)
            {
                bool flag;
                bool flag2;
                DataContractSerializerOperationBehavior behavior = new DataContractSerializerOperationBehavior(description);
                DispatchOperation operation = new DispatchOperation(item.DispatchRuntime, description.Name, NamingHelper.GetMessageAction(description, false), NamingHelper.GetMessageAction(description, true))
                {
                    Formatter = (IDispatchMessageFormatter)behavior.GetFormatter(description, out flag, out flag2, false),
                    Invoker   = new ControlOperationInvoker(description, new WorkflowControlEndpoint(namedPipeControlEndpointBinding, address), null, workflowServiceHost)
                };
                item.DispatchRuntime.Operations.Add(operation);
                OperationBehaviorAttribute attribute = description.Behaviors.Find <OperationBehaviorAttribute>();
                ((IOperationBehavior)attribute).ApplyDispatchBehavior(description, operation);
                if (attribute.TransactionScopeRequired)
                {
                    ((ITransactionChannelManager)listener).Dictionary.Add(new DirectionalAction(MessageDirection.Input, NamingHelper.GetMessageAction(description, false)), TransactionFlowOption.Allowed);
                }
            }
            DispatchRuntime dispatchRuntime = item.DispatchRuntime;

            dispatchRuntime.ConcurrencyMode             = ConcurrencyMode.Multiple;
            dispatchRuntime.InstanceContextProvider     = new DurableInstanceContextProvider(workflowServiceHost);
            dispatchRuntime.InstanceProvider            = new DurableInstanceProvider(workflowServiceHost);
            dispatchRuntime.ServiceAuthorizationManager = new WindowsAuthorizationManager(this.WindowsGroup);
            ServiceDebugBehavior     behavior2  = workflowServiceHost.Description.Behaviors.Find <ServiceDebugBehavior>();
            ServiceBehaviorAttribute attribute2 = workflowServiceHost.Description.Behaviors.Find <ServiceBehaviorAttribute>();
            bool flag3 = false;

            if (behavior2 != null)
            {
                flag3 |= behavior2.IncludeExceptionDetailInFaults;
            }
            if (attribute2 != null)
            {
                flag3 |= attribute2.IncludeExceptionDetailInFaults;
            }
            ChannelDispatcher dispatcher4 = new ChannelDispatcher(listener, namedPipeControlEndpointBinding.Name, namedPipeControlEndpointBinding)
            {
                MessageVersion = namedPipeControlEndpointBinding.MessageVersion
            };

            dispatcher4.Endpoints.Add(item);
            dispatcher4.ServiceThrottle = workflowServiceHost.ServiceThrottle;
            ChannelDispatcher dispatcher2 = dispatcher4;

            workflowServiceHost.ChannelDispatchers.Add(dispatcher2);
        }