Exemplo n.º 1
0
 public bool IsValid(out string errorMessage)
 {
     errorMessage = null;
     if (SecretKeyV3.IsDefaultKeyName(this.Name))
     {
         if (this.Permissions != SecretKeyPermissions.Full)
         {
             errorMessage = string.Format("SecretKeys: default keys must have full permissions instead of {0}", this.Permissions.ToString());
             return(false);
         }
         if (!SecretKeyValidator.IsKeyValueLengthValid(this.Value, out errorMessage, 16, 256))
         {
             return(false);
         }
         return(true);
     }
     if (!SecretKeyValidator.IsKeyNameLengthValid(this.Name, out errorMessage, 5, 20))
     {
         return(false);
     }
     if (!SecretKeyValidator.IsKeyNameLowerCaseAlphaNumeric(this.Name, out errorMessage))
     {
         return(false);
     }
     if (!SecretKeyValidator.IsKeyValueLengthValid(this.Value, out errorMessage, 16, 256))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
        public bool HasValidValues(out string errorMessage)
        {
            int num  = 0;
            int num1 = 0;

            foreach (SecretKeyV3 secretKeyV3 in this)
            {
                if (!secretKeyV3.IsDefault())
                {
                    num1++;
                }
                else
                {
                    num++;
                }
            }
            if (num < 1)
            {
                errorMessage = string.Format("At least {0} default secret key(s) need to be specified. Found {1} secret keys.", 1, num);
                return(false);
            }
            if (num > 2)
            {
                errorMessage = string.Format("At most {0} default secret key(s) are allowed. Found {1} secret keys.", 2, num);
                return(false);
            }
            if (num1 <= 4)
            {
                if (!SecretKeyValidator.ContainsUniqueKeyNames(this, out errorMessage))
                {
                    return(false);
                }
                return(true);
            }
            errorMessage = string.Format("At most {0} custom secret key(s) are allowed. Found {1} secret keys.", 4, num1);
            return(false);
        }