示例#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);
 }
示例#2
0
        internal static bool ContainsUniqueKeyNames(SecretKeyListV3 keys, out string errorMessage)
        {
            bool             flag;
            HashSet <string> strs = new HashSet <string>();

            List <SecretKeyV3> .Enumerator enumerator = keys.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    SecretKeyV3 current = enumerator.Current;
                    if (strs.Add(current.Name))
                    {
                        continue;
                    }
                    errorMessage = string.Format("More than one secret key is named {0}.", current.Name);
                    flag         = false;
                    return(flag);
                }
                errorMessage = null;
                return(true);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
            return(flag);
        }
示例#3
0
        public override bool Equals(object obj)
        {
            if (obj == null || this.GetType() != obj.GetType())
            {
                return(false);
            }
            SecretKeyV3 secretKeyV3 = (SecretKeyV3)obj;

            if (!this.Name.Equals(secretKeyV3.Name))
            {
                return(false);
            }
            if (!SecretKeyValidator.s_keyValueComparer.Equals(this.Value, secretKeyV3.Value))
            {
                return(false);
            }
            if (this.Permissions != secretKeyV3.Permissions)
            {
                return(false);
            }
            return(true);
        }