A Winforms based authentication manager.
Inheritance: Rally.RestApi.Auth.ApiAuthManager
		/// <summary>
		/// Shows the specified SSO URL to the user.
		/// </summary>
		internal void ShowSsoPage(RestApiAuthMgrWinforms authMgr, Uri ssoUrl)
		{
			if (authMgr == null)
				throw new ArgumentNullException("authMgr", "You must provide an authorization manager.");

			if (ssoUrl == null)
				throw new ArgumentNullException("ssoUrl", "You must provide a URL for completing SSO authentication.");

			this.authMgr = authMgr;
			browser.Url = ssoUrl;
			Show();
		}
        /// <summary>
        /// Shows the specified SSO URL to the user.
        /// </summary>
        internal void ShowSsoPage(RestApiAuthMgrWinforms authMgr, Uri ssoUrl)
        {
            if (authMgr == null)
            {
                throw new ArgumentNullException("authMgr", "You must provide an authorization manager.");
            }

            if (ssoUrl == null)
            {
                throw new ArgumentNullException("ssoUrl", "You must provide a URL for completing SSO authentication.");
            }

            this.authMgr = authMgr;
            browser.Url  = ssoUrl;
            Show();
        }
		public MainWindow()
		{
			InitializeComponent();
			headerLabel.Text = "Login Window Example";

			// HELP: Instantiate authorization managers
			winFormsAuthMgr = new RestApiAuthMgrWinforms(applicationToken, encryptionKey, encryptionUtilities);
			wpfAuthMgr = new RestApiAuthMgrWpf(applicationToken, encryptionKey, encryptionUtilities);

			// Help: Set logos. Any use of Rally's Logo is governed by your agreements with Rally.
			RestApiAuthMgrWinforms.SetLogo(ImageResources.RallyLogo40x40);
			RestApiAuthMgrWpf.SetLogo(GetImageSource(ImageResources.RallyLogo40x40),
				GetImageSource(ImageResources.RallyLogo40x40));


			// Help: You can auto-authenticate if you want. We do not have it enabled for this application.
			// wpfAuthMgr.AutoAuthenticate(true);

			UpdateAuthenticationResults(RallyRestApi.AuthenticationResult.NotAuthorized, null);
		}
		// HELP: This method has some setup code that may interest you.
		#region reconfigure_Click
		private void reconfigure_Click(object sender, RoutedEventArgs e)
		{
			Uri defaultProxyServer = null;
			if (!String.IsNullOrWhiteSpace(defaultProxyServerUri.Text))
				defaultProxyServer = new Uri(defaultProxyServerUri.Text);

			// HELP: This is for demo purposes only. We are clearing all known data in the authentication managers by doing this.
			winFormsAuthMgr = new RestApiAuthMgrWinforms(applicationToken, encryptionKey, encryptionUtilities);
			wpfAuthMgr = new RestApiAuthMgrWpf(applicationToken, encryptionKey, encryptionUtilities);

			UpdateAuthenticationResults(RallyRestApi.AuthenticationResult.NotAuthorized, null);

			// HELP: Configure labels for UI. These are global and used by both authentication managers to build their UI.
			// If this is not called, the default labels will be used.
			ApiAuthManager.Configure(loginWindowServerLabelText: "My Updated Server Label",
				loginWindowDefaultServer: new Uri("http://onprem.rally.url"));

			Uri defaultServer = null;
			if (!String.IsNullOrWhiteSpace(defaultServerUri.Text))
				defaultServer = new Uri(defaultServerUri.Text);

			ApiAuthManager.Configure(windowTitleLabel.Text, headerLabel.Text,
				credentialsTabLabel.Text, usernameLabel.Text, passwordLabel.Text,
				serverTabLabel.Text, String.Empty, serverLabel.Text, String.Empty, defaultServer,
				proxyTabLabel.Text, proxyServerLabel.Text, proxyUsernameLabel.Text,
				proxyPasswordLabel.Text, defaultProxyServer,
				loginWindowSsoInProgressLabel.Text,
				loginButtonLabel.Text, logoutButtonLabel.Text, cancelButtonLabel.Text);

			// HELP: If you need to use custom controls (Ex: from a third party vendor), you can set them using this code snippet.
			// This triggers a global change for the next time a window is created.
			if ((useCustomControls.IsChecked.HasValue) && (useCustomControls.IsChecked.Value))
			{
				RestApiAuthMgrWpf.SetCustomControlType(CustomWpfControlType.Buttons, typeof(CustomButton));
				RestApiAuthMgrWpf.SetCustomControlType(CustomWpfControlType.TabControl, typeof(CustomTabControl));
				RestApiAuthMgrWpf.SetCustomControlType(CustomWpfControlType.TabItem, typeof(CustomTabItem));
			}
		}
		internal void BuildLayout(RestApiAuthMgrWinforms authMgr)
		{
			Text = ApiAuthManager.LoginWindowTitle;
			AuthMgr = authMgr;

			tabCredentials.Text = ApiAuthManager.LoginWindowCredentialsTabText;
			userNameLabel.Text = ApiAuthManager.LoginWindowUserNameLabelText;
			passwordLabel.Text = ApiAuthManager.LoginWindowPwdLabelText;

			tabServer.Text = ApiAuthManager.LoginWindowRallyServerTabText;
			rallyServerLabel.Text = ApiAuthManager.LoginWindowServerLabelText;

			tabProxy.Text = ApiAuthManager.LoginWindowProxyServerTabText;
			proxyServerLabel.Text = ApiAuthManager.LoginWindowProxyServerLabelText;
			proxyUserNameLabel.Text = ApiAuthManager.LoginWindowProxyUserNameLabelText;
			proxyPasswordLabel.Text = ApiAuthManager.LoginWindowProxyPwdLabelText;

			loginBtn.Text = ApiAuthManager.LoginWindowLoginText;
			logoutBtn.Text = ApiAuthManager.LoginWindowLogoutText;
			cancelBtn.Text = ApiAuthManager.LoginWindowCancelText;

			if ((authMgr.Api != null) &&
				(authMgr.Api.ConnectionInfo != null) &&
				(authMgr.Api.ConnectionInfo.Server != null))
			{
				rallyServerInput.Text = authMgr.Api.ConnectionInfo.Server.ToString();
			}
			else if (ApiAuthManager.LoginWindowDefaultServer != null)
				rallyServerInput.Text = ApiAuthManager.LoginWindowDefaultServer.ToString();
			else
				rallyServerInput.Text = RallyRestApi.DEFAULT_SERVER;

			if ((authMgr.Api != null) &&
				(authMgr.Api.ConnectionInfo != null) &&
				(authMgr.Api.ConnectionInfo.Proxy != null) &&
				(authMgr.Api.ConnectionInfo.Proxy.Address != null))
			{
				proxyServerInput.Text = authMgr.Api.ConnectionInfo.Proxy.Address.ToString();
			}
			else if (ApiAuthManager.LoginWindowDefaultProxyServer != null)
				proxyServerInput.Text = ApiAuthManager.LoginWindowDefaultProxyServer.ToString();
			else
				proxyServerInput.Text = String.Empty;

			if (authMgr.Api.AuthenticationState != RallyRestApi.AuthenticationResult.NotAuthorized)
			{
				usernameInput.Text = AuthMgr.Api.ConnectionInfo.UserName;
				passwordInput.Text = String.Empty;
				rallyServerInput.Text = AuthMgr.Api.ConnectionInfo.Server.ToString();
				if (AuthMgr.Api.ConnectionInfo.Proxy != null)
					proxyServerInput.Text = AuthMgr.Api.ConnectionInfo.Proxy.Address.ToString();
			}
		}
        internal void BuildLayout(RestApiAuthMgrWinforms authMgr)
        {
            Text    = ApiAuthManager.LoginWindowTitle;
            AuthMgr = authMgr;

            tabCredentials.Text = ApiAuthManager.LoginWindowCredentialsTabText;
            userNameLabel.Text  = ApiAuthManager.LoginWindowUserNameLabelText;
            passwordLabel.Text  = ApiAuthManager.LoginWindowPwdLabelText;

            tabServer.Text        = ApiAuthManager.LoginWindowRallyServerTabText;
            rallyServerLabel.Text = ApiAuthManager.LoginWindowServerLabelText;

            tabProxy.Text           = ApiAuthManager.LoginWindowProxyServerTabText;
            proxyServerLabel.Text   = ApiAuthManager.LoginWindowProxyServerLabelText;
            proxyUserNameLabel.Text = ApiAuthManager.LoginWindowProxyUserNameLabelText;
            proxyPasswordLabel.Text = ApiAuthManager.LoginWindowProxyPwdLabelText;

            loginBtn.Text  = ApiAuthManager.LoginWindowLoginText;
            logoutBtn.Text = ApiAuthManager.LoginWindowLogoutText;
            cancelBtn.Text = ApiAuthManager.LoginWindowCancelText;

            if ((authMgr.Api != null) &&
                (authMgr.Api.ConnectionInfo != null) &&
                (authMgr.Api.ConnectionInfo.Server != null))
            {
                rallyServerInput.Text = authMgr.Api.ConnectionInfo.Server.ToString();
            }
            else if (ApiAuthManager.LoginWindowDefaultServer != null)
            {
                rallyServerInput.Text = ApiAuthManager.LoginWindowDefaultServer.ToString();
            }
            else
            {
                rallyServerInput.Text = RallyRestApi.DEFAULT_SERVER;
            }

            if ((authMgr.Api != null) &&
                (authMgr.Api.ConnectionInfo != null) &&
                (authMgr.Api.ConnectionInfo.Proxy != null) &&
                (authMgr.Api.ConnectionInfo.Proxy.Address != null))
            {
                proxyServerInput.Text = authMgr.Api.ConnectionInfo.Proxy.Address.ToString();
            }
            else if (ApiAuthManager.LoginWindowDefaultProxyServer != null)
            {
                proxyServerInput.Text = ApiAuthManager.LoginWindowDefaultProxyServer.ToString();
            }
            else
            {
                proxyServerInput.Text = String.Empty;
            }

            if (authMgr.Api.AuthenticationState != RallyRestApi.AuthenticationResult.NotAuthorized)
            {
                usernameInput.Text    = AuthMgr.Api.ConnectionInfo.UserName;
                passwordInput.Text    = String.Empty;
                rallyServerInput.Text = AuthMgr.Api.ConnectionInfo.Server.ToString();
                if (AuthMgr.Api.ConnectionInfo.Proxy != null)
                {
                    proxyServerInput.Text = AuthMgr.Api.ConnectionInfo.Proxy.Address.ToString();
                }
            }
        }