/// <summary> /// Creates the client. /// </summary> /// <param name="url">The URL.</param> /// <param name="username">The username.</param> /// <param name="password">The password.</param> /// <param name="authenticationMode">The authentication mode.</param> /// <returns></returns> public static LocatorHub.LocatorHub CreateClient(string url, string username, string password, AuthenticationMode authenticationMode, string tokenUrl) { LocatorHub.LocatorHub client = new LocatorHub.LocatorHub(); string locatorUrl = url; if (locatorUrl.StartsWith("DATAHUB:")) { locatorUrl = locatorUrl.Replace("DATAHUB:", ""); string token = LocatorManager.GetToken(LocatorManager.GetTokenUrlFromLocatorUrl(locatorUrl), DataHubConfiguration.Current.UserName, DataHubConfiguration.Current.Password); locatorUrl = String.Format("{0}?Token={1}", locatorUrl, token); } else { switch (authenticationMode) { case AuthenticationMode.Token: string locatorTokenURl = tokenUrl; if (String.IsNullOrEmpty(locatorTokenURl)) { locatorTokenURl = LocatorManager.GetTokenUrlFromLocatorUrl(url); } string token = LocatorManager.GetToken(locatorTokenURl, username, password); locatorUrl = String.Format("{0}?Token={1}", url, token); break; case AuthenticationMode.Windows: client.Credentials = new NetworkCredential(username, password); break; case AuthenticationMode.CurrentWindows: client.Credentials = CredentialCache.DefaultNetworkCredentials; break; } } client.Url = locatorUrl; return client; }
/// <summary> /// Initializes a new instance of the <see cref="LocatorPopupForm"/> class. /// </summary> public LocatorPopupForm(LocatorHub.LocatorHub client) { InitializeComponent(); this.Client = client; }