Beispiel #1
0
 public override T GetProperty <T>(BindingContext context)
 {
     if (context == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
     }
     if (typeof(T) == typeof(ISecurityCapabilities))
     {
         ISecurityCapabilities lowerCapabilities = context.GetInnerProperty <ISecurityCapabilities>();
         if (lowerCapabilities != null)
         {
             // composite duplex cannot ensure that messages it receives are from the part it sends
             // messages to. So it cannot offer server auth
             return((T)(object)(new SecurityCapabilities(lowerCapabilities.SupportsClientAuthentication,
                                                         false, lowerCapabilities.SupportsClientWindowsIdentity, lowerCapabilities.SupportedRequestProtectionLevel,
                                                         System.Net.Security.ProtectionLevel.None)));
         }
         else
         {
             return(null);
         }
     }
     else if (typeof(T) == typeof(ChannelProtectionRequirements))
     {
         ChannelProtectionRequirements myRequirements = this.GetProtectionRequirements();
         myRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
         return((T)(object)myRequirements);
     }
     else
     {
         return(context.GetInnerProperty <T>());
     }
 }
        public override T GetProperty <T>(BindingContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            // make sure our Datagram header is signed
            if (typeof(T) == typeof(ChannelProtectionRequirements))
            {
                ChannelProtectionRequirements myRequirements = new ChannelProtectionRequirements();
                if (PacketRoutable)
                {
                    myRequirements.IncomingSignatureParts.AddParts(OneWaySignedMessageParts);
                    myRequirements.OutgoingSignatureParts.AddParts(OneWaySignedMessageParts);
                }
                ChannelProtectionRequirements innerRequirements = context.GetInnerProperty <ChannelProtectionRequirements>();
                if (innerRequirements != null)
                {
                    myRequirements.Add(innerRequirements);
                }
                return((T)(object)myRequirements);
            }
            else
            {
                return(context.GetInnerProperty <T>());
            }
        }
        public override T GetProperty <T>(BindingContext context) where T : class
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }
            if (!(typeof(T) == typeof(ChannelProtectionRequirements)))
            {
                return(context.GetInnerProperty <T>());
            }
            ChannelProtectionRequirements requirements = new ChannelProtectionRequirements();

            if (this.PacketRoutable)
            {
                requirements.IncomingSignatureParts.AddParts(OneWaySignedMessageParts);
                requirements.OutgoingSignatureParts.AddParts(OneWaySignedMessageParts);
            }
            ChannelProtectionRequirements innerProperty = context.GetInnerProperty <ChannelProtectionRequirements>();

            if (innerProperty != null)
            {
                requirements.Add(innerProperty);
            }
            return((T)requirements);
        }
Beispiel #4
0
        public override T GetProperty <T>(BindingContext context) where T : class
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }
            if (typeof(T) == typeof(ChannelProtectionRequirements))
            {
                ChannelProtectionRequirements protectionRequirements = this.GetProtectionRequirements(context);
                protectionRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
                return((T)protectionRequirements);
            }
            Collection <BindingElement> collection = context.BindingParameters.FindAll <BindingElement>();
            T individualProperty = default(T);

            for (int i = 0; i < collection.Count; i++)
            {
                individualProperty = collection[i].GetIndividualProperty <T>();
                if (individualProperty != new T())
                {
                    return(individualProperty);
                }
            }
            if (typeof(T) == typeof(MessageVersion))
            {
                return((T)TransportDefaults.GetDefaultMessageEncoderFactory().MessageVersion);
            }
            if (typeof(T) == typeof(XmlDictionaryReaderQuotas))
            {
                return((T) new XmlDictionaryReaderQuotas());
            }
            return(default(T));
        }
        public override T GetProperty <T>(BindingContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            if (typeof(T) == typeof(ChannelProtectionRequirements))
            {
                AddressingVersion addressing = MessageVersion.Default.Addressing;
#pragma warning disable 56506
                MessageEncodingBindingElement encoding = context.Binding.Elements.Find <MessageEncodingBindingElement>();
                if (encoding != null)
                {
                    addressing = encoding.MessageVersion.Addressing;
                }
                ChannelProtectionRequirements myRequirements = base.GetProtectionRequirements(addressing, ProtectionLevel.EncryptAndSign);
                myRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
                return((T)(object)myRequirements);
            }
            else
            {
                return(base.GetProperty <T>(context));
            }
        }
        public void AddToReadOnly()
        {
            ChannelProtectionRequirements r =
                new ChannelProtectionRequirements();

            r.MakeReadOnly();
            r.Add(new ChannelProtectionRequirements());
        }
        public override T GetProperty <T>(BindingContext context) where T : class
        {
            if (!(typeof(T) == typeof(ChannelProtectionRequirements)))
            {
                return(context.GetInnerProperty <T>());
            }
            ChannelProtectionRequirements protectionRequirements = this.GetProtectionRequirements();

            if (protectionRequirements == null)
            {
                return(context.GetInnerProperty <ChannelProtectionRequirements>());
            }
            protectionRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
            return((T)protectionRequirements);
        }
        public override T GetProperty <T>(BindingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (typeof(T) == typeof(ChannelProtectionRequirements))
            {
                ChannelProtectionRequirements myRequirements = this.GetProtectionRequirements();
                myRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
                return((T)(object)myRequirements);
            }

            return(context.GetInnerProperty <T>());
        }
