public AutoUpgradingHashedSecretVerifierDecorator( IApiClientSecretProvider apiClientSecretProvider, ISecretVerifier next, IPackedHashConverter packedHashConverter, ISecurePackedHashProvider securePackedHashProvider, IHashConfigurationProvider hashConfigurationProvider) { _apiClientSecretProvider = apiClientSecretProvider; _next = next; _packedHashConverter = packedHashConverter; _securePackedHashProvider = securePackedHashProvider; _hashConfiguration = hashConfigurationProvider.GetHashConfiguration(); }
public ApplicationSettingHashConfigurationProvider(IConfigValueProvider appConfigProvider, ISecureHasher[] secureHashers) { Func <string, string> getValue = appConfigProvider.GetValue; Func <string, int> getIntValue = key => { var value = getValue(key); if (value == null) { throw new Exception($"Configuration for value '{key}' has invalid value."); } int intValue; if (!int.TryParse(value, out intValue)) { throw new Exception($"Configuration for value '{key}' has invalid value of '{value}'."); } return(intValue); }; var algorithm = getValue("Password.Algorithm"); if (!secureHashers.Any(x => x.Algorithm.Equals(algorithm))) { throw new Exception($"Hashing algorithm ({algorithm}) was not found in a configured secure hasher."); } _hashConfiguration = new HashConfiguration { Algorithm = algorithm, Iterations = getIntValue("Password.Iterations"), SaltSize = getIntValue("Password.SaltSize") }; }