コード例 #1
0
        /// <summary>
        /// Creates client.
        /// </summary>
        void CreateClient()
        {
            Data.DeviceEnvironment info = Controllers.ContextController.GetDeviceEnvironment();

            EndpointController controller = new EndpointController(new EndpointAddress(_serviceAddress));

            CredentialsProvider credentialsProvider = new CredentialsProvider();

            credentialsProvider.Username = info.Credentials.UserName;
            credentialsProvider.Password = info.Credentials.Password;

            Binding binding = new HttpBinding(new IChannelController[] { this, controller, credentialsProvider });

            _client = CreateClient(binding, new EndpointAddress(_serviceAddress));
            System.Net.ServicePointManager.Expect100Continue = false;

            SecurityBehavior securityBehavior = new SecurityBehavior();

            securityBehavior.UserName        = info.Credentials.UserName;
            securityBehavior.Password        = info.Credentials.Password;
            securityBehavior.UseUTCTimestamp = info.Credentials.UseUTCTimeStamp;
            _client.Endpoint.Behaviors.Add(securityBehavior);

            _client.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 0, 0, _messageTimeout);
        }
コード例 #2
0
 /// <summary>
 /// Adds security behaviour to the proxy-class.
 /// </summary>
 /// <param name="endpoint"></param>
 protected void AddSecurityBehaviour(ServiceEndpoint endpoint)
 {
     if (!string.IsNullOrEmpty(_username) && !string.IsNullOrEmpty(_password))
     {
         SecurityBehavior securityBehavior = new SecurityBehavior();
         securityBehavior.CredentialsProvider = _credentialsProvider;
         endpoint.Behaviors.Add(securityBehavior);
     }
 }
コード例 #3
0
 /// <summary>
 /// Adds SecurityBehavior to endpoint.
 /// </summary>
 /// <param name="endpoint">Endpoint.</param>
 public void AttachSecurity(System.ServiceModel.Description.ServiceEndpoint endpoint)
 {
     if (!string.IsNullOrEmpty(_username) && !string.IsNullOrEmpty(_password))
     {
         SecurityBehavior securityBehavior = new SecurityBehavior();
         securityBehavior.CredentialsProvider = _credentialsProvider;
         endpoint.Behaviors.Add(securityBehavior);
     }
 }
コード例 #4
0
 /// <summary>
 /// Adds security behaviour to the proxy-class.
 /// </summary>
 /// <param name="endpoint"></param>
 protected void AddSecurityBehaviour(ServiceEndpoint endpoint)
 {
     if (!string.IsNullOrEmpty(_username) && !string.IsNullOrEmpty(_password))
     {
         SecurityBehavior securityBehavior = new SecurityBehavior();
         securityBehavior.UserName        = _username;
         securityBehavior.Password        = _password;
         securityBehavior.UseUTCTimestamp = _useUTCTimestamp;
         endpoint.Behaviors.Add(securityBehavior);
     }
 }
コード例 #5
0
 /// <summary>
 /// Adds SecurityBehavior to endpoint.
 /// </summary>
 /// <param name="endpoint">Endpoint.</param>
 protected void AttachSecurity(System.ServiceModel.Description.ServiceEndpoint endpoint)
 {
     if (!string.IsNullOrEmpty(_username) && !string.IsNullOrEmpty(_password))
     {
         SecurityBehavior securityBehavior = new SecurityBehavior();
         securityBehavior.UserName        = _username;
         securityBehavior.Password        = _password;
         securityBehavior.UseUTCTimestamp = _useUTCTimestamp;
         endpoint.Behaviors.Add(securityBehavior);
     }
 }
コード例 #6
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;
            }
        }