Add Encryption Module, remove all encryption Code from Filesystem to prevent circular dependencies

This commit is contained in:
Jonathan Jenne 2021-05-26 16:37:55 +02:00
parent 0e25ec9cec
commit b1b4868010
28 changed files with 542 additions and 15 deletions

View File

@ -48,4 +48,12 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.5.0.0" newVersion="7.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -132,6 +132,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Monitor", "GUIs.Monitor\Mon
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MonoRepoUtils", "ConfigCreator\MonoRepoUtils.vbproj", "{9D4AC920-C78E-41C3-994E-91690FF79380}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Encryption", "Encryption\Encryption.vbproj", "{8A8F20FC-C46E-41AC-BEE7-218366CFFF99}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -350,6 +352,10 @@ Global
{9D4AC920-C78E-41C3-994E-91690FF79380}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D4AC920-C78E-41C3-994E-91690FF79380}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D4AC920-C78E-41C3-994E-91690FF79380}.Release|Any CPU.Build.0 = Release|Any CPU
{8A8F20FC-C46E-41AC-BEE7-218366CFFF99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8A8F20FC-C46E-41AC-BEE7-218366CFFF99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A8F20FC-C46E-41AC-BEE7-218366CFFF99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A8F20FC-C46E-41AC-BEE7-218366CFFF99}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -408,6 +414,7 @@ Global
{65EFB268-C0E0-40C1-8981-9F70DEE5C74A} = {F98C0329-C004-417F-B2AB-7466E88D8220}
{E24E8D40-0361-4C07-8FAE-3621DE316E70} = {8FFE925E-8B84-45F1-93CB-32B1C96F41EB}
{9D4AC920-C78E-41C3-994E-91690FF79380} = {8FFE925E-8B84-45F1-93CB-32B1C96F41EB}
{8A8F20FC-C46E-41AC-BEE7-218366CFFF99} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8A8F20FC-C46E-41AC-BEE7-218366CFFF99}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>DigitalData.Modules.Encryption</RootNamespace>
<AssemblyName>DigitalData.Modules.Encryption</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>Windows</MyType>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>DigitalData.Modules.Encryption.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>DigitalData.Modules.Encryption.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>
<PropertyGroup>
<OptionExplicit>On</OptionExplicit>
</PropertyGroup>
<PropertyGroup>
<OptionCompare>Binary</OptionCompare>
</PropertyGroup>
<PropertyGroup>
<OptionStrict>Off</OptionStrict>
</PropertyGroup>
<PropertyGroup>
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.5\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<Import Include="Microsoft.VisualBasic" />
<Import Include="System" />
<Import Include="System.Collections" />
<Import Include="System.Collections.Generic" />
<Import Include="System.Data" />
<Import Include="System.Diagnostics" />
<Import Include="System.Linq" />
<Import Include="System.Xml.Linq" />
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="Compression.vb" />
<Compile Include="Encryption.vb" />
<Compile Include="EncryptionLegacy.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Application.myapp</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="My Project\Resources.Designer.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="My Project\Settings.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
<None Include="My Project\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Modules.Logging\Logging.vbproj">
<Project>{903b2d7d-3b80-4be9-8713-7447b704e1b0}</Project>
<Name>Logging</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
</Project>

View File

@ -1,7 +1,16 @@
Imports System.Security.Cryptography
Imports System.Data
Imports System.Data.SqlClient
Public Class EncryptionLegacy
Private TripleDes As New TripleDESCryptoServiceProvider
Private DEFAULT_KEY As String = "!35452didalog="
Sub New()
TripleDes.Key = TruncateHash(DEFAULT_KEY, TripleDes.KeySize \ 8)
TripleDes.IV = TruncateHash("", TripleDes.BlockSize \ 8)
End Sub
Sub New(ByVal key As String)
' Initialize the crypto provider.
TripleDes.Key = TruncateHash(key, TripleDes.KeySize \ 8)
@ -62,5 +71,13 @@ Public Class EncryptionLegacy
' Convert the plaintext stream to a string.
Return result
End Function
Public Function DecryptConnectionString(ConnectionString As String) As String
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = ConnectionString}
Dim oDecryptedPassword = DecryptData(oBuilder.Password)
oBuilder.Password = oDecryptedPassword
Return oBuilder.ToString()
End Function
End Class

View File

