Add Encryption Module, remove all encryption Code from Filesystem to prevent circular dependencies
This commit is contained in:
@@ -114,6 +114,10 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Encryption\Encryption.vbproj">
|
||||
<Project>{8a8f20fc-c46e-41ac-bee7-218366cfff99}</Project>
|
||||
<Name>Encryption</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.Filesystem\Filesystem.vbproj">
|
||||
<Project>{991d0231-4623-496d-8bd0-9ca906029cbc}</Project>
|
||||
<Name>Filesystem</Name>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
Imports System.Reflection
|
||||
Imports System.Xml.Serialization
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Encryption
|
||||
Imports DigitalData.Modules.Config.ConfigAttributes
|
||||
|
||||
Public Class ConfigManager(Of T)
|
||||
@@ -34,6 +35,12 @@ Public Class ConfigManager(Of T)
|
||||
GetType(GlobalSettingAttribute)
|
||||
}
|
||||
|
||||
Private ReadOnly _ConnectionStringAttributes = New List(Of Type) From {
|
||||
GetType(ConnectionStringAttribute),
|
||||
GetType(ConnectionStringAppServerAttribute),
|
||||
GetType(ConnectionStringTestAttribute)
|
||||
}
|
||||
|
||||
''' <summary>
|
||||
''' Signals that all properties will be written to (and read from) the UserConfig.xml
|
||||
'''
|
||||
@@ -159,6 +166,27 @@ Public Class ConfigManager(Of T)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function DecryptConnectionStrings() As Boolean
|
||||
Try
|
||||
Dim oType As Type = GetType(T)
|
||||
Dim oProperties = oType.GetProperties()
|
||||
Dim oEncryption = New EncryptionLegacy()
|
||||
|
||||
For Each oProperty In oProperties
|
||||
If Attribute.IsDefined(oProperty, GetType(ConnectionStringAttribute)) Then
|
||||
Dim oValue = oProperty.GetValue(_Config, Nothing)
|
||||
Dim oDecryptedValue = oEncryption.DecryptConnectionString(oValue)
|
||||
oProperty.SetValue(_Config, oDecryptedValue, Nothing)
|
||||
End If
|
||||
Next
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Copies all properties from Source to Target, except those who have an attribute
|
||||
''' listed in ExcludedAttributeTypes
|
||||
@@ -203,7 +231,7 @@ Public Class ConfigManager(Of T)
|
||||
|
||||
Private Function LoadConfig() As T
|
||||
' first create an empty/default config object
|
||||
Dim oConfig = Activator.CreateInstance(_BlueprintType)
|
||||
Dim oConfig As T = Activator.CreateInstance(_BlueprintType)
|
||||
|
||||
' try to load the special app config
|
||||
oConfig = LoadAppConfig(oConfig)
|
||||
|
||||
Reference in New Issue
Block a user