Exemple #1
0
        /// <summary>
        /// newkeyBtn_Click event
        /// </summary>
        private void newkeyBtn_Click(object sender, EventArgs e)
        {
            Cursor crs = this.Cursor;

            try
            {
                MMCService.NewUserKey(_upn);
                _secretkey              = MMCService.GetEncodedUserKey(_upn);
                this.DisplayKey.Text    = _secretkey;
                this.qrCodeGraphic.Text = MMCService.GetQRCodeValue(_upn, this.DisplayKey.Text);
                if (!SyncDisabled)
                {
                    userPropertyPage.SyncSharedUserData(this, true);
                }
            }
            catch (Exception ex)
            {
                this.Cursor = crs;
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                {
                    Text    = ex.Message,
                    Buttons = MessageBoxButtons.OK,
                    Icon    = MessageBoxIcon.Error
                };
                userPropertyPage.ParentSheet.ShowDialog(messageBoxParameters);
            }
            finally
            {
                this.Cursor = crs;
            }
        }
Exemple #2
0
        /// <summary>
        /// BTNSendByMail_Click event
        /// </summary>
        private void BTNSendByMail_Click(object sender, EventArgs e)
        {
            Cursor crs = this.Cursor;
            int    cnt = 0;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                RegistrationList lst = userPropertyPage.GetSharedUserData();
                foreach (Registration reg in lst)
                {
                    string secret = MMCService.GetEncodedUserKey(reg.UPN);
                    MMCService.SendKeyByEmail(reg.MailAddress, reg.UPN, secret);
                    cnt++;
                }
            }
            catch (Exception ex)
            {
                this.Cursor = crs;
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = ex.Message;
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                userPropertyPage.ParentSheet.ShowDialog(messageBoxParameters);
            }
            finally
            {
                this.Cursor = crs;
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = string.Format(errors_strings.InfosSendingMails, cnt);
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Information;
                userPropertyPage.ParentSheet.ShowDialog(messageBoxParameters);
            }
        }
 /// <summary>
 /// newkeyBtn_Click event
 /// </summary>
 private void newkeyBtn_Click(object sender, EventArgs e)
 {
     MMCService.NewUserKey(_upn);
     _secretkey              = MMCService.GetEncodedUserKey(_upn);
     this.DisplayKey.Text    = _secretkey;
     this.qrCodeGraphic.Text = MMCService.GetQRCodeValue(_upn, this.DisplayKey.Text);
     if (!SyncDisabled)
     {
         userPropertyPage.SyncSharedUserData(this, true);
     }
 }
Exemple #4
0
        /// <summary>
        /// SetUserControlData method implmentation
        /// </summary>
        public void SetUserControlData(MFAUserList lst, bool disablesync)
        {
            SyncDisabled = disablesync;
            try
            {
                MFAUser obj = lst[0];
                _upn       = obj.UPN;
                _email     = obj.MailAddress;
                _secretkey = MMCService.GetEncodedUserKey(obj.UPN);

                if (string.IsNullOrEmpty(_email))
                {
                    this.EmailPrompt.Text = "Email : ";
                    _emailnotset          = true;
                }
                else
                {
                    this.EmailPrompt.Text = string.Format("Email : {0}", _email);
                    _emailnotset          = false;
                }
                if (!string.IsNullOrEmpty(_secretkey))
                {
                    this.DisplayKey.Text = _secretkey;
                    if (!string.IsNullOrEmpty(_upn))
                    {
                        this.qrCodeGraphic.Text = MMCService.GetQRCodeValue(_upn, this.DisplayKey.Text);
                    }
                    else
                    {
                        this.qrCodeGraphic.Text = string.Empty;
                    }
                }
                else
                {
                    userPropertyPage.Dirty = true;
                }
                UpdateControlsEnabled();
            }
            catch (Exception)
            {
                this.DisplayKey.Text    = string.Empty;
                this.qrCodeGraphic.Text = string.Empty;
            }
            finally
            {
                SyncDisabled = false;
            }
        }
        /// <summary>
        /// SetUserControlData method implmentation
        /// </summary>
        public void SetUserControlData(RegistrationList lst, bool disablesync)
        {
            SyncDisabled = disablesync;
            try
            {
                Registration obj = ((RegistrationList)lst)[0];
                _secretkey = MMCService.GetEncodedUserKey(((Registration)obj).UPN);
                // _secretkey = KeysManager.EncodedKey(((Registration)obj).UPN);
                _upn   = ((Registration)obj).UPN;
                _email = ((Registration)obj).MailAddress;

                if (string.IsNullOrEmpty(_email))
                {
                    this.EmailPrompt.Text = "Adresse email : ";
                    _emailnotset          = true;
                }
                else
                {
                    this.EmailPrompt.Text = string.Format("Adresse email : {0}", _email);
                    _emailnotset          = false;
                }
                if (!string.IsNullOrEmpty(_secretkey))
                {
                    this.DisplayKey.Text = _secretkey;
                    if (!string.IsNullOrEmpty(_upn))
                    {
                        this.qrCodeGraphic.Text = MMCService.GetQRCodeValue(_upn, this.DisplayKey.Text);
                    }
                    else
                    {
                        this.qrCodeGraphic.Text = string.Empty;
                    }
                }
                else
                {
                    userPropertyPage.Dirty = true;
                }
                UpdateControlsEnabled();
            }
            finally
            {
                SyncDisabled = false;
            }
        }