@ -0,0 +1,13 @@
'------------------------------------------------------------------------------
' <auto-generated>
' Dieser Code wurde von einem Tool generiert.
' Laufzeitversion:4.0.30319.42000
'
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
' der Code erneut generiert wird.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>false</MySubMain>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode>
<ApplicationType>1</ApplicationType>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>

View File

@ -0,0 +1,35 @@
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' Allgemeine Informationen über eine Assembly werden über die folgenden
' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
' die einer Assembly zugeordnet sind.
' Werte der Assemblyattribute überprüfen
<Assembly: AssemblyTitle("Encryption")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("Encryption")>
<Assembly: AssemblyCopyright("Copyright © 2021")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
'Die folgende GUID wird für die typelib-ID verwendet, wenn dieses Projekt für COM verfügbar gemacht wird.
<Assembly: Guid("e92901a1-8e87-482d-b63f-f20292d38f1e")>
' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
'
' Hauptversion
' Nebenversion
' Buildnummer
' Revision
'
' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
' indem Sie "*" wie unten gezeigt eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>

View File

@ -0,0 +1,63 @@
'------------------------------------------------------------------------------
' <auto-generated>
' Dieser Code wurde von einem Tool generiert.
' Laufzeitversion:4.0.30319.42000
'
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
' der Code erneut generiert wird.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Imports System
Namespace My.Resources
'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
'-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
'''<summary>
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("DigitalData.Modules.Encryption.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set
resourceCulture = value
End Set
End Property
End Module
End Namespace

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,73 @@
'------------------------------------------------------------------------------
' <auto-generated>
' Dieser Code wurde von einem Tool generiert.
' Laufzeitversion:4.0.30319.42000
'
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
' der Code erneut generiert wird.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
#Region "Automatische My.Settings-Speicherfunktion"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.DigitalData.Modules.Encryption.My.MySettings
Get
Return Global.DigitalData.Modules.Encryption.My.MySettings.Default
End Get
End Property
End Module
End Namespace

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.7.5" targetFramework="net461" />
</packages>

View File

@ -32,5 +32,5 @@ Imports System.Runtime.InteropServices
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' [assembly: AssemblyVersion("1.0.*")]
<Assembly: AssemblyVersion("0.1.0.0")>
<Assembly: AssemblyVersion("0.2.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>

View File

@ -73,7 +73,8 @@ Public Class frmMonitor
Private Sub frmStart_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
LogConfig = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, "Digital Data", "Monitor")
ConfigManager = New ConfigManager(Of Config)(LogConfig, Application.UserAppDataPath)
ConfigManager = New ConfigManager(Of Config)(LogConfig, Application.UserAppDataPath, Application.UserAppDataPath, Application.StartupPath)
ConfigManager.DecryptConnectionStrings()
Init(LogConfig)
If ConfigManager.Config.ConnectionString = String.Empty Then

View File

@ -1,6 +1,4 @@
Public Class ClassConstants
Public Const CRYPTO_LEGACY_ENCRYPTION_KEY = "!35452didalog="
Public Const SERVICE_MAX_MESSAGE_SIZE = 2147483647
Public Const SERVICE_MAX_BUFFER_SIZE = 2147483647
Public Const SERVICE_MAX_ARRAY_LENGTH = 2147483647

View File

@ -10,6 +10,7 @@ Imports DigitalData.GUIs.ZooFlow.ClassConstants
Imports System.Threading
Imports System.Globalization
Imports DigitalData.Modules.EDMI.API
Imports DigitalData.Modules.Encryption
Public Class ClassInit
Private _MainForm As frmFlowForm
@ -115,7 +116,7 @@ Public Class ClassInit
End Sub
Private Sub CheckConnectivity(MyApplication As My.MyApplication)
Dim oCrypt As New EncryptionLegacy(CRYPTO_LEGACY_ENCRYPTION_KEY)
Dim oCrypt As New EncryptionLegacy()
Dim oBuilder = My.SystemConfig.GetConnectionStringBuilder(My.SystemConfig.ConnectionString)
oBuilder.Password = oCrypt.DecryptData(oBuilder.Password)
Dim oDecryptedConnectionString = oBuilder.ToString

View File

@ -465,6 +465,10 @@
<Project>{3e7bc8a9-91ef-49b8-8110-2c01f664c24a}</Project>
<Name>SQLEditor</Name>
</ProjectReference>
<ProjectReference Include="..\Encryption\Encryption.vbproj">
<Project>{8a8f20fc-c46e-41ac-bee7-218366cfff99}</Project>
<Name>Encryption</Name>
</ProjectReference>
<ProjectReference Include="..\GUIs.ClipboardWatcher\ClipboardWatcher.vbproj">
<Project>{B7D465A2-AE31-4CDF-A8B2-34B42D3EA84E}</Project>
<Name>ClipboardWatcher</Name>

View File

@ -1,4 +1,5 @@
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Encryption
Imports DigitalData.Modules.Filesystem
Imports DigitalData.Modules.Logging
@ -102,7 +103,7 @@ Public Class frmConfigDatabase
Dim oResult = MessageBox.Show(STRING_CONNECTION_SUCCESSFUL, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If oResult = DialogResult.Yes Then
Dim oCrypt As New EncryptionLegacy("!35452didalog=")
Dim oCrypt As New EncryptionLegacy()
Dim oEncryptedPassword = oCrypt.EncryptData(txtPassword.Text)
Dim oEncryptedConnectionString = $"Server={txtServerName.Text};Database={cmbDatabase.Text};User Id={txtUserName.Text};Password={oEncryptedPassword};"

View File

@ -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>

View File

@ -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)

View File

@ -1,5 +1,6 @@
Imports System.IO
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Encryption
Imports ProtoBuf
''' <module>FileContainer</module>
@ -41,7 +42,7 @@ Imports ProtoBuf
''' oContainer.SaveAs("E:\some2.container")
''' </example>
Public Class FileContainer
Private _crypto As Encryption
Private _crypto As Encryption.Encryption
Private _compression As Compression
Private _inner As FileContainerInner
Private _logger As Logger
@ -85,7 +86,7 @@ Public Class FileContainer
Public Sub New(LogConfig As LogConfig, Password As String)
_logger = LogConfig.GetLogger()
_crypto = New Encryption(LogConfig, Password)
_crypto = New Encryption.Encryption(LogConfig, Password)
_compression = New Compression(LogConfig)
_inner = New FileContainerInner()
End Sub

