コード例 #1
0
        public int Update(SessionContext sessionContext, int id, SecurityParameter securityParameter)
        {
            try
            {
                if (!Helpers.IsInOrganizationContext(sessionContext, securityParameter.OrgId))
                {
                    return(0);
                }

                SecurityParameter savedSecurityParameter = _securityParameterRepository.Get(sessionContext, id);
                if (savedSecurityParameter != null)
                {
                    securityParameter.Id = id;
                    if (!savedSecurityParameter.Equals(securityParameter))
                    {
                        return(_securityParameterRepository.Update(securityParameter));
                    }
                }
                return(0);
            }
            catch (Exception ex)
            {
                _logger.LogException(new ExceptionLog
                {
                    ExceptionDate   = DateTime.Now,
                    ExceptionMsg    = ex.Message,
                    ExceptionSource = ex.Source,
                    ExceptionType   = "UserService",
                    FullException   = ex.StackTrace
                });
                return(0);
            }
        }
コード例 #2
0
        public int Insert(SecurityParameter securityParameter)
        {
            string query = @"Insert into [PasswordPolicy](MinCaps, MinSmallChars, MinSpecialChars, MinNumber, MinLength, AllowUserName, DisAllPastPassword, DisAllowedChars, ChangeIntervalDays, OrgId) 
                values (@MinCaps, @MinSmallChars, @MinSpecialChars, @MinNumber, @MinLength, @AllowUserName, @DisAllPastPassword, @DisAllowedChars, @ChangeIntervalDays, @OrgId)";

            using IDbConnection db = _connectionFactory.GetConnection;
            return(db.Execute(query, securityParameter));
        }
コード例 #3
0
        private void GetSecurityParameter()
        {
            SecurityParameter objSecurityParameter = new SecurityParameter();

            objSecurityParameter = objSecurityParameter.SecurityParameterGet();

            if (objSecurityParameter != null)
            {
                Session["PasswordExpireDate"] = objSecurityParameter.PasswordExpireDate;
                Session["FourEyePolicy"]      = objSecurityParameter.FourEyePolicy;
                Session["MaxLoginLimit"]      = objSecurityParameter.MaxLoginLimit;
            }
        }
コード例 #4
0
        public int Update(SecurityParameter updatedSecurityParameter)
        {
            string query = @"update [PasswordPolicy] Set 
                                MinCaps = @MinCaps, 
                                MinSmallChars = @MinSmallChars,
                                MinSpecialChars = @MinSpecialChars,
                                MinNumber = @MinNumber,
                                MinLength = @MinLength,
                                AllowUserName = @AllowUserName,
                                DisAllPastPassword = @DisAllPastPassword,
                                DisAllowedChars = @DisAllowedChars,
                                ChangeIntervalDays = @ChangeIntervalDays,
                                OrgId = @OrgId
                            Where Id = @Id";

            using IDbConnection db = _connectionFactory.GetConnection;
            return(db.Execute(query, updatedSecurityParameter));
        }
コード例 #5
0
ファイル: Heplers.cs プロジェクト: Rishirakish/OSDP
        public static RequestResult<bool> ValidatePassword(string password, SecurityParameter securityParameter)
        {
            List<ValidationMessage> validationMessages = new List<ValidationMessage>();
            
            if (password.Length < securityParameter.MinLength)
            {
                validationMessages.Add(new ValidationMessage {Reason = "Minimum length of the password should be " + securityParameter.MinLength + "characters long", Severity = ValidationSeverity.Error });
                return new RequestResult<bool>(false, validationMessages); ;
            }

            if (!ValidateMinimumSmallChars(password, securityParameter.MinSmallChars))
            {
                validationMessages.Add(new ValidationMessage { Reason = "Minimum number of small characters the password should have is " + securityParameter.MinSmallChars, Severity = ValidationSeverity.Error });
                return new RequestResult<bool>(false, validationMessages); ;
            }

            if (!ValidateMinimumCapsChars(password, securityParameter.MinCaps))
            {
                validationMessages.Add(new ValidationMessage { Reason = "Minimum number of capital characters the password should have is " + securityParameter.MinCaps, Severity = ValidationSeverity.Error });
                return new RequestResult<bool>(false, validationMessages); ;
            }

            if (!ValidateMinimumDigits(password, securityParameter.MinNumber))
            {
                validationMessages.Add(new ValidationMessage { Reason = "Minimum number of numeric characters the password should have is " + securityParameter.MinNumber, Severity = ValidationSeverity.Error });
                return new RequestResult<bool>(false, validationMessages); ;
            }

            if (!ValidateMinimumSpecialChars(password, securityParameter.MinSpecialChars))
            {
                validationMessages.Add(new ValidationMessage { Reason = "Minimum number of special characters the password should have is " + securityParameter.MinSpecialChars, Severity = ValidationSeverity.Error });
                return new RequestResult<bool>(false, validationMessages); ;
            }

            if (!ValidateDisallowedChars(password, securityParameter.DisAllowedChars))
            {
                validationMessages.Add(new ValidationMessage { Reason = "Characters which are not allowed in password are " + securityParameter.DisAllowedChars, Severity = ValidationSeverity.Error });
                return new RequestResult<bool>(false, validationMessages); ;
            }

            return new RequestResult<bool>(true);
        }
コード例 #6
0
 public int Insert(SessionContext sessionContext, SecurityParameter securityParameter)
 {
     try
     {
         if (!Helpers.IsInOrganizationContext(sessionContext, securityParameter.OrgId))
         {
             return(0);
         }
         return(_securityParameterRepository.Insert(securityParameter));
     }
     catch (Exception ex)
     {
         _logger.LogException(new ExceptionLog
         {
             ExceptionDate   = DateTime.Now,
             ExceptionMsg    = ex.Message,
             ExceptionSource = ex.Source,
             ExceptionType   = "UserService",
             FullException   = ex.StackTrace
         });
         return(0);
     }
 }
コード例 #7
0
        public int GetNumericValue(string name)
        {
            SecurityParameter parameter = CurrentParameters.FirstOrDefault(i => i.Name == name);

            return(parameter == null ? 0 : parameter.NumericValue);
        }
コード例 #8
0
        public bool GetBoolValue(string name)
        {
            SecurityParameter parameter = CurrentParameters.FirstOrDefault(i => i.Name == name);

            return(parameter == null ? false : parameter.BoolValue);
        }
コード例 #9
0
        public string GetValue(string name)
        {
            SecurityParameter parameter = CurrentParameters.FirstOrDefault(i => i.Name == name);

            return(parameter == null ? "" : parameter.Value);
        }