Exemple #6
0
        /// <summary>
        /// BTNSendByMail_Click event
        /// </summary>
        private void BTNSendByMail_Click(object sender, EventArgs e)
        {
            Cursor crs = this.Cursor;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                RegistrationList lst = userPropertyPage.GetSharedUserData();
                foreach (Registration reg in lst)
                {
                    string secret = MMCService.GetEncodedUserKey(reg.UPN);
                    MMCService.SendKeyByEmail(reg.MailAddress, reg.UPN, secret);
                }
            }
            finally
            {
                this.Cursor = crs;
            }
        }
        /// <summary>
        /// CanApplyDataChanges method implementation
        /// </summary>
        private bool CanApplyDataChanges(Registration registration)
        {
            bool result = false;

            if (registration.IsApplied)
            {
                return(true);
            }
            if (string.IsNullOrEmpty(registration.UPN))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = res.PPAGEVALIDUSER;
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                ParentSheet.ShowDialog(messageBoxParameters);
                ParentSheet.SetActivePage(0);
            }
            else if (string.IsNullOrEmpty(MMCService.GetEncodedUserKey(registration.UPN)))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = res.PPAGEVALIDKEY;
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                ParentSheet.ShowDialog(messageBoxParameters);
                ParentSheet.SetActivePage(1);
            }
            else if (string.IsNullOrEmpty(registration.MailAddress))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = res.PPAGEVALIDMAIL;
                messageBoxParameters.Buttons = MessageBoxButtons.YesNo;
                messageBoxParameters.Icon    = MessageBoxIcon.Warning;
                if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes)
                {
                    result = true;
                }
                else
                {
                    ParentSheet.SetActivePage(0);
                }
            }
            else if (!MMCService.IsValidEmail(registration.MailAddress))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = res.PPAGEINVALIDMAIL;
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                ParentSheet.ShowDialog(messageBoxParameters);
                ParentSheet.SetActivePage(0);
            }
            else if (string.IsNullOrEmpty(registration.PhoneNumber))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = res.PPAGEVALIDPHONE;
                messageBoxParameters.Buttons = MessageBoxButtons.YesNo;
                messageBoxParameters.Icon    = MessageBoxIcon.Warning;
                if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes)
                {
                    result = true;
                }
                else
                {
                    ParentSheet.SetActivePage(0);
                }
            }
            else if (!MMCService.IsValidPhone(registration.PhoneNumber))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = res.PPAGEINVALIDPHONE;
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                ParentSheet.ShowDialog(messageBoxParameters);
                ParentSheet.SetActivePage(0);
            }
            else
            {
                result = true;
            }
            return(result);
        }
        /// <summary>
        /// CanApplyDataChanges method implementation
        /// </summary>
        private bool CanApplyDataChanges(MFAUser registration)
        {
            bool result = true;

            if (registration.IsApplied)
            {
                return(result);
            }
            IExternalProvider prov1 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Code);

            if (prov1 != null)
            {
                if ((prov1.Enabled) && (prov1.IsRequired))
                {
                    if (string.IsNullOrEmpty(registration.UPN))
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                        {
                            Text    = res.PPAGEVALIDUSER,
                            Buttons = MessageBoxButtons.OK,
                            Icon    = MessageBoxIcon.Error
                        };
                        ParentSheet.ShowDialog(messageBoxParameters);
                        ParentSheet.SetActivePage(0);
                        result = false;
                    }
                    else if (string.IsNullOrEmpty(MMCService.GetEncodedUserKey(registration.UPN)))
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                        {
                            Text    = res.PPAGEVALIDKEY,
                            Buttons = MessageBoxButtons.OK,
                            Icon    = MessageBoxIcon.Error
                        };
                        ParentSheet.ShowDialog(messageBoxParameters);
                        ParentSheet.SetActivePage(1);
                        result = false;
                    }
                }
            }
            IExternalProvider prov2 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Email);

            if (prov2 != null)
            {
                if ((prov2.Enabled) && (prov2.IsRequired))
                {
                    if (string.IsNullOrEmpty(registration.MailAddress))
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                        {
                            Text    = res.PPAGEVALIDMAIL,
                            Buttons = MessageBoxButtons.YesNo,
                            Icon    = MessageBoxIcon.Warning
                        };
                        if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes)
                        {
                            result = true;
                        }
                        else
                        {
                            result = false;
                            ParentSheet.SetActivePage(0);
                        }
                    }
                    else if (!MMCService.IsValidEmail(registration.MailAddress))
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                        {
                            Text    = res.PPAGEINVALIDMAIL,
                            Buttons = MessageBoxButtons.OK,
                            Icon    = MessageBoxIcon.Error
                        };
                        ParentSheet.ShowDialog(messageBoxParameters);
                        ParentSheet.SetActivePage(0);
                        result = false;
                    }
                }
            }
            IExternalProvider prov3 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.External);

            if (prov3 != null)
            {
                if ((prov3.Enabled) && (prov3.IsRequired))
                {
                    if (string.IsNullOrEmpty(registration.PhoneNumber))
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                        {
                            Text    = res.PPAGEVALIDPHONE,
                            Buttons = MessageBoxButtons.YesNo,
                            Icon    = MessageBoxIcon.Warning
                        };
                        if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes)
                        {
                            result = true;
                        }
                        else
                        {
                            result = false;
                            ParentSheet.SetActivePage(0);
                        }
                    }
                    else if (!MMCService.IsValidPhone(registration.PhoneNumber))
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                        {
                            Text    = res.PPAGEINVALIDPHONE,
                            Buttons = MessageBoxButtons.OK,
                            Icon    = MessageBoxIcon.Error
                        };
                        ParentSheet.ShowDialog(messageBoxParameters);
                        ParentSheet.SetActivePage(0);
                        result = false;
                    }
                }
            }
            return(result);
        }