Пример #1
0
        internal void BuildLayout(RestApiAuthMgrWpf authMgr)
        {
            Title   = ApiAuthManager.LoginWindowTitle;
            AuthMgr = authMgr;

            tabControl        = GetTabControl();
            tabControl.Margin = new Thickness(10, 10, 10, 5);
            Grid.SetColumn(tabControl, 0);
            Grid.SetColumnSpan(tabControl, 3);
            Grid.SetRow(tabControl, 1);
            layoutGrid.Children.Add(tabControl);

            AddTab(tabControl, TabType.Credentials);
            AddTab(tabControl, TabType.Rally);
            AddTab(tabControl, TabType.Proxy);

            AddButtons();

            inputRow.Height    = new GridLength(tabControl.Height + 20, GridUnitType.Pixel);
            inputRow.MinHeight = inputRow.Height.Value;

            this.Height    = inputRow.Height.Value + (28 * 2) + 100;
            this.MinHeight = this.Height;
            this.MaxHeight = this.Height;

            SetDefaultValues();
            ConnectionTypeChanged(GetEditor(EditorControlType.ConnectionType), null);
        }
		/// <summary>
		/// Shows the specified SSO URL to the user.
		/// </summary>
		internal void ShowSsoPage(RestApiAuthMgrWpf 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.");

			try
			{
				this.authMgr = authMgr;
				if (authMgr.Api.ConnectionInfo.IdpServer != null)
				{
					idpUrl = authMgr.Api.ConnectionInfo.IdpServer;
					idpProxy = authMgr.Api.ConnectionInfo.Proxy;
				}

				this.ssoUrl = ssoUrl;
				SetUrl();
				Show();
			}
			catch
			{
				Dispatcher.Invoke(SetUrl);
				Dispatcher.Invoke(Show);
				// If current thread is not the dispacher thread, then we can't launch the window.
				// Fail and consider SSO not available.
			}
		}
        /// <summary>
        /// Shows the specified SSO URL to the user.
        /// </summary>
        internal void ShowSsoPage(RestApiAuthMgrWpf 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.");
            }

            try
            {
                this.authMgr = authMgr;
                if (authMgr.Api.ConnectionInfo.IdpServer != null)
                {
                    idpUrl   = authMgr.Api.ConnectionInfo.IdpServer;
                    idpProxy = authMgr.Api.ConnectionInfo.Proxy;
                }

                this.ssoUrl = ssoUrl;
                SetUrl();
                Show();
            }
            catch
            {
                Dispatcher.Invoke(SetUrl);
                Dispatcher.Invoke(Show);
                // If current thread is not the dispacher thread, then we can't launch the window.
                // Fail and consider SSO not available.
            }
        }
Пример #4
0
        private HeaderedContentControl GetTabItem()
        {
            HeaderedContentControl tabItem;

            Type tabItemType = RestApiAuthMgrWpf.GetCustomControlType(CustomWpfControlType.TabItem);

            if (tabItemType == null)
            {
                tabItem = new TabItem();
            }
            else
            {
                tabItem = (HeaderedContentControl)Activator.CreateInstance(tabItemType);
            }

            return(tabItem);
        }
Пример #5
0
        private Selector GetTabControl()
        {
            Selector selector;

            Type tabControlType = RestApiAuthMgrWpf.GetCustomControlType(CustomWpfControlType.TabControl);

            if (tabControlType == null)
            {
                selector = new TabControl();
            }
            else
            {
                selector = (Selector)Activator.CreateInstance(tabControlType);
            }

            return(selector);
        }
Пример #6
0
        private Button GetButton()
        {
            Button button;

            Type buttonType = RestApiAuthMgrWpf.GetCustomControlType(CustomWpfControlType.Buttons);

            if (buttonType == null)
            {
                button = new Button();
            }
            else
            {
                button = (Button)Activator.CreateInstance(buttonType);
            }

            button.Margin = new Thickness(5, 0, 5, 0);
            button.Height = 25;

            return(button);
        }
		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(RestApiAuthMgrWpf authMgr)
		{
			Title = ApiAuthManager.LoginWindowTitle;
			AuthMgr = authMgr;

			tabControl = GetTabControl();
			tabControl.Margin = new Thickness(10, 10, 10, 5);
			Grid.SetColumn(tabControl, 0);
			Grid.SetColumnSpan(tabControl, 3);
			Grid.SetRow(tabControl, 1);
			layoutGrid.Children.Add(tabControl);

			AddTab(tabControl, TabType.Credentials);
			AddTab(tabControl, TabType.Rally);
			AddTab(tabControl, TabType.Proxy);

			AddButtons();

			inputRow.Height = new GridLength(tabControl.Height + 20, GridUnitType.Pixel);
			inputRow.MinHeight = inputRow.Height.Value;

			Height = inputRow.Height.Value + (28 * 2) + 100;
			MinHeight = Height;
			MaxHeight = Height;

			SetDefaultValues();
			ConnectionTypeChanged(GetEditor(EditorControlType.ConnectionType), null);
		}