Beispiel #9
0
        public override T GetProperty <T>(BindingContext context)
            where T : class
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (typeof(T) != typeof(ChannelProtectionRequirements))
            {
                return(base.GetProperty <T>(context));
            }
            ChannelProtectionRequirements protectionRequirements = RelayedOnewayTransportBindingElement.GetProtectionRequirements(context);

            protectionRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
            return((T)protectionRequirements);
        }
Beispiel #10
0
        public override T GetProperty <T>(BindingContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            if (typeof(T) == typeof(ChannelProtectionRequirements) && this.ProtectionLevel != ProtectionLevel.None)
            {
                ChannelProtectionRequirements innerRequirements = context.GetInnerProperty <ChannelProtectionRequirements>();
                if (innerRequirements == null)
                {
                    return((T)(object)ContextMessageHeader.GetChannelProtectionRequirements(this.ProtectionLevel));
                }
                else
                {
                    ChannelProtectionRequirements requirements = new ChannelProtectionRequirements(innerRequirements);
                    requirements.Add(ContextMessageHeader.GetChannelProtectionRequirements(this.ProtectionLevel));
                    return((T)(object)requirements);
                }
            }
            else if (typeof(T) == typeof(IContextSessionProvider))
            {
                return((T)(object)this);
            }
            else if (typeof(T) == typeof(IContextBindingElement))
            {
                return((T)(object)this);
            }
            else if (typeof(T) == typeof(ICorrelationDataSource))
            {
                ICorrelationDataSource correlationData = instanceCorrelationData;

                if (correlationData == null)
                {
                    ICorrelationDataSource innerCorrelationData = context.GetInnerProperty <ICorrelationDataSource>();
                    correlationData         = CorrelationDataSourceHelper.Combine(innerCorrelationData, ContextExchangeCorrelationDataDescription.DataSource);
                    instanceCorrelationData = correlationData;
                }

                return((T)(object)correlationData);
            }

            return(context.GetInnerProperty <T>());
        }
