public void Configure(WebServicesClientProtocol proxy)
        {
            // configure proxy URL
            if (!String.IsNullOrEmpty(serverUrl))
            {
                if (serverUrl.EndsWith("/"))
                {
                    serverUrl = serverUrl.Substring(0, serverUrl.Length - 1);
                }

                proxy.Url = serverUrl + proxy.Url.Substring(proxy.Url.LastIndexOf('/'));
            }

            // set proxy timeout
            proxy.Timeout = (timeout == -1) ? System.Threading.Timeout.Infinite : timeout * 1000;

            // setup security assertion
            if (!String.IsNullOrEmpty(serverPassword))
            {
                ServerUsernameAssertion assert
                    = new ServerUsernameAssertion(ServerSettings.ServerId, serverPassword);

                // create policy
                Policy policy = new Policy();
                policy.Assertions.Add(assert);

                proxy.SetPolicy(policy);
            }

            // provider settings
            ServiceProviderSettingsSoapHeader settingsHeader = new ServiceProviderSettingsSoapHeader();
            List <string> settings = new List <string>();

            // AD Settings
            settings.Add("AD:Enabled=" + ServerSettings.ADEnabled.ToString());
            settings.Add("AD:AuthenticationType=" + ServerSettings.ADAuthenticationType.ToString());
            settings.Add("AD:RootDomain=" + ServerSettings.ADRootDomain);
            settings.Add("AD:Username="******"AD:Password="******"Server:ServerId=" + ServerSettings.ServerId);
            settings.Add("Server:ServerName=" + ServerSettings.ServerName);

            // Provider Settings
            settings.Add("Provider:ProviderGroupID=" + ProviderSettings.ProviderGroupID.ToString());
            settings.Add("Provider:ProviderCode=" + ProviderSettings.ProviderCode);
            settings.Add("Provider:ProviderName=" + ProviderSettings.ProviderName);
            settings.Add("Provider:ProviderType=" + ProviderSettings.ProviderType);

            // Custom Provider Settings
            foreach (string settingName in ProviderSettings.Settings.Keys)
            {
                settings.Add(settingName + "=" + ProviderSettings.Settings[settingName]);
            }

            // set header
            settingsHeader.Settings = settings.ToArray();
            FieldInfo field = proxy.GetType().GetField("ServiceProviderSettingsSoapHeaderValue");

            if (field != null)
            {
                field.SetValue(proxy, settingsHeader);
            }
        }
Exemple #2
0
 public ClientOutputFilter(ServerUsernameAssertion parentAssertion, FilterCreationContext filterContext)
     : base(parentAssertion.ServiceActor, false, parentAssertion.ClientActor)
 {
     this.parentAssertion = parentAssertion;
     this.filterContext   = filterContext;
 }