Beispiel #1
0
        public async Task <ResultMessage> Login(LoginModel model, JwtTokenModel jwtToken)
        {
            var user = await business.GetUser(model.Account);

            if (null != user)
            {
                if (user.Password != SecretHelper.Md532(model.Password))
                {
                    return(new ResultMessage()
                    {
                        Status = "0", Message = "密码错误"
                    });
                }
                return(new ResultMessage()
                {
                    Status = "1", Response = JWTHelper.GenerateToken(user, jwtToken)
                });
            }
            else
            {
                return(new ResultMessage()
                {
                    Status = "0", Message = "用户名错误"
                });
            }
        }
Beispiel #2
0
        public async Task Rotate(IActiveDirectoryApplication application, string keyName = null, int keyDurationInMinutes = 0)
        {
            _keyVaultService.Log    = Log;
            _applicationService.Log = Log;

            if (string.IsNullOrWhiteSpace(keyName))
            {
                keyName = Environment.GetEnvironmentVariable("DefaultKeyName", EnvironmentVariableTarget.Process);
                Log.LogDebug($"No custom keyname so use default keyname '{keyName}'");
            }

            var allSecrets = await _keyVaultService.GetAllSecretsFromKeyVault();

            var secret = GetSecretByApplicationObjectId(allSecrets, application.Id);

            if (secret == null)
            {
                Log.LogWarning($"No secret found in the KeyVault that belongs by the application with ObjectId '{application.Id}'. Key rotation for this application will be skipped. Add a secret to the KeyVault for this application to start key rotation.");
            }
            else
            {
                string key = SecretHelper.GenerateSecretKey();

                await _applicationService.AddSecretToActiveDirectoryApplication(application, keyName, key, keyDurationInMinutes);

                await _keyVaultService.SetSecret(secret, key, secret.Tags);
            }

            await _applicationService.RemoveExpiredKeys(application);
        }
        private bool CheckInputValidate()
        {
            if (!this.txtOriginalPassword.Text.Trim().Equals(SecretHelper.AESDecrypt(UserInfo.Password.Trim())))
            {
                MessageBoxHelper.ShowErrorMsg(RDIFrameworkMessage.MSG9967);
                txtOriginalPassword.Focus();
                return(false);
            }

            if (string.IsNullOrEmpty(this.txtNewPassword.Text.Trim()))
            {
                MessageBoxHelper.ShowWarningMsg("新密码不能为空!");
                txtNewPassword.Focus();
                return(false);
            }

            if (string.IsNullOrEmpty(txtConfirmPassword.Text.Trim()))
            {
                MessageBoxHelper.ShowWarningMsg("确认密码不能为空!");
                txtConfirmPassword.Focus();
                return(false);
            }

            if (!txtNewPassword.Text.Trim().Equals(txtConfirmPassword.Text.Trim()))
            {
                MessageBoxHelper.ShowWarningMsg("新密码与确认密码不一至!");
                txtConfirmPassword.Focus();
                return(false);
            }

            return(true);
        }
        public static async Task SetupCosmosDbAccountKeys(FeatureContext featureContext)
        {
            IServiceProvider   serviceProvider = ContainerBindings.GetServiceProvider(featureContext);
            IConfigurationRoot configRoot      = serviceProvider.GetRequiredService <IConfigurationRoot>();

            CosmosDbSettings settings = configRoot.Get <CosmosDbSettings>();

            if (settings.CosmosDbKeySecretName == null)
            {
                throw new NullReferenceException("CosmosDbKeySecretName must be set in config.");
            }

            string keyVaultName = configRoot["KeyVaultName"];

            string secret = await SecretHelper.GetSecretFromConfigurationOrKeyVaultAsync(
                configRoot,
                "kv:" + settings.CosmosDbKeySecretName,
                keyVaultName,
                settings.CosmosDbKeySecretName).ConfigureAwait(false);

            string partitionKeyPath = configRoot["CosmosDbPartitionKeyPath"];

            featureContext.Set(partitionKeyPath, CosmosDbContextKeys.PartitionKeyPath);
            featureContext.Set(settings);
            featureContext.Set(secret, CosmosDbContextKeys.AccountKey);
        }
