-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolved #203: Encrypt option to settings
- Loading branch information
Showing
6 changed files
with
144 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
framework/src/Volo.Abp.Settings/Volo/Abp/Settings/AbpSettingsModule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingEncryptionService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace Volo.Abp.Settings | ||
{ | ||
public interface ISettingEncryptionService | ||
{ | ||
[CanBeNull] | ||
string Encrypt([NotNull]SettingDefinition settingDefinition, [CanBeNull] string plainValue); | ||
|
||
[CanBeNull] | ||
string Decrypt([NotNull]SettingDefinition settingDefinition, [CanBeNull] string encryptedValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingEncryptionService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using Volo.Abp.DependencyInjection; | ||
using Volo.Abp.Security.Encryption; | ||
|
||
namespace Volo.Abp.Settings | ||
{ | ||
public class SettingEncryptionService : ISettingEncryptionService, ITransientDependency | ||
{ | ||
protected IStringEncryptionService StringEncryptionService { get; } | ||
|
||
public SettingEncryptionService(IStringEncryptionService stringEncryptionService) | ||
{ | ||
StringEncryptionService = stringEncryptionService; | ||
} | ||
|
||
public virtual string Encrypt(SettingDefinition settingDefinition, string plainValue) | ||
{ | ||
if (plainValue.IsNullOrEmpty()) | ||
{ | ||
return plainValue; | ||
} | ||
|
||
return StringEncryptionService.Encrypt(plainValue); | ||
} | ||
|
||
public virtual string Decrypt(SettingDefinition settingDefinition, string encryptedValue) | ||
{ | ||
if (encryptedValue.IsNullOrEmpty()) | ||
{ | ||
return encryptedValue; | ||
} | ||
|
||
return StringEncryptionService.Decrypt(encryptedValue); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters