예제 #1
0
        void CommonConstruct(Uri[] bufferAddresses)
        {
            Debug.Assert(bufferAddresses != null);
            Debug.Assert(bufferAddresses.Length >= 1, "You must specify at least one buffer's address");

            m_BufferAddresses = bufferAddresses;

            string serviceNamespace = ServiceBusHelper.ExtractNamespace(m_BufferAddresses[0]);

            //Sanity check - should all use same service namespace
            foreach (Uri baseAddress in m_BufferAddresses)
            {
                Debug.Assert(serviceNamespace == ServiceBusHelper.ExtractNamespace(baseAddress));
                Debug.Assert(baseAddress.Scheme == "https");
            }

            m_Credential = new TransportClientEndpointBehavior();

            InitializeHost();
        }
예제 #2
0
        public EventsHost(Type serviceType, string[] baseAddresses)
        {
            Hosts = new Dictionary <Type, Dictionary <string, ServiceBusHost> >();

            Debug.Assert(baseAddresses != null);
            Debug.Assert(baseAddresses.Length > 0);

            m_SericeType = serviceType;

            for (int index = 0; index < baseAddresses.Length; index++)
            {
                if (baseAddresses[index].EndsWith("/") == false)
                {
                    baseAddresses[index] += "/";
                }
            }
            BaseAddresses = baseAddresses;

            //Try to guess a certificate
            ConfigureAnonymousMessageSecurity(ServiceBusHelper.ExtractNamespace(new Uri(baseAddresses[0])));
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
        protected override T CreateChannel()
        {
            Debug.Assert(Endpoint.Binding is NetMessagingBinding);

            bool requiresSession;

            if (SessionId == null)
            {
                requiresSession = false;
            }
            else
            {
                requiresSession = true;
            }
            IServiceBusProperties properties = this as IServiceBusProperties;
            Tuple <Uri, string>   tuple      = ServiceBusHelper.ParseUri(Endpoint.Address.Uri);

            ServiceBusHelper.VerifyQueue(tuple.Item1, tuple.Item2, properties.Credential.TokenProvider, requiresSession);

            this.AddGenericResolver();
            return(base.CreateChannel());
        }
예제 #5
0
        void InitializeHost()
        {
            Debug.Assert(Description.Endpoints.Count == 0, "Please do not include endpoints in config. Instead, provide buffer addresses to the constructor");

            Binding binding = new NetNamedPipeBinding();

            binding.SendTimeout = TimeSpan.MaxValue;

            Type[] interfaces = typeof(T).GetInterfaces();
            Debug.Assert(interfaces.Length > 0);

            foreach (Type interfaceType in interfaces)
            {
                if (interfaceType.GetCustomAttributes(typeof(ServiceContractAttribute), false).Length == 1)
                {
                    ServiceBusHelper.VerifyOneway(interfaceType);
                    string address = @"net.pipe://localhost/" + Guid.NewGuid();
                    AddServiceEndpoint(interfaceType, binding, address);
                }
            }
            m_Factory = binding.BuildChannelFactory <IDuplexSessionChannel>();
            m_Factory.Open();
        }
예제 #6
0
 protected virtual void ConfigureForServiceBus()
 {
     Debug.Assert(Endpoint.Binding is NetTcpRelayBinding);
     ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerTrust;
     ServiceBusHelper.ConfigureBinding(Endpoint.Binding);
 }
예제 #7
0
 static BufferedServiceBusClient()
 {
     ServiceBusHelper.VerifyOneway(typeof(T));
 }
예제 #8
0
 static BufferedServiceBusChannelFactory()
 {
     ServiceBusHelper.VerifyOneway(typeof(T));
 }