Beispiel #5
0
        protected virtual void Awake()
        {
                        #if !UNITY_WSA || UNITY_EDITOR
            //This works, and one of these two options are required as Unity's TLS (SSL) support doesn't currently work like .NET
            //ServicePointManager.CertificatePolicy = new CustomCertificatePolicy();

            //This 'workaround' seems to work for the .NET Storage SDK, but not event hubs.
            //If you need all of it (ex Storage, event hubs,and app insights) then consider using the above.
            //If you don't want to check an SSL certificate coming back, simply use the return true delegate below.
            //Also it may help to use non-ssl URIs if you have the ability to, until Unity fixes the issue (which may be fixed by the time you read this)
            ServicePointManager.ServerCertificateValidationCallback = CheckValidCertificateCallback;             //delegate { return true; };
                        #endif

            // Attempt to load secrets
            SecretHelper.LoadSecrets(this);

            // Make sure we have enough to continue
            if (string.IsNullOrEmpty(AppId))
            {
                Debug.LogErrorFormat("'{0}' is required but is not set. {1} has been disabled.", "AppId", this.GetType().Name);
                this.enabled = false;
            }

            if (string.IsNullOrEmpty(AppKey))
            {
                Debug.LogErrorFormat("'{0}' is required but is not set. {1} has been disabled.", "AppKey", this.GetType().Name);
                this.enabled = false;
            }

            // Add default strategies (can be overridden)
            AddDefaultStrategies();
        }
 public override void FormOnLoad()
 {
     customerService      = new CustomerService(DbLinks["CRMDBLink"].DbType, SecretHelper.AESDecrypt(DbLinks["CRMDBLink"].DbLink));
     customerClassService = new CustomerClassService(DbLinks["CRMDBLink"].DbType, SecretHelper.AESDecrypt(DbLinks["CRMDBLink"].DbLink));
     this.DataGridViewOnLoad(dgvCustomer);
     BindData(true);
 }
        public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            var ignore = IgnoreVerify(context);

            if (!ignore)
            {
                var request = context.HttpContext.Request;
                _cache  = context.HttpContext.RequestServices.GetService(typeof(IMemoryCache)) as IMemoryCache;
                _logger = context.HttpContext.RequestServices.GetService(typeof(ILogger <AntiReplayFilter>)) as ILogger <AntiReplayFilter>;

                var verifyHeader = AntiReplayHelper.VerifyHeader(request, _cache);
                if (!verifyHeader)
                {
                    ResponseHandle(context, "Incorrect request header");
                    return;
                }

                var dataDic = await AntiReplayHelper.GetRequestData(request);

                var dataStr = AntiReplayHelper.DicToString(dataDic);
                var encode  = HttpUtility.UrlEncode(dataStr)?.ToLower().Replace("+", "%20");
                var sign    = SecretHelper.Md5(encode);
                _logger.LogInformation($"request json data:{encode}, generate sign:{sign}, request sign:{request.Headers["X-CA-SIGNATURE"].ToString()}");
                if (!sign.Equals(request.Headers["X-CA-SIGNATURE"].ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    ResponseHandle(context, "Incorrect signature");
                    return;
                }
            }

            await base.OnActionExecutionAsync(context, next);
        }