Beispiel #11
0
 public override T GetProperty <T>(BindingContext context) where T : class
 {
     if (context == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
     }
     if (typeof(T) == typeof(ChannelProtectionRequirements))
     {
         ChannelProtectionRequirements protectionRequirements = this.GetProtectionRequirements();
         protectionRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
         return((T)protectionRequirements);
     }
     if (typeof(T) == typeof(IBindingDeliveryCapabilities))
     {
         return((T) new BindingDeliveryCapabilitiesHelper(this, context.GetInnerProperty <IBindingDeliveryCapabilities>()));
     }
     return(context.GetInnerProperty <T>());
 }
 public override T GetProperty <T>(BindingContext context)
 {
     if (typeof(T) == typeof(ChannelProtectionRequirements))
     {
         ChannelProtectionRequirements myRequirements = this.GetProtectionRequirements();
         if (myRequirements != null)
         {
             myRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
             return((T)(object)myRequirements);
         }
         else
         {
             return((T)(object)context.GetInnerProperty <ChannelProtectionRequirements>());
         }
     }
     else
     {
         return(context.GetInnerProperty <T>());
     }
 }
        public override T GetProperty <T>(BindingContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            if (typeof(T) == typeof(ChannelProtectionRequirements))
            {
                ChannelProtectionRequirements myRequirements = this.GetProtectionRequirements(context);
                myRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
                return((T)(object)myRequirements);
            }

            // to cover all our bases, let's iterate through the BindingParameters to make sure
            // we haven't missed a query (since we're the Transport and we're at the bottom)
#pragma warning suppress 56506 // [....], BindingContext.BindingParameters cannot be null
            Collection <BindingElement> bindingElements = context.BindingParameters.FindAll <BindingElement>();

            T result = default(T);
            for (int i = 0; i < bindingElements.Count; i++)
            {
                result = bindingElements[i].GetIndividualProperty <T>();
                if (result != default(T))
                {
                    return(result);
                }
            }

            if (typeof(T) == typeof(MessageVersion))
            {
                return((T)(object)TransportDefaults.GetDefaultMessageEncoderFactory().MessageVersion);
            }

            if (typeof(T) == typeof(XmlDictionaryReaderQuotas))
            {
                return((T)(object)new XmlDictionaryReaderQuotas());
            }

            return(null);
        }
 public override T GetProperty <T>(BindingContext context)
 {
     if (context == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context));
     }
     if (typeof(T) == typeof(ChannelProtectionRequirements))
     {
         ChannelProtectionRequirements myRequirements = GetProtectionRequirements();
         myRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
         return((T)(object)myRequirements);
     }
     else if (typeof(T) == typeof(IBindingDeliveryCapabilities))
     {
         return((T)(object)new BindingDeliveryCapabilitiesHelper(this, context.GetInnerProperty <IBindingDeliveryCapabilities>()));
     }
     else
     {
         return(context.GetInnerProperty <T>());
     }
 }
        public override T GetProperty <T>(BindingContext context) where T : class
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }
            if (!(typeof(T) == typeof(ChannelProtectionRequirements)))
            {
                return(base.GetProperty <T>(context));
            }
            AddressingVersion             addressing = MessageVersion.Default.Addressing;
            MessageEncodingBindingElement element    = context.Binding.Elements.Find <MessageEncodingBindingElement>();

            if (element != null)
            {
                addressing = element.MessageVersion.Addressing;
            }
            ChannelProtectionRequirements protectionRequirements = base.GetProtectionRequirements(addressing, ProtectionLevel.EncryptAndSign);

            protectionRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
            return((T)protectionRequirements);
        }
Beispiel #16
0
        public override T GetProperty <T>(BindingContext context) where T : class
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }
            if ((typeof(T) == typeof(ChannelProtectionRequirements)) && (this.ProtectionLevel != System.Net.Security.ProtectionLevel.None))
            {
                ChannelProtectionRequirements innerProperty = context.GetInnerProperty <ChannelProtectionRequirements>();
                if (innerProperty == null)
                {
                    return((T)ContextMessageHeader.GetChannelProtectionRequirements(this.ProtectionLevel));
                }
                ChannelProtectionRequirements requirements2 = new ChannelProtectionRequirements(innerProperty);
                requirements2.Add(ContextMessageHeader.GetChannelProtectionRequirements(this.ProtectionLevel));
                return((T)requirements2);
            }
            if (typeof(T) == typeof(IContextSessionProvider))
            {
                return((T)this);
            }
            if (typeof(T) == typeof(IContextBindingElement))
            {
                return((T)this);
            }
            if (!(typeof(T) == typeof(ICorrelationDataSource)))
            {
                return(context.GetInnerProperty <T>());
            }
            ICorrelationDataSource instanceCorrelationData = this.instanceCorrelationData;

            if (instanceCorrelationData == null)
            {
                instanceCorrelationData      = CorrelationDataSourceHelper.Combine(context.GetInnerProperty <ICorrelationDataSource>(), ContextExchangeCorrelationDataDescription.DataSource);
                this.instanceCorrelationData = instanceCorrelationData;
            }
            return((T)instanceCorrelationData);
        }
Beispiel #17
0
        public override T GetProperty <T>(BindingContext context) where T : class
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }
            if (typeof(T) == typeof(ISecurityCapabilities))
            {
                ISecurityCapabilities innerProperty = context.GetInnerProperty <ISecurityCapabilities>();
                if (innerProperty != null)
                {
                    return((T) new SecurityCapabilities(innerProperty.SupportsClientAuthentication, false, innerProperty.SupportsClientWindowsIdentity, innerProperty.SupportedRequestProtectionLevel, ProtectionLevel.None));
                }
                return(default(T));
            }
            if (!(typeof(T) == typeof(ChannelProtectionRequirements)))
            {
                return(context.GetInnerProperty <T>());
            }
            ChannelProtectionRequirements protectionRequirements = this.GetProtectionRequirements();

            protectionRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
            return((T)protectionRequirements);
        }
        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);
        }