public PasswordResetController(IVerify verify, IPassword password, IUserMaster userMaster, IVerification verification) { _verify = verify; _iPassword = password; _userMaster = userMaster; _verification = verification; }
public bool ShowLogin(string command, IVerify defaultVerify, bool allowThirdVerify, DelegateBusinessVerify businessVerify) { frmLogin loginWindow = new frmLogin(defaultVerify, allowThirdVerify, businessVerify); //login.TopMost = true; if (string.IsNullOrEmpty(_title) == false) { loginWindow.Text = _title; } loginWindow.ShowDialog(); if (loginWindow.DBProvider == null) { return(false); } _dbHelper = loginWindow.DBProvider; _loginUser = loginWindow.LoginUser; _serverName = loginWindow.ServerName; return(true); }
//the function that does the permutations //i use what is called dependency injection, meaning i dont need to know/care what class //would use it or how many public void GeneratePermutation(IVerify verify) { int index = 1; while (_currentNumOfPermutations != _totalNumOfPermutations) { //first, i check if the value at the current index is < the maximum index in the given array //ie if the length is 3, then the last index is 2 if (_solutions[index] < _values.Length - 1) { //if its less that the maximum index, i can increment the value of the current index _solutions[index] += 1; } //if it is = or bigger, i need to reset the value at the index position and go back one step, //ie decrement the index else { //i reset the value to -1 because i want the loop to increment the value from -1 to 0 //and then check to see if the solution is valid or not //if i reset it to 0, then it will increment it to the max value, then go back, and so on, //until it reaches the first index in the array and it misses many solutions and gives index //out of range _solutions[index] = -1; index--; //i use continue because if i get to this point, i know that the solution is not valid continue; } bool validate = verify.isValid(_solutions, index); if (validate == true) { //if the solution is valid, then i check if the index can go one position farther if (index < _values.Length - 1) { index++; //i use continue because i know if the index can go on one more position, then //the solution is not valid continue; } //if the index cant go farther, i check if it is a solution //if the index is at the last position in the array, it should be a solution if (verify.isSolution(_values, index)) { //increment the number of current solutions _currentNumOfPermutations += 1; //print the indexes of the solutions //Console.WriteLine($"indexes are {string.Join(" ", solution)}"); Console.WriteLine($"solution {_currentNumOfPermutations} = {valuesToString(_solutions)}"); //Thread.Sleep(30); //Console.Clear(); //after i find a solution, i reset the value at the current index, and go back one step _solutions[index] = -1; index--; } } } }
public frmLogin(IVerify sysDefaultVerify, bool allowThridVerify, DelegateBusinessVerify businessVerify) { InitializeComponent(); _verifyDefault = sysDefaultVerify; _allowThridVerify = allowThridVerify; _businessVerify = businessVerify; }
public UserTask(string name, string description) { _verify = new Verify(); Name = name; Description = description; DateAdd = DateTime.Now; Validate(); }
/// <summary> /// Verify type is valid /// </summary> /// <typeparam name="T">type</typeparam> /// <param name="name">name of variable</param> /// <param name="userType">user type</param> /// <param name="allowNull">allow null</param> public static void IsValid(string name, IVerify userType, bool allowNull = false) { Verify.IsNotEmpty(nameof(name), name); Verify.Assert <ArgumentNullException>(allowNull || userType != null, name); if (userType != null) { Verify.Assert(userType.IsValid(), name); } }
public bool IsValid(IVerify verify) { if (verify != null) { bool valid = verify.Verify(this.Caster, this.Target, this.Attribute); if (!valid) { Interrupt(new InterruptValid()); } return(false); } return(true); }
public RegistrationController( IUserMaster userMaster, IPassword password, ISavedAssignedRoles savedAssignedRoles, IVerify verify, IVerification verification, IAgentCheckInStatus agentCheckInStatus) { _iUserMaster = userMaster; _iPassword = password; _savedAssignedRoles = savedAssignedRoles; _verify = verify; _verification = verification; _agentCheckInStatus = agentCheckInStatus; }
public LoginController(IUserMaster userMaster, IPassword password, ISavedAssignedRoles savedAssignedRoles, IAgentCheckInStatus agentCheckInStatus, IVerify verify, IProfile profile, ICategory category, IVerification verification) { _iUserMaster = userMaster; _password = password; _savedAssignedRoles = savedAssignedRoles; _agentCheckInStatus = agentCheckInStatus; _verify = verify; _iProfile = profile; _category = category; _verification = verification; }
private static void VerifyProvider_Supply(IVerify obj) { var result = obj.Login("vgameadmini", string.Empty); result.OnValue += val => { if(val) { Console.WriteLine("驗證成功"); } else { Console.WriteLine("驗證失敗"); } Program._Enable = false; }; }
private void _SupplyVerify(IVerify obj) { // 直接呼叫 obj.Login("1", "1"); _Viewer.WriteLine($"property{obj.TestProperty}"); obj.TestEvent += result => { _Viewer.WriteLine($"event {result}"); }; // command 使用方法1 // _Command.Register<string, string>( // "m [a1, a2]", // (a1, a2) => { obj.Login(a1, a2); }); // command 使用方法2 _Command.RegisterLambda <IVerify, string, string, Value <bool> > ( obj, (instance, a1, a2) => instance.Login(a1, a2), _ReturnValue); }
private void butVerfiyCfg_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtVerifyAssembly.Text)) { MessageBox.Show("未指定对应的认证驱动,不能进行配置。", "提示"); return; } string modulePath = System.Windows.Forms.Application.StartupPath + @"\" + txtVerifyAssembly.Text; IVerify verify = null; if (File.Exists(modulePath) == true) { FileInfo fi = new FileInfo(modulePath); string assemblyName = fi.Name.Replace(fi.Extension, ""); string[] tmp = ("..." + assemblyName).Split('.'); string objName = tmp[tmp.Length - 1]; verify = (IVerify)Assembly.LoadFile(modulePath).CreateInstance(assemblyName + "." + objName); } if (verify != null) { verify.VerifyConfig(); } else { MessageBox.Show("认证实例创建失败。", "提示"); } } catch (Exception ex) { MsgBox.ShowException(ex, this); } }
public UserTaskHandler(IUserTaskRepository repository, IVerify verify) { _repository = repository; _verify = verify; }
private void _ToVerify(IVerify obj) { var result = obj.Login(_Account, _Password); result.OnValue += val => { OnDoneEvent(val); }; }
private void _Verify(IVerify obj) { _VerifyResult(obj.Login("name", "pw")); }
private void sbutLogin_Click(object sender, EventArgs e) { try { ServerInfo si = _sm.FindAlias(cbxServer.Text); if (si == null) { MessageBox.Show("未找到对应的服务器配置信息。", "提示"); return; } if (string.IsNullOrEmpty(si.ServerDriverFile)) { MessageBox.Show("未配置数据访问程序集。", "提示"); return; } IDBProvider dbProvider = null; string modulePath = System.Windows.Forms.Application.StartupPath + @"\" + si.ServerDriverFile; if (File.Exists(modulePath) == true) { FileInfo fi = new FileInfo(modulePath); string assemblyName = fi.Name.Replace(fi.Extension, ""); string[] tmp = ("..." + assemblyName).Split('.'); string objName = tmp[tmp.Length - 1]; dbProvider = (IDBProvider)Assembly.LoadFile(modulePath).CreateInstance(assemblyName + "." + objName); } if (dbProvider == null) { MessageBox.Show("数据访问实例创建失败。", "提示"); return; } dbProvider.Init(si.ServerIP, si.ServerPort, si.ServerInstance, si.GrantAccount, si.GrantPwd); string strErr = ""; IDbConnection dc = dbProvider.Open(ref strErr); if (dc == null) { MessageBox.Show("数据服务访问失败:" + strErr, "提示"); return; } //身份验证... IVerify verify = null; if (string.IsNullOrEmpty(si.AuthenticationWay.Trim()) || _allowThridVerify == false) { //未配置认证或不允许三方认证时,使用系统默认认证方式 if (_verifyDefault != null) { verify = _verifyDefault; } } else { modulePath = System.Windows.Forms.Application.StartupPath + @"\" + si.AuthenticationDirverFile; if (File.Exists(modulePath) == true) { FileInfo fiVerify = new FileInfo(modulePath); string assemblyName = fiVerify.Name.Replace(fiVerify.Extension, ""); string[] tmp = ("..." + assemblyName).Split('.'); string objName = tmp[tmp.Length - 1]; verify = (IVerify)Assembly.LoadFile(modulePath).CreateInstance(assemblyName + "." + objName); } else { MessageBox.Show("认证驱动文件不存在,暂不能登录。", "提示"); return; } } if (verify == null) { MessageBox.Show("认证对象不能实例化。", "提示"); return; } string attachInfo = ""; verify.Init(dbProvider); _loginUser = verify.StartVerify(txtUser.Text, txtPwd.Text, out attachInfo, out strErr); if (_loginUser == null) { if (string.IsNullOrEmpty(strErr) == false) { MessageBox.Show("认证失败:" + strErr, "提示"); } return; } _serverName = cbxServer.Text; _password = txtPwd.Text; _dbProvider = dbProvider; if (_businessVerify?.Invoke(_dbProvider, _loginUser) == false) { _dbProvider = null; _loginUser = null; _password = ""; _serverName = ""; return; } try { AppSetting.BatchBegin(); try { AppSetting.WriteSetting("loginserver", cbxServer.Text); AppSetting.WriteSetting("loginuser", txtUser.Text); } finally { AppSetting.BatchCommit(); } } catch (Exception ex) { MsgBox.ShowException(ex, this); } Close(); } catch (Exception ex) { MsgBox.ShowException(ex, this); } }
public bool ShowLogin(string command, IVerify defaultVerify, bool allowThirdVerify) { return(ShowLogin(command, defaultVerify, allowThirdVerify, null)); }
public bool ShowLogin(string command, IVerify defaultVerify) { return(ShowLogin(command, defaultVerify, true, null)); }
private void _Provider_Supply(IVerify obj) { obj.Login(_Account, _Password).OnValue += _Result; }
public bool ShowLogin(string command, IVerify defaultVerify, DelegateBusinessVerify businessVerify) { return(ShowLogin(command, defaultVerify, true, businessVerify)); }
public void Setup() { helper = new HMACSHA256Verify(); }
public PasswordCheckerService(IRepository repository, IVerify condition) { this.repository = repository ?? throw new ArgumentNullException($"Repository {nameof(repository)} has null value"); this.condition = condition ?? throw new ArgumentNullException($"Condition {nameof(repository)} has null value"); }
private void Button1_Click(object sender, EventArgs e) { IVerify verify = VerifierFactory.GetVerifier("normal"); MessageBox.Show(verify.Verify(nameTextbox.Text, passwordTextbox.Text) ? "登录成功!" : "登录失败!"); }