예제 #1
0
        private void ShowSecurityDialog(DisplayType displayType, string errorMessage = null)
        {
            SecurityPortal    securityDialog   = new SecurityPortal(displayType);
            ISecurityProvider securityProvider = SecurityPrincipal.Identity.Provider;

            // Show authentication failure reason if one was defined and user didn't force another message
            if ((object)errorMessage == null && (object)securityProvider != null)
            {
                errorMessage = securityProvider.AuthenticationFailureReason;
            }

            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                securityDialog.ProviderFailure = true;
                securityDialog.DisplayErrorMessage(errorMessage);
            }

            // Show the WPF security dialog
            if (!securityDialog.ShowDialog().GetValueOrDefault())
            {
                // User chose to cancel security action. If the secure window has no parent,
                // this is root window so exit application, otherwise just close the window
                if ((object)this.Owner == null)
                {
                    m_shutdownRequested = true;
                    Application.Current.Shutdown();
                }
                else
                {
                    this.Close();
                }
            }

            SecurityPrincipal = securityDialog.SecurityPrincipal;
        }
예제 #2
0
        private void ShowSecurityDialog(DisplayType displayType, string errorMessage = null)
        {
            SecurityPortal securityDialog = new SecurityPortal(displayType);

            // Show authentication failure reason if one was defined and user didn't force another message
            if ((object)errorMessage == null && (object)SecurityProviderCache.CurrentProvider != null)
                errorMessage = SecurityProviderCache.CurrentProvider.AuthenticationFailureReason;

            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                securityDialog.ProviderFailure = true;
                securityDialog.DisplayErrorMessage(errorMessage);
            }

            // Show the WPF security dialog
            if (!securityDialog.ShowDialog().GetValueOrDefault())
            {
                // User chose to cancel security action. If the secure window has no parent,
                // this is root window so exit application, otherwise just close the window
                if ((object)this.Owner == null)
                {
                    m_shutdownRequested = true;
                    Application.Current.Shutdown();
                }
                else
                {
                    this.Close();
                }
            }
        }