Example #1
0
        public bool CanChangePassword(VaultParams vaultParams)
        {
            if (!Vault.Exists())
            {
                return(false);
            }

            if (null == vaultParams.Password ||
                vaultParams.Password.Length <= 0)
            {
                return(false);
            }

            if (null == vaultParams.ValidationPassword ||
                vaultParams.ValidationPassword.Length <= 0)
            {
                return(false);
            }

            if (!SecureStringExtension.Equals(vaultParams.Password, vaultParams.ValidationPassword))
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        public bool CanCreateVault(VaultParams vaultParams)
        {
            if (null == vaultParams)
            {
                return(false);
            }

            if (string.IsNullOrWhiteSpace(vaultParams.FilePath))
            {
                return(false);
            }

            //if (!Uri.IsWellFormedUriString("file:///" + vaultParams.FilePath.Replace("\\", "/"), UriKind.Absolute))
            //{
            //    return false;
            //}

            if (string.IsNullOrWhiteSpace(vaultParams.Name))
            {
                return(false);
            }

            if (null == vaultParams.Password || null == vaultParams.ValidationPassword)
            {
                return(false);
            }

            if (!SecureStringExtension.Equals(vaultParams.Password, vaultParams.ValidationPassword))
            {
                return(false);
            }

            return(true);
        }
Example #3
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            if (!(value is SecureString))
            {
                return(new ValidationResult(false, "This value is not a SecureString"));
            }

            if (null == ValidationPassword || null == value)
            {
                return(new ValidationResult(false, "Password is required"));
            }

            if (!SecureStringExtension.Equals(value as SecureString, ValidationPassword))
            {
                return(new ValidationResult(false, "Passwords do not match"));
            }

            return(ValidationResult.ValidResult);
        }