Ejemplo n.º 1
0
    public string GetSm3Digest(string id)
    {
        IDigestEncryptionService     Iservice = Miic.Cryptographic.SM3.Sm3Service.Instance;
        IAsymmetricEncryptionService IasymmetricEncryptionService = Sm2Service.Instance;
        string result = Iservice.Encrypt(id);

        return(result);
    }
Ejemplo n.º 2
0
    public string ModifyPassword(PasswordView passwordView, bool isEmail)
    {
        string result   = string.Empty;
        string MailType = "Miic.Config.email.xml";
        string message  = string.Empty;

        try
        {
            if (!string.IsNullOrEmpty(passwordView.NewPassword))
            {
                if (!string.IsNullOrEmpty(UserID))
                {
                    MiicSocialUserInfo miicSocialUserInfo = ImiicSocialUser.GetInformation(UserID);
                    miicSocialUserInfo.Password = passwordView.NewPassword;
                    //添加MD5加密密码
                    miicSocialUserInfo.SM3Password = passwordView.Sm3;
                    bool temp = ImiicSocialUser.Update(new MiicSocialUserInfo()
                    {
                        ID          = miicSocialUserInfo.ID,
                        Password    = miicSocialUserInfo.Password,
                        SM3Password = miicSocialUserInfo.SM3Password
                    });


                    OAService.UserService    service = new OAService.UserService();
                    IDigestEncryptionService IdigestEncryptionService = Md5Service.Instance;
                    bool synchroOa = service.SynchroUserInfo(new OAService.UserInfo()
                    {
                        ID       = miicSocialUserInfo.ID,
                        Password = miicSocialUserInfo.Password,
                        Md5      = IdigestEncryptionService.Encrypt(IdigestEncryptionService.Encrypt(miicSocialUserInfo.Password))
                    });

                    if (temp == true && synchroOa == true)
                    {
                        if (isEmail == true)
                        {
                            bool      tempEmail = false;
                            string    content   = "尊敬的用户" + miicSocialUserInfo.SocialCode + "您好:您的" + Config.AppName + "账户密码已经修改,账号为:" + miicSocialUserInfo.SocialCode + ";新密码为:" + miicSocialUserInfo.Password + ",感谢您的支持,谢谢!";
                            MiicEmail email     = new MiicEmail(Config.AppName, "*****@*****.**", miicSocialUserInfo.Email, "找回密码", content);
                            email.Priority = MailPriority.High;
                            Reflection    reflection = new Reflection();
                            Assembly      a          = Assembly.LoadFrom(HttpContext.Current.Server.MapPath("/Bin/MiicLibrary.dll"));
                            Stream        stream     = a.GetManifestResourceStream(MailType);
                            IEmailService Iemail     = reflection.initInterface <IEmailService>(stream, "01");
                            tempEmail = Iemail.SendMail(email, out message);
                            if (tempEmail == true)
                            {
                                result = Config.Serializer.Serialize(new { result = true, message = "您的密码修改成功,请查阅您的Email" });
                            }
                            else
                            {
                                result = Config.Serializer.Serialize(new { result = true, message = "您的密码修改成功,Email发送失败" });
                            }
                        }
                        else
                        {
                            result = Config.Serializer.Serialize(new { result = true, message = "您的密码修改成功" });
                        }
                    }
                    else
                    {
                        result = Config.Serializer.Serialize(new { result = false, message = "您的密码修改失败" });
                    }
                }
                else
                {
                    throw new MiicCookieArgumentNullException("UserID失效!");
                }
            }
            else
            {
                throw new ArgumentNullException("新密码为空!");
            }
        }
        catch (Exception ex)
        {
            Config.IlogicLogService.Write(new LogicLog()
            {
                AppName       = Config.AppName,
                ClassName     = ClassName,
                NamespaceName = NamespaceName,
                MethodName    = MethodBase.GetCurrentMethod().Name,
                Message       = ex.Message,
                Oper          = Config.Oper
            });
        }
        return(result);
    }