/// <summary> /// Initializes a new instance of the <see cref="HmacSigner"/> class using the specified configuration and key repository. /// </summary> /// <param name="configuration">The configuration used for signing.</param> /// <param name="keyRepository">The repository used for retrieving the key associated with the user.</param> /// <exception cref="ArgumentNullException">The configuration or key repository is null.</exception> /// <exception cref="HmacConfigurationException">The configured signature encoding is invalid.</exception> public HmacSigner(IHmacConfiguration configuration, IHmacKeyRepository keyRepository) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration), "The configuration cannot be null."); } if (keyRepository == null) { throw new ArgumentNullException(nameof(keyRepository), "The key repository cannot be null."); } HmacConfiguration = configuration; HmacKeyRepository = keyRepository; DateHeaderCulture = new CultureInfo(HmacConstants.DateHeaderCulture); Md5 = MD5.Create(); try { SignatureEncoding = Encoding.GetEncoding(configuration.SignatureEncoding); } catch (ArgumentException ex) { throw new HmacConfigurationException("The configured signature encoding is invalid.", ex); } }
/// <summary> /// Initializes a new instance of the <see cref="RestSharpHmacSigner"/> class using the specified configuration and key repository. /// </summary> /// <param name="configuration">The configuration used for signing.</param> /// <param name="keyRepository">The repository used for retrieving the key associated with the user.</param> /// <exception cref="ArgumentNullException">The configuration or key repository is null.</exception> public RestSharpHmacSigner(IHmacConfiguration configuration, IHmacKeyRepository keyRepository) : base(configuration, keyRepository) { }
public HmacAuthorizeAttribute(IHmacConfigurationManager configurationManager) { _configurationManager = configurationManager; _keyRepository = new SingleUserHmacKeyRepository("Neo", "FollowTheWhiteRabbit"); }