protected virtual void ConfigureForServiceBus(string username, string password) { ClientCredentials.UserName.UserName = username; ClientCredentials.UserName.Password = password; ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerTrust; ServiceBusHelper.ConfigureBinding(Endpoint.Binding, false); }
public void Open() { if (State != CommunicationState.Created) { return; } try { Opening(this, EventArgs.Empty); ServiceBusHelper.ConfigureBinding(Binding, Anonymous); m_Proxies = new Dictionary <string, T>(); IServiceBusProperties properties = this; foreach (Uri uri in properties.Addresses) { EndpointIdentity identity = new DnsEndpointIdentity(m_ServiceCertFindValue.ToString()); EndpointAddress address = new EndpointAddress(uri, identity); ChannelFactory <T> factory = new ChannelFactory <T>(Binding, address); //Set credentials for message security (if needed) factory.Credentials.UserName.UserName = ServiceUsername; //could be null factory.Credentials.UserName.Password = ServicePassword; //could be null //Set service cert to secure message ClientCredentials behavior = factory.Endpoint.Behaviors.Find <ClientCredentials>(); behavior.ServiceCertificate.SetDefaultCertificate(m_ServiceCertLocation, m_ServiceCertStoreName, m_ServiceCertFindType, m_ServiceCertFindValue); //Set service bus creds if (properties.Credential == null) { if (m_Secret != null) { factory.SetServiceBusCredentials(m_Issuer, m_Secret); } } else { Debug.Assert(m_Secret == null); factory.Endpoint.Behaviors.Add(properties.Credential); } string methodName = uri.Segments[uri.Segments.Length - 1]; methodName = methodName.Replace("/", ""); m_Proxies[methodName] = factory.CreateChannel(); ICommunicationObject proxy = m_Proxies[methodName] as ICommunicationObject; proxy.Open(); } State = CommunicationState.Opened; Opened(this, EventArgs.Empty); } catch { State = CommunicationState.Faulted; } }
public void ConfigureAnonymousMessageSecurity(StoreLocation location, StoreName storeName, X509FindType findType, object findValue) { Credentials.ServiceCertificate.SetCertificate(location, storeName, findType, findValue); Authorization.PrincipalPermissionMode = PrincipalPermissionMode.None; foreach (ServiceEndpoint endpoint in Description.Endpoints) { ServiceBusHelper.ConfigureBinding(endpoint.Binding); } }
public void ConfigureMessageSecurity(StoreLocation location, StoreName storeName, X509FindType findType, object findValue, bool useProviders, string applicationName) { Credentials.ServiceCertificate.SetCertificate(location, storeName, findType, findValue); foreach (ServiceEndpoint endpoint in Description.Endpoints) { ServiceBusHelper.ConfigureBinding(endpoint.Binding, false); } if (useProviders) { Authorization.PrincipalPermissionMode = PrincipalPermissionMode.UseAspNetRoles; Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.MembershipProvider; SecurityBehavior.EnableRoleManager(); string application; if (String.IsNullOrEmpty(applicationName)) { applicationName = Membership.ApplicationName; } if (String.IsNullOrEmpty(applicationName) || applicationName == "/") { if (String.IsNullOrEmpty(Assembly.GetEntryAssembly().GetName().Name)) { application = AppDomain.CurrentDomain.FriendlyName; } else { application = Assembly.GetEntryAssembly().GetName().Name; } } else { application = applicationName; } Membership.ApplicationName = application; Roles.ApplicationName = application; } }
protected virtual void ConfigureForServiceBus() { Debug.Assert(Endpoint.Binding is NetTcpRelayBinding); ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerTrust; ServiceBusHelper.ConfigureBinding(Endpoint.Binding); }