use new Encryption methods

This commit is contained in:
Jonathan Jenne 2021-05-28 11:01:59 +02:00
parent 3d30ab7309
commit 33cfb257b1
3 changed files with 8 additions and 14 deletions

View File

@ -74,7 +74,6 @@ Public Class frmMonitor
Try Try
LogConfig = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, "Digital Data", "Monitor") LogConfig = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, "Digital Data", "Monitor")
ConfigManager = New ConfigManager(Of Config)(LogConfig, Application.UserAppDataPath, Application.UserAppDataPath, Application.StartupPath) ConfigManager = New ConfigManager(Of Config)(LogConfig, Application.UserAppDataPath, Application.UserAppDataPath, Application.StartupPath)
ConfigManager.DecryptConnectionStrings()
Init(LogConfig) Init(LogConfig)
If ConfigManager.Config.ConnectionString = String.Empty Then If ConfigManager.Config.ConnectionString = String.Empty Then
@ -82,6 +81,7 @@ Public Class frmMonitor
If oSQLConfig.ShowDialog() = DialogResult.OK Then If oSQLConfig.ShowDialog() = DialogResult.OK Then
ConfigManager.Config.ConnectionString = oSQLConfig.ConnectionString ConfigManager.Config.ConnectionString = oSQLConfig.ConnectionString
ConfigManager.Save() ConfigManager.Save()
Application.Restart()
Else Else
ShowErrorMessage("No Database configured. Application will close!") ShowErrorMessage("No Database configured. Application will close!")
Application.Exit() Application.Exit()
@ -89,7 +89,8 @@ Public Class frmMonitor
End If End If
End If End If
Database = New MSSQLServer(LogConfig, ConfigManager.Config.ConnectionString) Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
Database = New MSSQLServer(LogConfig, oConnectionString)
GridBuilder = New GridBuilder(New List(Of GridView) From {GridView1, GridView2, GridView3, GridView4}) GridBuilder = New GridBuilder(New List(Of GridView) From {GridView1, GridView2, GridView3, GridView4})
GridBuilder. GridBuilder.
WithDefaults(). WithDefaults().
@ -133,7 +134,7 @@ Public Class frmMonitor
Private Function LoadGDPicture() As String Private Function LoadGDPicture() As String
Dim oSQL = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'" Dim oSQL = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'"
Return Database.GetScalarValue(oSQL).ToString() Return Database.GetScalarValue(oSQL)
End Function End Function
Private Sub buttonSearch_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles buttonSearch.ItemClick Private Sub buttonSearch_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles buttonSearch.ItemClick

View File

@ -116,12 +116,8 @@ Public Class ClassInit
End Sub End Sub
Private Sub CheckConnectivity(MyApplication As My.MyApplication) Private Sub CheckConnectivity(MyApplication As My.MyApplication)
Dim oCrypt As New EncryptionLegacy() Dim oConnectionString = MSSQLServer.DecryptConnectionString(My.SystemConfig.ConnectionString)
Dim oBuilder = My.SystemConfig.GetConnectionStringBuilder(My.SystemConfig.ConnectionString) My.Database = New MSSQLServer(My.LogConfig, oConnectionString)
oBuilder.Password = oCrypt.DecryptData(oBuilder.Password)
Dim oDecryptedConnectionString = oBuilder.ToString
My.Database = New MSSQLServer(My.LogConfig, oDecryptedConnectionString)
If My.Database.DBInitialized = False Then If My.Database.DBInitialized = False Then
_Logger.Warn("Could not initialize DD_ECM-Database!") _Logger.Warn("Could not initialize DD_ECM-Database!")

View File

@ -129,11 +129,8 @@ Public Class frmSQLConfig
Dim oResult = MessageBox.Show(STRING_CONNECTION_SUCCESSFUL, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) Dim oResult = MessageBox.Show(STRING_CONNECTION_SUCCESSFUL, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If oResult = DialogResult.Yes Then If oResult = DialogResult.Yes Then
Dim oCrypt As New EncryptionLegacy() Dim oPlainTextConnectionString = $"Server={txtServerName.Text};Database={cmbDatabase.Text};User Id={txtUserName.Text};Password={txtPassword.Text};"
Dim oEncryptedPassword = oCrypt.EncryptData(txtPassword.Text) ConnectionString = MSSQLServer.EncryptConnectionString(oPlainTextConnectionString)
Dim oEncryptedConnectionString = $"Server={txtServerName.Text};Database={cmbDatabase.Text};User Id={txtUserName.Text};Password={oEncryptedPassword};"
ConnectionString = oEncryptedConnectionString
Close() Close()
End If End If
Catch ex As Exception Catch ex As Exception