View File

@ -75,11 +75,8 @@
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="Encryption\Compression.vb" />
<Compile Include="FileContainer\DocumentObject.vb" />
<Compile Include="Encryption\EncryptionLegacy.vb" />
<Compile Include="FileContainer\FileContainer.vb" />
<Compile Include="Encryption\Encryption.vb" />
<Compile Include="File.vb" />
<Compile Include="FileContainer\FileContainerInner.vb" />
<Compile Include="FileWatcher\FileWatcher.vb" />
@ -122,6 +119,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.Logging\Logging.vbproj">
<Project>{903b2d7d-3b80-4be9-8713-7447b704e1b0}</Project>
<Name>Logging</Name>

View File

@ -141,6 +141,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.Database\Database.vbproj">
<Project>{eaf0ea75-5fa7-485d-89c7-b2d843b03a96}</Project>
<Name>Database</Name>

View File

@ -1,6 +1,7 @@
Imports System.ComponentModel
Imports System.Data.SqlClient
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Encryption
Imports DigitalData.Modules.Filesystem
Imports DigitalData.Modules.Logging
@ -128,7 +129,7 @@ Public Class frmSQLConfig
Dim oResult = MessageBox.Show(STRING_CONNECTION_SUCCESSFUL, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If oResult = DialogResult.Yes Then
Dim oCrypt As New EncryptionLegacy("!35452didalog=")
Dim oCrypt As New EncryptionLegacy()
Dim oEncryptedPassword = oCrypt.EncryptData(txtPassword.Text)
Dim oEncryptedConnectionString = $"Server={txtServerName.Text};Database={cmbDatabase.Text};User Id={txtUserName.Text};Password={oEncryptedPassword};"

View File

@ -136,6 +136,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.Database\Database.vbproj">
<Project>{eaf0ea75-5fa7-485d-89c7-b2d843b03a96}</Project>
<Name>Database</Name>

View File

@ -6,6 +6,8 @@ Imports DigitalData.Modules.Filesystem
Imports DigitalData.Modules.Language
Imports System.Timers
Imports System.IO
Imports DigitalData.Modules.Encryption
Public Class EmailService
Private _Logger As Logger
Private _LogConfig As LogConfig
@ -50,7 +52,7 @@ Public Class EmailService
_Logger.NewBlock("Inititalize Encryption")
_Encryption = New EncryptionLegacy("!35452didalog=")
_Encryption = New EncryptionLegacy()
_Logger.EndBlock()