public void Configure(WebServicesClientProtocol proxy) { // set proxy URL string serverUrl = enterpriseServerUrl.Trim(); if (serverUrl.Length == 0) throw new Exception("Enterprise Server URL could not be empty"); int idx = proxy.Url.LastIndexOf("/"); // strip the last slash if any if (serverUrl[serverUrl.Length - 1] == '/') serverUrl = serverUrl.Substring(0, serverUrl.Length - 1); proxy.Url = serverUrl + proxy.Url.Substring(idx); // set timeout proxy.Timeout = 900000; //15 minutes // System.Threading.Timeout.Infinite; if (!String.IsNullOrEmpty(username)) { // create assertion UsernameAssertion assert = new UsernameAssertion(username, password); // apply policy Policy policy = new Policy(); policy.Assertions.Add(assert); proxy.SetPolicy(policy); } }
public static WebServicesClientProtocol ServerInit(WebServicesClientProtocol proxy, ServerProxyConfigurator cnfg, int serverId) { // get server info ServerInfo server = ServerController.GetServerByIdInternal(serverId); if (server == null) { throw new Exception(String.Format("Server with ID {0} was not found", serverId)); } // set AD integration settings cnfg.ServerSettings.ADEnabled = server.ADEnabled; cnfg.ServerSettings.ADAuthenticationType = AuthenticationTypes.Secure; try { cnfg.ServerSettings.ADAuthenticationType = (AuthenticationTypes)Enum.Parse(typeof(AuthenticationTypes), server.ADAuthenticationType, true); } catch { /* ignore */ } cnfg.ServerSettings.ADRootDomain = server.ADRootDomain; cnfg.ServerSettings.ADUsername = server.ADUsername; cnfg.ServerSettings.ADPassword = server.ADPassword; cnfg.ServerSettings.ADParentDomain = server.ADParentDomain; cnfg.ServerSettings.ADParentDomainController = server.ADParentDomainController; // set timeout cnfg.Timeout = ConfigSettings.ServerRequestTimeout; return(ServerInit(proxy, cnfg, server.ServerUrl, server.Password)); }
public static void ApplyAutheticationTicket(WebServicesClientProtocol protocol, string userName, string password) { UsernameToken token = GetUsernameToken(userName, password, PasswordOption.SendPlainText); protocol.SetClientCredential(token); protocol.SetPolicy(new TpPolicy()); }
public static WebServicesClientProtocol ServerInit(WebServicesClientProtocol proxy, ServerProxyConfigurator cnfg, int serverId) { // get server info ServerInfo server = ServerController.GetServerByIdInternal(serverId); if (server == null) throw new Exception(String.Format("Server with ID {0} was not found", serverId)); // set AD integration settings cnfg.ServerSettings.ADEnabled = server.ADEnabled; cnfg.ServerSettings.ADAuthenticationType = AuthenticationTypes.Secure; try { cnfg.ServerSettings.ADAuthenticationType = (AuthenticationTypes)Enum.Parse(typeof(AuthenticationTypes), server.ADAuthenticationType, true); } catch { /* ignore */ } cnfg.ServerSettings.ADRootDomain = server.ADRootDomain; cnfg.ServerSettings.ADUsername = server.ADUsername; cnfg.ServerSettings.ADPassword = server.ADPassword; // set timeout cnfg.Timeout = ConfigSettings.ServerRequestTimeout; return ServerInit(proxy, cnfg, server.ServerUrl, server.Password); }
public void Configure(WebServicesClientProtocol proxy) { // set proxy URL string serverUrl = _serverUrl.Trim(); if (serverUrl.Length == 0) { throw new Exception("Enterprise Server URL could not be empty"); } int idx = proxy.Url.LastIndexOf("/"); // strip the last slash if any if (serverUrl[serverUrl.Length - 1] == '/') { serverUrl = serverUrl.Substring(0, serverUrl.Length - 1); } proxy.Url = serverUrl + proxy.Url.Substring(idx); // set timeout proxy.Timeout = 900000; //15 minutes // System.Threading.Timeout.Infinite; if (_securityPolicy != null) { proxy.SetPolicy(_securityPolicy); } }
public static WebServicesClientProtocol Init(WebServicesClientProtocol proxy, int serviceId) { ServerProxyConfigurator cnfg = new ServerProxyConfigurator(); // get service ServiceInfo service = ServerController.GetServiceInfo(serviceId); if (service == null) { throw new Exception(String.Format("Service with ID {0} was not found", serviceId)); } // set service settings StringDictionary serviceSettings = ServerController.GetServiceSettings(serviceId); foreach (string key in serviceSettings.Keys) { cnfg.ProviderSettings.Settings[key] = serviceSettings[key]; } // get provider ProviderInfo provider = ServerController.GetProvider(service.ProviderId); cnfg.ProviderSettings.ProviderGroupID = provider.GroupId; cnfg.ProviderSettings.ProviderCode = provider.ProviderName; cnfg.ProviderSettings.ProviderName = provider.DisplayName; cnfg.ProviderSettings.ProviderType = provider.ProviderType; // init service on the server level return(ServerInit(proxy, cnfg, service.ServerId)); }
public static WebServicesClientProtocol Init(WebServicesClientProtocol proxy, int serviceId) { ServerProxyConfigurator cnfg = new ServerProxyConfigurator(); // get service ServiceInfo service = ServerController.GetServiceInfo(serviceId); if (service == null) throw new Exception(String.Format("Service with ID {0} was not found", serviceId)); // set service settings StringDictionary serviceSettings = ServerController.GetServiceSettings(serviceId); foreach (string key in serviceSettings.Keys) cnfg.ProviderSettings.Settings[key] = serviceSettings[key]; // get provider ProviderInfo provider = ServerController.GetProvider(service.ProviderId); cnfg.ProviderSettings.ProviderGroupID = provider.GroupId; cnfg.ProviderSettings.ProviderCode = provider.ProviderName; cnfg.ProviderSettings.ProviderName = provider.DisplayName; cnfg.ProviderSettings.ProviderType = provider.ProviderType; // init service on the server level return ServerInit(proxy, cnfg, service.ServerId); }
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); }
public void Configure(WebServicesClientProtocol proxy) { // set proxy URL string serverUrl = enterpriseServerUrl.Trim(); if (serverUrl.Length == 0) { throw new Exception("Enterprise Server URL could not be empty"); } int idx = proxy.Url.LastIndexOf("/"); // strip the last slash if any if (serverUrl[serverUrl.Length - 1] == '/') { serverUrl = serverUrl.Substring(0, serverUrl.Length - 1); } proxy.Url = serverUrl + proxy.Url.Substring(idx); // set timeout proxy.Timeout = 900000; //15 minutes // System.Threading.Timeout.Infinite; if (!String.IsNullOrEmpty(username)) { // create assertion UsernameAssertion assert = new UsernameAssertion(username, password); // apply policy Policy policy = new Policy(); policy.Assertions.Add(assert); proxy.SetPolicy(policy); } }
/// <summary> /// 对某个WS进行初始化 /// </summary> /// <param name="ws"></param> /// <param name="username"></param> /// <param name="password"></param> public static void Init(WebServicesClientProtocol ws, string username, string password) { AppContext.UserName = username; AppContext.Password = password; Policy policy = new Policy(); policy.Assertions.Add(new MyAssertion()); ws.SetPolicy(policy); }
private static WebServicesClientProtocol ServerInit(WebServicesClientProtocol proxy, ServerProxyConfigurator cnfg, string serverUrl, string serverPassword) { // set URL & password cnfg.ServerUrl = serverUrl; cnfg.ServerPassword = serverPassword; // configure proxy! cnfg.Configure(proxy); return(proxy); }
private static void serviceClientSetting(WebServicesClientProtocol serviceClient, string url, string username = null, string password = null, int timeout = -1) { serviceClient.Url = url; /* timeout is 0 if config verb EBSServiceTimeout is not defined. * It is set at the _sr_client CS_SERVICEREQUEST_PUB_Service() instance * level, so all the ws calls (from this proxy client) have this timeout setting */ serviceClient.Timeout = timeout == 0 ? -1 : timeout; if (!String.IsNullOrWhiteSpace(username) && !String.IsNullOrWhiteSpace(password)) { // add wsse:Security headers. UsernameToken userNameToken = new UsernameToken(username, password, PasswordOption.SendPlainText); SoapContext soapContext = serviceClient.RequestSoapContext; soapContext.Security.Tokens.Add(userNameToken); } }
private void EncryptMessage(WebServicesClientProtocol oWSProxy) { X509SecurityToken encryptToken = new X509SecurityToken(this.EncryptTokenCertificate); if (!encryptToken.SupportsDataEncryption) { throw new CryptographicException("Certificate for encryption must support data encryption."); } if (encryptToken.IsExpired) { throw new CryptographicException("Certificate for signature is expired."); } oWSProxy.RequestSoapContext.Security.Tokens.Add(encryptToken); oWSProxy.RequestSoapContext.Security.Elements.Add(new EncryptedData(encryptToken)); }
private void AddSignature(WebServicesClientProtocol oWSProxy) { SecurityToken signingToken = new X509SecurityToken(this.SigningTokenCertificate); if (!signingToken.SupportsDigitalSignature) { throw new CryptographicException("Certificate for signature must support digital signatures and have a private key available."); } if (signingToken.IsExpired) { throw new CryptographicException("Certificate for signature is expired."); } //Add the signature element to a security section on the request to sign the request oWSProxy.RequestSoapContext.Security.Tokens.Add(signingToken); oWSProxy.RequestSoapContext.Security.Elements.Add(new MessageSignature(signingToken)); }
public void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy, bool applyPolicy) { // load ES properties string serverUrl = WebDavAppConfigManager.Instance.EnterpriseServerUrl; EnterpriseServerProxyConfigurator cnfg = new EnterpriseServerProxyConfigurator(); cnfg.EnterpriseServerUrl = serverUrl; // create assertion if (applyPolicy) { cnfg.Username = WebDavAppConfigManager.Instance.WebsitePanelConstantUserParameters.Login; cnfg.Password = _cryptography.Decrypt(WebDavAppConfigManager.Instance.WebsitePanelConstantUserParameters.Password); } cnfg.Configure(proxy); }
public static void RunServiceAsSpaceOwner(WebServicesClientProtocol proxy) { // impersonate as space owner string username = EcommerceSettings.GetSetting("OwnerUsername"); string password = EcommerceSettings.GetSetting("OwnerPassword"); if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password)) { EnterpriseServerProxyConfigurator config = new EnterpriseServerProxyConfigurator(); config.EnterpriseServerUrl = EcommerceSettings.GetSetting("EnterpriseServer"); config.Username = username; config.Password = password; config.Configure(proxy); } else throw new Exception("Ecommerce doesn't configured correctly, please review SitesSettings/Ecommerce section"); }
public static void RunServiceAsSpaceOwner(WebServicesClientProtocol proxy) { // impersonate as space owner string username = EcommerceSettings.GetSetting("OwnerUsername"); string password = EcommerceSettings.GetSetting("OwnerPassword"); if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password)) { EnterpriseServerProxyConfigurator config = new EnterpriseServerProxyConfigurator(); config.EnterpriseServerUrl = EcommerceSettings.GetSetting("EnterpriseServer"); config.Username = username; config.Password = password; config.Configure(proxy); } else { throw new Exception("Ecommerce doesn't configured correctly, please review SitesSettings/Ecommerce section"); } }
public void Configure(WebServicesClientProtocol proxy) { // set proxy URL string serverUrl = _serverUrl.Trim(); if (serverUrl.Length == 0) throw new Exception("Enterprise Server URL could not be empty"); int idx = proxy.Url.LastIndexOf("/"); // strip the last slash if any if (serverUrl[serverUrl.Length - 1] == '/') serverUrl = serverUrl.Substring(0, serverUrl.Length - 1); proxy.Url = serverUrl + proxy.Url.Substring(idx); // set timeout proxy.Timeout = 900000; //15 minutes // System.Threading.Timeout.Infinite; if (_securityPolicy != null) proxy.SetPolicy(_securityPolicy); }
public static void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy, bool applyPolicy) { // load ES properties string serverUrl = PortalConfiguration.SiteSettings["EnterpriseServer"]; EnterpriseServerProxyConfigurator cnfg = new EnterpriseServerProxyConfigurator(); cnfg.EnterpriseServerUrl = serverUrl; // create assertion if (applyPolicy) { if (AuthTicket != null) { cnfg.Username = AuthTicket.Name; cnfg.Password = AuthTicket.UserData.Substring(0, AuthTicket.UserData.IndexOf(Environment.NewLine)); } } cnfg.Configure(proxy); }
public static void Configure(WebServicesClientProtocol proxy, bool applyPolicy) { if (applyPolicy && !HttpContext.Current.Request.IsAuthenticated) { // impersonate as space owner string username = EcommerceSettings.GetSetting("OwnerUsername"); string password = EcommerceSettings.GetSetting("OwnerPassword"); if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password)) { EnterpriseServerProxyConfigurator config = new EnterpriseServerProxyConfigurator(); config.EnterpriseServerUrl = EcommerceSettings.GetSetting("EnterpriseServer"); config.Username = username; config.Password = password; config.Configure(proxy); return; } } PortalUtils.ConfigureEnterpriseServerProxy(proxy, applyPolicy); }
public static void Configure(WebServicesClientProtocol proxy) { Configure(proxy, true); }
public static WebServicesClientProtocol ServerInit(WebServicesClientProtocol proxy, int serverId) { return(ServerInit(proxy, new ServerProxyConfigurator(), serverId)); }
public static WebServicesClientProtocol ServerInit(WebServicesClientProtocol proxy, string serverUrl, string serverPassword) { return(ServerInit(proxy, new ServerProxyConfigurator(), serverUrl, serverPassword)); }
public static void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy) { ConfigureEnterpriseServerProxy(proxy, true); }
public static void ApplyAutheticationTicket(WebServicesClientProtocol protocol, string userName, string password) { var token = GetUsernameToken(userName, password, PasswordOption.SendPlainText); protocol.SetClientCredential(token); protocol.SetPolicy(new TpServicePolicy()); }
public static WebServicesClientProtocol ServerInit(WebServicesClientProtocol proxy, string serverUrl, string serverPassword) { return ServerInit(proxy, new ServerProxyConfigurator(), serverUrl, serverPassword); }
public static WebServicesClientProtocol ServerInit(WebServicesClientProtocol proxy, int serverId) { return ServerInit(proxy, new ServerProxyConfigurator(), serverId); }
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); } }
private static WebServicesClientProtocol ServerInit(WebServicesClientProtocol proxy, ServerProxyConfigurator cnfg, string serverUrl, string serverPassword) { // set URL & password cnfg.ServerUrl = serverUrl; cnfg.ServerPassword = serverPassword; // configure proxy! cnfg.Configure(proxy); return proxy; }