public static string Caption(ApiKeyRole role) { string caption; if (Captions.TryGetValue(role, out caption)) { return(caption); } throw new Exception($"Compliance is not set ({role})"); }
void IApiKeyProvider.SetPublicApiKey(ApiKeyRole role, IApiKey apiKey) { var pair = _apiKeys.FirstOrDefault(k => k.Role == role); if (pair == null) { _apiKeys.Add(new Authenticator(role, null, apiKey)); } else { pair.PublicKey = apiKey; } SaveApiKeys(); }
private bool ApiKeyFromControls(object control, out IApiKey apiKey, out ApiKeyRole role) { apiKey = null; role = ApiKeyRole.Account; var textBox = control as TextBox; if (textBox == null) { return(false); } var value = textBox.Text; if (!(textBox.Tag is ApiKeyRole)) { throw new Exception("textBox.Tag is not ApiKeyRole"); } apiKey = string.IsNullOrEmpty(value) ? null : new ApiKey(value); role = (ApiKeyRole)textBox.Tag; return(true); }
public Authenticator(ApiKeyRole role, IApiKey privateKey, IApiKey publicKey) { Role = role; PrivateKey = privateKey; PublicKey = publicKey; }
public Authenticator ApiKeys(ApiKeyRole role) { return(_apiKeyProvider.ApiKeys.FirstOrDefault(p => p.Role == role)); }
void IApiKeyProvider.SetPublicApiKey(ApiKeyRole role, IApiKey apiKey) { _apiKeyProvider.SetPublicApiKey(role, apiKey); }
void IApiKeyProvider.SetPrivateApiKey(ApiKeyRole role, IApiKey apiKey) { _apiKeyProvider.SetPrivateApiKey(role, apiKey); }
private string ApiKeySettingsName(ApiKeyRole role, bool isPrivateKey) { var name = isPrivateKey ? "PrivateKey" : "PublicKey"; return(ApiKeyRoleCaption.Caption(role) + name); }