Exemple #1
0
 protected override void ValidateRights(IEnumerable <AccessRights> value)
 {
     base.ValidateRights(value);
     if (!SharedAccessAuthorizationRule.IsValidCombinationOfRights(value))
     {
         throw new ArgumentException(SRClient.InvalidCombinationOfManageRight);
     }
 }
Exemple #2
0
 protected override void OnValidate()
 {
     if (string.IsNullOrEmpty(this.InternalKeyName) || !string.Equals(this.InternalKeyName, HttpUtility.UrlEncode(this.InternalKeyName)))
     {
         throw new InvalidDataContractException(SRCore.SharedAccessAuthorizationRuleKeyContainsInvalidCharacters);
     }
     if (this.InternalKeyName.Length > 256)
     {
         throw new InvalidDataContractException(SRCore.SharedAccessAuthorizationRuleKeyNameTooBig(256));
     }
     if (string.IsNullOrEmpty(this.InternalPrimaryKey))
     {
         throw new InvalidDataContractException(SRCore.SharedAccessAuthorizationRuleRequiresPrimaryKey);
     }
     if (Encoding.ASCII.GetByteCount(this.InternalPrimaryKey) != 44)
     {
         throw new InvalidDataContractException(SRCore.SharedAccessRuleAllowsFixedLengthKeys(44));
     }
     if (!SharedAccessAuthorizationRule.CheckBase64(this.InternalPrimaryKey))
     {
         throw new InvalidDataContractException(SRCore.SharedAccessKeyShouldbeBase64);
     }
     if (!string.IsNullOrEmpty(this.InternalSecondaryKey))
     {
         if (Encoding.ASCII.GetByteCount(this.InternalSecondaryKey) != 44)
         {
             throw new InvalidDataContractException(SRCore.SharedAccessRuleAllowsFixedLengthKeys(44));
         }
         if (!SharedAccessAuthorizationRule.CheckBase64(this.InternalSecondaryKey))
         {
             throw new InvalidDataContractException(SRCore.SharedAccessKeyShouldbeBase64);
         }
     }
     if (!SharedAccessAuthorizationRule.IsValidCombinationOfRights(base.Rights))
     {
         throw new InvalidDataContractException(SRClient.InvalidCombinationOfManageRight);
     }
 }