/** * The execution of this behavior comes rather late. * Anyone that inspects the service description in the meantime, * such as for metadata generation, won't see the protection level that we want to use. * * One way of doing it is at when create HostFactory * * ServiceEndpoint endpoint = host.Description.Endpoints.Find(typeof(IService)); * OperationDescription operation = endpoint.Contract.Operations.Find("Action"); * MessageDescription message = operation.Messages.Find("http://tempuri.org/IService/ActionResponse"); * MessageHeaderDescription header = message.Headers[new XmlQualifiedName("aheader", "http://tempuri.org/")]; * header.ProtectionLevel = ProtectionLevel.Sign; * * **/ public void AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) { ChannelProtectionRequirements requirements = bindingParameters.Find<ChannelProtectionRequirements>(); XmlQualifiedName qName = new XmlQualifiedName(header, ns); MessagePartSpecification part = new MessagePartSpecification(qName); requirements.OutgoingSignatureParts.AddParts(part, action); }
public void AddBindingParameters(OperationDescription description, BindingParameterCollection parameters) { //see if ChunkingBindingParameter already exists ChunkingBindingParameter param = parameters.Find<ChunkingBindingParameter>(); if (param == null) { param = new ChunkingBindingParameter(); parameters.Add(param); } if ((appliesTo & ChunkingAppliesTo.InMessage) == ChunkingAppliesTo.InMessage) { //add input message's action to ChunkingBindingParameter param.AddAction(description.Messages[0].Action); } if (!description.IsOneWay && ((appliesTo & ChunkingAppliesTo.OutMessage) == ChunkingAppliesTo.OutMessage)) { //add output message's action to ChunkingBindingParameter param.AddAction(description.Messages[1].Action); } }
/// <summary> /// Adds the binding parameters. /// </summary> /// <param name="serviceEndpoint">The service endpoint.</param> /// <param name="parameters">The parameters.</param> void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } ServiceDebugBehavior debugBehavior = parameters.Find<ServiceDebugBehavior>(); if (debugBehavior == null && this.serviceDebugBehavior != null) { parameters.Add(this.serviceDebugBehavior); } DispatcherSynchronizationBehavior synchronizationBehavior = parameters.Find<DispatcherSynchronizationBehavior>(); if (synchronizationBehavior == null && this.dispatcherSynchronizationBehavior != null) { parameters.Add(this.dispatcherSynchronizationBehavior); } }
private static Dictionary<DirectionalAction, TransactionFlowOption> EnsureDictionary(BindingParameterCollection parameters) { Dictionary<DirectionalAction, TransactionFlowOption> dictionary = parameters.Find<Dictionary<DirectionalAction, TransactionFlowOption>>(); if (dictionary == null) { dictionary = new Dictionary<DirectionalAction, TransactionFlowOption> { dictionary }; } return dictionary; }
public static bool TryExtract(BindingParameterCollection collection, out AuthenticationSchemes authenticationSchemes) { Fx.Assert(collection != null, "collection != null"); authenticationSchemes = AuthenticationSchemes.None; AuthenticationSchemesBindingParameter instance = collection.Find<AuthenticationSchemesBindingParameter>(); if (instance != null) { authenticationSchemes = instance.AuthenticationSchemes; return true; } return false; }
public static bool TryExtract(BindingParameterCollection collection, out AuthenticationSchemes authenticationSchemes) { Fx.Assert(collection != null, "collection != null"); authenticationSchemes = AuthenticationSchemes.None; AuthenticationSchemesBindingParameter instance = collection.Find <AuthenticationSchemesBindingParameter>(); if (instance != null) { authenticationSchemes = instance.AuthenticationSchemes; return(true); } return(false); }
internal static T GetValue <T>(BindingParameterCollection bindingParameters, string name, T defaultValue) { if (bindingParameters == null || bindingParameters.Count == 0) { return(defaultValue); } IDictionary <string, object> endpointSettings = bindingParameters.Find <IDictionary <string, object> >(); object setting; if (endpointSettings == null || !endpointSettings.TryGetValue(name, out setting) || !(setting is T)) { return(defaultValue); } return((T)setting); }
public void AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) { var requirements = bindingParameters.Find<ChannelProtectionRequirements>(); requirements.IncomingSignatureParts.ChannelParts.HeaderTypes.Add(new XmlQualifiedName(_name, _ns)); requirements.IncomingEncryptionParts.ChannelParts.HeaderTypes.Add(new XmlQualifiedName(_name, _ns)); }
void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection parameters) { if (parameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters"); } ServiceDebugBehavior param = parameters.Find<ServiceDebugBehavior>(); if (param == null) { parameters.Add(this); } }
void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection parameters) { if (parameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters"); } if (this.serviceAuthenticationManager != null) { // throw if bindingParameters already has a AuthenticationManager ServiceAuthenticationManager otherAuthenticationManager = parameters.Find<ServiceAuthenticationManager>(); if (otherAuthenticationManager != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MultipleAuthenticationManagersInServiceBindingParameters, otherAuthenticationManager))); } parameters.Add(this.serviceAuthenticationManager); } if (this.authenticationSchemes != AuthenticationSchemes.None) { // throw if bindingParameters already has an AuthenticationSchemes AuthenticationSchemesBindingParameter otherAuthenticationSchemesBindingParameter = parameters.Find<AuthenticationSchemesBindingParameter>(); if (otherAuthenticationSchemesBindingParameter != null) { if (otherAuthenticationSchemesBindingParameter.AuthenticationSchemes != authenticationSchemes) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MultipleAuthenticationSchemesInServiceBindingParameters, otherAuthenticationSchemesBindingParameter.AuthenticationSchemes))); } } else { parameters.Add(new AuthenticationSchemesBindingParameter(this.authenticationSchemes)); } } }
public void AddBindingParameters(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, isForClient)); } else { requirements.Add(ChannelProtectionRequirements.CreateFromContract(endpoint.Contract, isc, isForClient)); } } }
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection parameters) { ISecurityCapabilities bindingElement = null; BindingElementCollection elements = endpoint.Binding.CreateBindingElements(); for (int i = 0; i < elements.Count; i++) { if (!(elements[i] is ITransportTokenAssertionProvider)) { ISecurityCapabilities individualProperty = elements[i].GetIndividualProperty<ISecurityCapabilities>(); if (individualProperty != null) { bindingElement = individualProperty; break; } } } if (bindingElement != null) { ChannelProtectionRequirements item = parameters.Find<ChannelProtectionRequirements>(); if (item == null) { item = new ChannelProtectionRequirements(); parameters.Add(item); } MessageEncodingBindingElement element = elements.Find<MessageEncodingBindingElement>(); if ((element != null) && (element.MessageVersion.Addressing == AddressingVersion.None)) { item.Add(ChannelProtectionRequirements.CreateFromContractAndUnionResponseProtectionRequirements(endpoint.Contract, bindingElement, this.isForClient)); } else { item.Add(ChannelProtectionRequirements.CreateFromContract(endpoint.Contract, bindingElement, this.isForClient)); } } }
void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection bindingParameters) { if (bindingParameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingParameters"); } SecurityCredentialsManager manager = bindingParameters.Find<SecurityCredentialsManager>(); if (manager != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MultipleSecurityCredentialsManagersInChannelBindingParameters", new object[] { manager }))); } bindingParameters.Add(this); }
void IServiceBehavior.AddBindingParameters(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection parameters) { if (parameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters"); } SecurityCredentialsManager manager = parameters.Find<SecurityCredentialsManager>(); if (manager != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MultipleSecurityCredentialsManagersInServiceBindingParameters", new object[] { manager }))); } parameters.Add(this); }
void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection parameters) { if (parameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters"); } // throw if bindingParameters already has a SecurityCredentialsManager SecurityCredentialsManager otherCredentialsManager = parameters.Find<SecurityCredentialsManager>(); if (otherCredentialsManager != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MultipleSecurityCredentialsManagersInServiceBindingParameters, otherCredentialsManager))); } parameters.Add(this); }
void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection bindingParameters) { if (bindingParameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingParameters"); } // throw if bindingParameters already has a SecurityCredentialsManager SecurityCredentialsManager otherCredentialsManager = bindingParameters.Find<SecurityCredentialsManager>(); if (otherCredentialsManager != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.MultipleSecurityCredentialsManagersInChannelBindingParameters, otherCredentialsManager))); } bindingParameters.Add(this); }
internal virtual bool IsMetadataListener(BindingParameterCollection bindingParameters) { return bindingParameters.Find<ServiceMetadataExtension.MetadataBindingParameter>() != null; }
internal override void AddMetadataBindingParameters(Uri listenUri, KeyedByTypeCollection<IServiceBehavior> serviceBehaviors, BindingParameterCollection bindingParameters) { if (serviceBehaviors.Find<HostedBindingBehavior>() != null) { bindingParameters.Add(new HostedMetadataBindingParameter()); } VirtualPathExtension virtualPathExtension = bindingParameters.Find<VirtualPathExtension>(); if (virtualPathExtension != null) { AuthenticationSchemes hostSupportedAuthenticationSchemes = AspNetEnvironment.Current.GetAuthenticationSchemes(listenUri); if (hostSupportedAuthenticationSchemes != AuthenticationSchemes.None) { if (bindingParameters.Find<AuthenticationSchemesBindingParameter>() == null) { bindingParameters.Add(new AuthenticationSchemesBindingParameter(hostSupportedAuthenticationSchemes)); } } } base.AddMetadataBindingParameters(listenUri, serviceBehaviors, bindingParameters); }
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)); } } }
internal override bool IsMetadataListener(BindingParameterCollection bindingParameters) { return base.IsMetadataListener(bindingParameters) || bindingParameters.Find<HostedMetadataBindingParameter>() != null; }