/// <summary> /// 通过加密密文获取原文 /// </summary> /// <param name="cipper">格式为md5(username){密文}{今天日期}</param> /// <param name="username"></param> /// <param name="cipperServices">获取密钥</param> /// <returns></returns> public static string FromCipperToString(this string cipper, string username, ICipperServices cipperServices) { try { string md5Str = username.ToMd5(); var rsa = new RsaHelper(RSAType.RSA2, Encoding.UTF8, cipperServices.PrivateKey, cipperServices.PublicKey); var decryptStr = rsa.Decrypt(cipper); if (decryptStr == null || decryptStr.Length <= md5Str.Length || DateTime.Now.ToString("yyyyMMdd") != decryptStr.Substring(0, 8) || decryptStr.Substring(decryptStr.Length - md5Str.Length, md5Str.Length) != md5Str) { return(null); } return(decryptStr.Substring(8, decryptStr.Length - 8 - md5Str.Length)); } catch (Exception) { throw new ActionStatusMessageException(ActionStatusMessage.Account.Auth.Invalid.CipperInvalid); } }
/// <summary> /// 账号管理 /// </summary> /// <param name="userManager"></param> /// <param name="signInManager"></param> /// <param name="emailSender"></param> /// <param name="logger"></param> /// <param name="usersService"></param> /// <param name="verifyService"></param> /// <param name="authService"></param> /// <param name="context"></param> /// <param name="currentUserService"></param> /// <param name="userActionServices"></param> /// <param name="cipperServices"></param> /// <param name="permissionServices"></param> public AccountController( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IEmailSender emailSender, ILogger <AccountController> logger, IUsersService usersService, IVerifyService verifyService, IGoogleAuthService authService, ApplicationDbContext context, ICurrentUserService currentUserService, IUserActionServices userActionServices, ICipperServices cipperServices, IPermissionServices permissionServices) { _userManager = userManager; _signInManager = signInManager; _emailSender = emailSender; _logger = logger; _usersService = usersService; _verifyService = verifyService; _authService = authService; _context = context; this.currentUserService = currentUserService; _userActionServices = userActionServices; this.cipperServices = cipperServices; this.permissionServices = permissionServices; }
/// <summary> /// /// </summary> /// <param name="configuration"></param> /// <param name="verifyService"></param> /// <param name="cipperServices"></param> public SystemStaticController(IConfiguration configuration, IVerifyService verifyService, ICipperServices cipperServices) { this.configuration = configuration; this._verifyService = verifyService; this.cipperServices = cipperServices; }