|
|
|
@ -17,32 +17,28 @@ namespace isn
|
|
|
|
|
/// <value></value>
|
|
|
|
|
public string ProtectedApiKey { get; set; }
|
|
|
|
|
|
|
|
|
|
public string ApiKey { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Key alias
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value></value>
|
|
|
|
|
public string Alias { get; set; }
|
|
|
|
|
public string Url { get; set; }
|
|
|
|
|
|
|
|
|
|
public SourceSettings()
|
|
|
|
|
{
|
|
|
|
|
rsa = RSA.Create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetClearApiKey()
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(ApiKey)) return ApiKey;
|
|
|
|
|
return
|
|
|
|
|
Encoding.UTF8.GetString(
|
|
|
|
|
rsa.Decrypt(Encoding.UTF8.GetBytes(ProtectedApiKey),
|
|
|
|
|
RSAEncryptionPadding.Pkcs1));
|
|
|
|
|
var base64EncodedBytes = System.Convert.FromBase64String(ProtectedApiKey);
|
|
|
|
|
var decrypted = rsa.Decrypt(base64EncodedBytes, RSAEncryptionPadding.Pkcs1);
|
|
|
|
|
return Encoding.UTF8.GetString(decrypted);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetApiKey(string key)
|
|
|
|
|
{
|
|
|
|
|
ApiKey = Encoding.UTF8.GetString(
|
|
|
|
|
rsa.Encrypt(Encoding.UTF8.GetBytes(key),
|
|
|
|
|
RSAEncryptionPadding.Pkcs1));
|
|
|
|
|
var crypted =rsa.Encrypt(Encoding.UTF8.GetBytes(key), RSAEncryptionPadding.Pkcs1);
|
|
|
|
|
ProtectedApiKey = System.Convert.ToBase64String(crypted);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -51,8 +47,6 @@ namespace isn
|
|
|
|
|
public string DataProtectionTitle { get; set; }
|
|
|
|
|
public Dictionary<string, SourceSettings> Sources { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool AutoUpdateApiKey { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
private string defSourceKey;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -68,7 +62,7 @@ namespace isn
|
|
|
|
|
{
|
|
|
|
|
Sources[value]=new SourceSettings
|
|
|
|
|
{
|
|
|
|
|
Alias = defSourceKey
|
|
|
|
|
Url = defSourceKey
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
defSourceKey = value;
|
|
|
|
|