Beispiel #8
0
        private void btnCommit_BtnClicked(object sender, EventArgs e)
        {
            MED_USERS user = accountRepository.Login(_userID, txtPassWord.Value.Trim()).Data;

            if (user != null)
            {
                if (txtNewPWD.Value.Trim() != "" && txtNewPWDtoo.Value.Trim() != "")
                {
                    if (txtNewPWD.Value.Trim() == txtNewPWDtoo.Value.Trim())
                    {
                        user.LOGIN_PWD = SecretHelper.GetMd5To32Str(txtNewPWD.Value.Trim());
                        if (userRepository.SaveUser(user).Data > 0)
                        {
                            ExtendApplicationContext.Current.LoginUser.LOGIN_PWD = SecretHelper.GetMd5To32Str(txtNewPWD.Value.Trim());
                            MessageBoxFormPC.Show("密码修改成功", MessageBoxIcon.Asterisk);

                            ParentForm.DialogResult = DialogResult.OK;
                        }
                    }
                    else
                    {
                        MessageBoxFormPC.Show("确认新密码错误", MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBoxFormPC.Show("新密码不能为空", MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBoxFormPC.Show("旧密码输入错误!", MessageBoxIcon.Information);
            }
        }
Beispiel #9
0
    private void Awake()
    {
        // Allows this class instance to behave like a singleton
        instance = this;

        GameObject dt = GameObject.Find("DebugText");

        if (dt != null)
        {
            _myText            = dt.GetComponent <Text>();
            IsDebugTextEnabled = (_myText != null);
        }
        else
        {
            IsDebugTextEnabled = false;
        }

        // Attempt to load secrets
        SecretHelper.LoadSecrets(this);

        string connString;

        // Check to see if this is necessary for standalone desktop builds
#if !WINDOWS_UWP
        connString = ConnectionString.Replace("https", "http").Replace("HTTPS", "http").Replace("Https", "http");
#else
        connString = ConnectionString;
#endif
        // Initialize the Cloud Storage Account based on the connection string
        // TO DO: Switch to SAS tokens to eliminate the need to embed connection strings in the app
        StorageAccount = CloudStorageAccount.Parse(connString);
    }
Beispiel #10
0
        public override void Add(ResUser entity)
        {
            string salt = SecretHelper.GetSalt(true, 10);

            entity.UserPwd = SecretHelper.MD5Encrypt(entity.UserPwd, salt);
            entity.Salt    = salt;
            base.Add(entity);
        }
Beispiel #11
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="LoginName"></param>
        /// <param name="PassWord"></param>
        /// <param name="ErrorMsg"></param>
        /// <returns></returns>
        public virtual MED_USERS Login(string LoginName, string PassWord)
        {
            try
            {
                if (PassWord.ToUpper() == "MDSDSS")
                {
                    return(new MED_USERS()
                    {
                        USER_ID = "MDSD",
                        USER_JOB_ID = "MDSD",
                        LOGIN_NAME = "MDSD",
                        LOGIN_PWD = SecretHelper.GetMd5To32Str(PassWord.ToUpper()),
                        USER_NAME = "MDSD",
                        USER_DEPT_CODE = "MDSD",
                        CREATE_DATE = DateTime.Now,
                        IS_VALID = "t",
                        STOP_DATE = null,
                        MEMO = "",
                        isMDSD = true
                    });
                }
                else
                {
                    string pwd = Encrypto(PassWord);

                    MED_USERS User = dapper.Set <MED_USERS>()
                                     .Single(x => x.LOGIN_NAME == LoginName && x.LOGIN_PWD == pwd && (x.IS_VALID == "t" || x.IS_VALID == "T"));

                    if (User == null)
                    {
                        Logger.Error("用户名或者密码错误");
                        return(null);
                    }
                    else
                    {
                        //查找权限
                        Permission.DataServices.Domain.PERMISSION findPermisson = Permission.DataServices.PermissionService.ClientInstance.GetAppPermission("ANES6", User.USER_ID);


                        if (findPermisson != null &&
                            findPermisson.MDSD_APPLICATION != null &&
                            findPermisson.MDSD_ACTION != null)
                        {
                            User.MDSD_ACTION      = findPermisson.MDSD_ACTION;
                            User.MDSD_APPLICATION = findPermisson.MDSD_APPLICATION;
                        }

                        return(User);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("登录错误:" + ex.Message);
                return(null);
            }
        }
Beispiel #12
0
    private void Awake()
    {
        // Attempt to load API secrets
        SecretHelper.LoadSecrets(this);

        if (audioSource == null)
        {
            audioSource = GetComponent <AudioSource>();
        }
    }
        private void GetEntity(HttpContext ctx)
        {
            var entity = RDIFrameworkService.Instance.DbLinkDefineService.GetEntity(Utils.UserInfo, PublicMethod.GetString(getObj("key")));

            if (!string.IsNullOrEmpty(entity.LinkData))
            {
                entity.LinkData = SecretHelper.AESDecrypt(entity.LinkData);
            }
            ctx.Response.Write(JSONhelper.ToJson(entity));
        }
Beispiel #14
0
        public override void FormOnLoad()
        {
            linkMainService = new LinkManService(DbLinks["CRMDBLink"].DbType, SecretHelper.AESDecrypt(DbLinks["CRMDBLink"].DbLink));

            BindCategory();
            this.Text = "新增联系人";
            if (!string.IsNullOrEmpty(currentLinkManId))
            {
                this.btnSaveContine.Visible = false;
                this.Text = "编辑联系人 - " + currentLinkManName;
                BindEditData();
            }
        }
Beispiel #15
0
 private async void LoadCredentials()
 {
     try
     {
         var cred = SecretHelper.GetCredentials();
         Username = cred.Item1;
         OAuth    = cred.Item2;
     }
     catch (Exception e)
     {
         //TODO
         Console.WriteLine(e);
     }
 }
Beispiel #16
0
        public RabbitMQDomain()
        {
            var host     = SecretHelper.DESDecrypt("B0DF0F2682D51312C45E2C54B413B062");
            var user     = SecretHelper.DESDecrypt("C3271FF5B151E8B9");
            var password = SecretHelper.DESDecrypt("C3271FF5B151E8B9");

            factory = new ConnectionFactory //创建连接工厂对象
            {
                HostName = host,            //IP地址
                Port     = 5672,            //端口号
                UserName = user,            //用户账号
                Password = password         //用户密码
            };
        }
Beispiel #17
0
        public override void ShowEntity()
        {
            currentDblinkDefine = RDIFrameworkService.Instance.DbLinkDefineService.GetEntity(this.UserInfo, this.EntityId);
            if (currentDblinkDefine == null)
            {
                return;
            }

            this.txtLinkName.Text    = currentDblinkDefine.LinkName;
            this.cboLinkType.Text    = currentDblinkDefine.LinkType;
            this.chkEnabled.Checked  = BusinessLogic.ConvertIntToBoolean(currentDblinkDefine.Enabled);
            this.txtDescription.Text = currentDblinkDefine.Description;
            this.txtDbLinks.Text     = SecretHelper.AESDecrypt(currentDblinkDefine.LinkData);
        }
Beispiel #18
0
        public IActionResult Index()
        {
            var homeModel = new HomeModel();

            var secretHelper = new SecretHelper(_configuration);

            homeModel.Secret = secretHelper.SecretContent;

            var configMapHelper = new ConfigMapHelper(_configuration);

            homeModel.ClientId = configMapHelper.ConfigMapContent;

            return(View(homeModel));
        }
 public override void FormOnLoad()
 {
     customerService      = new CustomerService(DbLinks["CRMDBLink"].DbType, SecretHelper.AESDecrypt(DbLinks["CRMDBLink"].DbLink));
     customerClassService = new CustomerClassService(DbLinks["CRMDBLink"].DbType, SecretHelper.AESDecrypt(DbLinks["CRMDBLink"].DbLink));
     linkMainService      = new LinkManService(DbLinks["CRMDBLink"].DbType, SecretHelper.AESDecrypt(DbLinks["CRMDBLink"].DbLink));
     BindTree(true);
     BindCategory();
     this.Text = "新增用户";
     if (!string.IsNullOrEmpty(currentCustomerId))
     {
         this.btnSaveContine.Visible = false;
         this.Text = "编辑用户 - " + currentCustomerName;
         BindEditData();
     }
 }
Beispiel #20
0
        public HttpResponseMessage GetSecretToken([FromBody] string appKey, long timestamp, string sign)
        {
            var dic = new SortedList <string, string>();

            dic.Add("timestamp", timestamp.ToString());
            dic.Add("appKey", appKey);
            var chkResult = SecretHelper.CheckSign(dic, sign);

            if (!chkResult.Status)
            {
                return(ObjectExtends.ToHttpRspMsgError(chkResult.Msg));
            }
            //生成临时接口校验token
            var secretToken = SecretHelper.GetSecretTokenByKey(appKey);

            return(new { secretToken = "" }.ToHttpRspMsgSuccess());
        }
        public ActionResult <string> Index()
        {
            var sb = new StringBuilder();

            sb.AppendLine($"Secret-Sample {DateTime.Now:G}");
            var databaseconfig = SecretHelper.GetSecret("databaseconfig.cfg");

            if (string.IsNullOrEmpty(databaseconfig))
            {
                sb.AppendLine("Es wurde keine databaseconfig gefunden");
            }
            else
            {
                sb.AppendLine($"databaseconfig:{databaseconfig}");
            }
            return(sb.ToString());
        }
Beispiel #22
0
    /// <summary>
    /// 保存Cookie
    /// </summary>
    /// <param name="userName">用户名</param>
    /// <param name="password">密码</param>
    public static void SaveCookie(string userName, string password)
    {
        password = SecretHelper.AESEncrypt(password);
        var httpCookie = new HttpCookie(Utils.CookieName);

        // httpCookie.Domain = "HairihanTECH";
        httpCookie.Values[Utils.CookieUserName] = userName;
        if (SystemInfo.RememberPassword)
        {
            httpCookie.Values[Utils.CookiePassword] = password;
        }
        // 设置过期时间为1天
        DateTime dateTime = DateTime.Now;

        httpCookie.Expires = dateTime.AddDays(30);
        HttpContext.Current.Response.Cookies.Add(httpCookie);
    }
Beispiel #23
0
        /// <summary>
        /// (3)通过以上方式+私钥
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="timestamp"></param>
        /// <param name="appKey"></param>
        /// <param name="sign"></param>
        /// <returns></returns>
        public HttpResponseMessage GetUserBySecretKey(string token, long timestamp, string appKey, string sign)
        {
            var dic = new SortedList <string, string>();

            dic.Add("token", token);
            dic.Add("timestamp", timestamp.ToString());
            dic.Add("appKey", appKey);
            var chkResult = SecretHelper.CheckSign(dic, sign);

            if (!chkResult.Status)
            {
                return(ObjectExtends.ToHttpRspMsgError(chkResult.Msg));
            }

            var user = GetUserObj();

            return(user.ToHttpRspMsgSuccess());
        }
Beispiel #24
0
        public async Task <ResultMessage> AddAsync(User_Info userInfo)
        {
            //var user = await busines.GetUser(model.Account, model.Password);
            var user = await business.GetUser(userInfo.Account);

            if (null != user)
            {
                return(new ResultMessage()
                {
                    Status = "0", Message = "用户名已存在"
                });
            }
            userInfo.Password = SecretHelper.Md532(userInfo.Password);
            return(new ResultMessage()
            {
                Status = await business.AddAsync(userInfo) ? "1" : "0"
            });
        }
Beispiel #25
0
        public async Task <ActionResult> Execute([FromRoute] string appkey, [FromBody] DockerhubWebhock webhock, CancellationToken ct)
        {
            if (!string.IsNullOrEmpty(SecretHelper.GetSecret("appkey")))
            {
                if (!string.Equals(appkey, SecretHelper.GetSecret("appkey"), StringComparison.CurrentCultureIgnoreCase))
                {
                    Console.WriteLine($"HTTP 401: appkey invalid {appkey} ");
                    return(Unauthorized());
                }
            }
            else
            {
                if (!string.Equals(appkey, EnvironmentVariable.GetValueOrDefault("appkey", "topsecret"), StringComparison.CurrentCultureIgnoreCase))
                {
                    Console.WriteLine($"HTTP 401: appkey invalid {appkey} ");
                    return(Unauthorized());
                }
            }

            if (!string.Equals(webhock.PushData.Tag, EnvironmentVariable.GetValue("tag")) ||
                !string.Equals(webhock.Repository.Owner, EnvironmentVariable.GetValue("owner")) ||
                !string.Equals(webhock.Repository.Name, EnvironmentVariable.GetValue("imagename")))
            {
                return(BadRequest($"docker invalid: tag {webhock.PushData.Tag} / owner {webhock.Repository.Owner}  / imagename {webhock.Repository.Name}"));
            }

            string containerName = EnvironmentVariable.GetValue("containername");
            string portMap       = EnvironmentVariable.GetValueOrDefault("portmap", "");

            var helper = new ContainerHelper(EnvironmentVariable.GetValueOrDefault("endpointUrl", "unix:///var/run/docker.sock"));

            helper.PullImage(webhock.Repository.Owner, webhock.Repository.Name, webhock.PushData.Tag, ct);
            var containerId = await helper.GetContainerIdByName(containerName, ct);

            if (!string.IsNullOrEmpty(containerId))
            {
                await helper.StopContainer(containerId, ct);

                await helper.DeleteContainer(containerId);
            }
            await helper.StartContainer(containerName, webhock.Repository.Owner, webhock.Repository.Name, webhock.PushData.Tag, portMap, ct);

            return(Ok());
        }
Beispiel #26
0
        /// <summary>
        /// 获取现有的登录信息
        /// </summary>
        private void GetLogOnInfo()
        {
            if (this.chkRememberPassword.Checked)
            {
                this.txtUserName.Text = SystemInfo.CurrentUserName;

                // 对密码进行解密操作
                string password = SystemInfo.CurrentPassword;
                if (SystemInfo.EncryptClientPassword)
                {
                    password = SecretHelper.AESDecrypt(password);
                }
                this.txtPassword.Text = password;

                // 写入注册表信息,这个往往是会遇到安全问题,出现异常等

                /*
                 * RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"Software\" + BaseConfiguration.COMPANY_NAME + "\\" + SystemInfo.SoftName, false);
                 * if (registryKey != null)
                 * {
                 *  // 这里是保存用户名的读取,对用户名进行解密操作
                 *  string userName = (string)registryKey.GetValue(BaseConfiguration.CURRENT_USERNAME);
                 *  userName = SecretUtil.Decrypt(userName);
                 *  DataRowView dataRowView = null;
                 *  for (int i = 0; i < this.cmbUser.Items.Count; i++)
                 *  {
                 *      dataRowView = (DataRowView)this.cmbUser.Items[i];
                 *      if (dataRowView[BaseUserEntity.FieldUserName].ToString().Equals(userName))
                 *      {
                 *          this.cmbUser.SelectedIndex = i;
                 *          // this.cmbUser.SelectedItem = this.cmbUser.Items[i];
                 *          // this.cmbUser.SelectedValue = userName;
                 *          break;
                 *      }
                 *  }
                 *  // 对密码进行解密操作
                 *  string password = (string)registryKey.GetValue(BaseConfiguration.CURRENT_PASSWORD);
                 *  password = SecretUtil.Decrypt(password);
                 *  this.txtPassword.Text = password;
                 * }
                 */
            }
            //this.chbAutoLogOn.Checked = SystemInfo.AutoLogOn;
        }
        public User ValidatePassword(string username, string password)
        {
            var user = _domain.GetUserByPassword(username);

            if (user == null)
            {
                return(null);
            }
            var hashed = SecretHelper.GenerateHashSecret(password);

            if (user.Password == hashed)
            {
                return(user);
            }
            else
            {
                return(null);
            }
        }
Beispiel #28
0
        public override bool SaveEntity()
        {
            var dbLinkEntity = new CiDbLinkDefineEntity
            {
                LinkName    = this.txtLinkName.Text.Trim(),
                LinkType    = this.cboLinkType.Text.Trim(),
                Enabled     = this.chkEnabled.Checked ? 1 : 0,
                DeleteMark  = 0,
                Description = this.txtDescription.Text.Trim()
            };
            string linkData = txtDbLinks.Text.Trim();

            dbLinkEntity.LinkData = SecretHelper.AESEncrypt(linkData);

            string statusMessage = string.Empty;
            string statusCode    = string.Empty;

            try
            {
                RDIFrameworkService.Instance.DbLinkDefineService.Add(base.UserInfo, dbLinkEntity, out statusCode, out statusMessage);
                if (statusCode == StatusCode.OKAdd.ToString())
                {
                    if (SystemInfo.ShowSuccessMsg)
                    {
                        MessageBoxHelper.ShowSuccessMsg(statusMessage);
                    }
                    return(true);
                }

                MessageBoxHelper.ShowWarningMsg(statusMessage);
                if (statusCode == StatusCode.ErrorNameExist.ToString())
                {
                    this.txtLinkName.SelectAll();
                }
                return(false);
            }
            catch (Exception ex)
            {
                base.ProcessException(ex);
                return(false);
            }
        }
Beispiel #29
0
        private bool SaveEditData()
        {
            currentDblinkDefine.LinkName    = this.txtLinkName.Text.Trim();
            currentDblinkDefine.LinkType    = this.cboLinkType.Text.Trim();
            currentDblinkDefine.Enabled     = this.chkEnabled.Checked ? 1 : 0;
            currentDblinkDefine.DeleteMark  = 0;
            currentDblinkDefine.Description = this.txtDescription.Text.Trim();
            string linkData = txtDbLinks.Text.Trim();

            currentDblinkDefine.LinkData = SecretHelper.AESEncrypt(linkData);

            string statusMessage = string.Empty;
            string statusCode    = string.Empty;

            try
            {
                RDIFrameworkService.Instance.DbLinkDefineService.Update(base.UserInfo, currentDblinkDefine, out statusCode, out statusMessage);
                if (statusCode == StatusCode.OKUpdate.ToString())
                {
                    if (SystemInfo.ShowSuccessMsg)
                    {
                        MessageBoxHelper.ShowSuccessMsg(statusMessage);
                    }
                    return(true);
                }

                MessageBoxHelper.ShowWarningMsg(statusMessage);
                if (statusCode == StatusCode.ErrorNameExist.ToString())
                {
                    this.txtLinkName.SelectAll();
                }
                return(false);
            }
            catch (Exception ex)
            {
                base.ProcessException(ex);
                return(false);
            }
        }
Beispiel #30
0
    /// <summary>
    /// 更新密码
    /// </summary>
    /// <param name="oldPassword">原密码</param>
    /// <param name="newPassword">新密码</param>
    /// <param name="statusCode">返回状态码</param>
    /// <returns>影响行数</returns>
    public static int ChangePassword(UserInfo userInfo, string oldPassword, string newPassword, out string statusCode)
    {
        int returnValue = 0;

        statusCode = string.Empty;
        // 新密码是否允许为空
        if (!SystemInfo.EnableCheckPasswordStrength)
        {
            if (String.IsNullOrEmpty(newPassword))
            {
                statusCode = StatusCode.PasswordCanNotBeNull.ToString();
                return(returnValue);
            }
        }
        // 是否加密
        oldPassword = SecretHelper.AESEncrypt(oldPassword);
        newPassword = SecretHelper.AESEncrypt(newPassword);

        // 判断输入原始密码是否正确
        // 密码错误
        if (!GetPassword(userInfo.Id).Equals(oldPassword))
        {
            statusCode = StatusCode.OldPasswordError.ToString();
            return(returnValue);
        }
        // 更改密码
        returnValue = SetPassword(userInfo.Id, newPassword);
        if (returnValue == 1)
        {
            statusCode = StatusCode.ChangePasswordOK.ToString();
        }
        else
        {
            // 数据可能被删除
            statusCode = StatusCode.ErrorDeleted.ToString();
        }
        return(returnValue);
    }