diff --git a/ToolCollection/ClassActiveDirectory.vb b/ToolCollection/ClassActiveDirectory.vb index 15c7007..d8baa03 100644 --- a/ToolCollection/ClassActiveDirectory.vb +++ b/ToolCollection/ClassActiveDirectory.vb @@ -1,7 +1,7 @@ Imports System.DirectoryServices Imports DigitalData.Modules.Logging Public Class ClassActiveDirectory - Public Shared licenseManager As ClassLicenseManager = Nothing + Public Shared passwordCrypto As ClassPasswordCrypto = Nothing Public Shared ErgebnisAD As String() Private Shared _Logger As DigitalData.Modules.Logging.Logger Public Shared Function Test_Connect(SEARCH_Filter As String, Property2Load As String, Domain As String, User As String, PW As String) @@ -95,8 +95,8 @@ Public Class ClassActiveDirectory End If - licenseManager = New ClassLicenseManager("#DigitalData9731258!#") - Dim PWDecode As String = licenseManager.DecodeLicenseKey(PW) + passwordCrypto = New ClassPasswordCrypto("#DigitalData9731258!#") + Dim PWDecode As String = passwordCrypto.DecodePassword(PW) Dim objDirectoryEntry As DirectoryEntry = New DirectoryEntry(Domain) If PW <> String.Empty And User <> String.Empty Then objDirectoryEntry.Username = User diff --git a/ToolCollection/ClassLicense.vb b/ToolCollection/ClassLicense.vb deleted file mode 100644 index e069138..0000000 --- a/ToolCollection/ClassLicense.vb +++ /dev/null @@ -1,104 +0,0 @@ -Public Class ClassLicense - - Private _modulename As String - Private _expires As Date - Private _Typ As String - Private _anzProf As String - - - ' ++++++++++++++++++++++++++++++++++++++++++++++ Methoden ++++++++++++++++++++++++++++++++++++++++++++++ - - ''' - ''' Konstruktor der Lizenz - ''' - ''' Name des Moduls - ''' Gültigkeitsdatum der Lizenz - ''' - Sub New(ByVal modulename As String, ByVal expires As Date, ByVal _type As String, ByVal _anzprofile As String) - Me._modulename = modulename - Me._expires = expires - Me._Typ = _type - Me._anzProf = _anzprofile - End Sub - - - ' ++++++++++++++++++++++++++++++++++++++++++++++ Properties ++++++++++++++++++++++++++++++++++++++++++++++ - - ''' - ''' Liefert oder setzt den Namen des Moduls für diese Lizenz - ''' - ''' - ''' - ''' - Public Property Modulename() As String - Get - Return Me._modulename - End Get - Set(ByVal value As String) - Me._modulename = value - End Set - End Property - - - ''' - ''' Liefert oder setzt das Gültigkeitsdatum der Lizenz für das Modul - ''' - ''' - ''' - ''' - Public Property Expires() As Date - Get - Return Me._expires - End Get - Set(ByVal value As Date) - Me._expires = value - End Set - End Property - - - ''' - ''' Liefert ob die Lizenz schon abgelaufen ist - ''' - ''' - ''' - ''' - Public ReadOnly Property IsExpired() - Get - If Date.Today > Me._expires Then - Return True - Else - Return False - End If - End Get - End Property - - ''' - ''' Liefert den Typend er Lizenz - ''' - ''' - ''' - ''' - Public Property Type() As String - Get - Return Me._Typ - End Get - Set(ByVal value As String) - Me._Typ = value - End Set - End Property - ''' - ''' Liefert die Anzahl der Profile - ''' - ''' - ''' - ''' - Public Property Anz_Profile() As String - Get - Return Me._anzProf - End Get - Set(ByVal value As String) - Me._anzProf = value - End Set - End Property - -End Class diff --git a/ToolCollection/ClassLicenses.vb b/ToolCollection/ClassLicenses.vb deleted file mode 100644 index 2ef1a2e..0000000 --- a/ToolCollection/ClassLicenses.vb +++ /dev/null @@ -1,149 +0,0 @@ -Public Class ClassLicenses - - Private _licenses() As ClassLicense - Private _machine As String - Private _company As String - Private _WDLizenz As String - - ' ++++++++++++++++++++++++++++++++++++++++++++++ Methoden ++++++++++++++++++++++++++++++++++++++++++++++ - - ''' - ''' Konstruktor für die Lizenzen-Sammlung - ''' - ''' In Array übertragene Lizenzinformationen - ''' - Sub New(ByVal licenseStringArray(,) As String) - Try - If licenseStringArray IsNot Nothing Then - Dim license1() As String = licenseStringArray(0, 1).Split("#") - - If license1.Length > 1 Then - Me._machine = license1(1) - Else - Me._machine = "all" - End If - Me._company = license1(0) 'licenseStringArray(0, 1) - frmStart._company = Me._company - - Dim i As Integer - For i = 1 To licenseStringArray.GetLength(0) - 2 ' minus 2, weil GetLength nicht null-basiert ist und das erste Element Firma ist - Dim _date As Date - Dim anzprof As String = licenseStringArray(i, 3) - If anzprof.ToLower = "unlimited" Then - anzprof = 99 - End If - Try - _date = CDate(licenseStringArray(i, 1)) - Catch ex As Exception - - If licenseStringArray(i, 1).ToString.EndsWith("2099") Then - _date = "2099-12-31" - Else - MsgBox(ex.Message & vbNewLine & Environment.OSVersion.ToString, MsgBoxStyle.Critical) - End If - - End Try - - Me.Add(licenseStringArray(i, 0), _date, licenseStringArray(i, 2), anzprof) - Next - End If - Catch ex As Exception - MsgBox("Fehler bei Auslesen der Licenses: " & vbNewLine & ex.Message, MsgBoxStyle.Critical) - End Try - - End Sub - - - ''' - ''' Fügt der Lizenz-Sammlung eine Lizenz hinzu - ''' - ''' Name des Moduls, für das eine Lizenz angelegt werden soll - ''' Datum der Gültigkeit der Lizenz - ''' - Public Sub Add(ByVal modulename As String, ByVal expires As Date, ByVal type As String, ByVal anzprof As String) - - If Me._licenses IsNot Nothing Then - ReDim Preserve Me._licenses(Me._licenses.Length) - Else - ReDim Preserve Me._licenses(0) - End If - - Me._licenses(Me._licenses.Length - 1) = New ClassLicense(modulename, expires, type, anzprof) - End Sub - - - ''' - ''' Liefert eine Lizenz an Hand des Modulnamens - ''' - ''' Name des zu suchenden Moduls - ''' liefert ein Lizenzobjekt - ''' - Public Function GetLicense(ByVal modulename As String) As ClassLicense - If Me._licenses IsNot Nothing Then - For Each license As ClassLicense In Me._licenses - If license.Modulename = modulename Then - Return license - End If - Next - End If - - Return Nothing - End Function - - - - - ' ++++++++++++++++++++++++++++++++++++++++++++++ Properties ++++++++++++++++++++++++++++++++++++++++++++++ - - - ''' - ''' liefert eine Sammlung von Lizenzobjekten - ''' - ''' - ''' - ''' - Public ReadOnly Property Licenses() As ClassLicense() - Get - Return Me._licenses - End Get - End Property - - - ''' - ''' liefert eine Lizenz an Hand des Modulnamens - ''' - ''' Name des zu suchenden Moduls - ''' - ''' - ''' - Public ReadOnly Property License(ByVal modulename As String) As ClassLicense - Get - Return Me.GetLicense(modulename) - End Get - End Property - - - ''' - ''' Liefert oder setzt den Firmennamen des Lizenzeigentümers - ''' - ''' - ''' - ''' - Public Property Company() As String - Get - Return Me._company - End Get - Set(ByVal value As String) - Me._company = value - End Set - End Property - Public Property machine() As String - Get - Return Me._machine - End Get - Set(ByVal value As String) - Me._machine = value - End Set - End Property - -End Class diff --git a/ToolCollection/ClassLicenseManager.vb b/ToolCollection/ClassPasswordCrypto.vb similarity index 51% rename from ToolCollection/ClassLicenseManager.vb rename to ToolCollection/ClassPasswordCrypto.vb index 0c1a919..9eb3caa 100644 --- a/ToolCollection/ClassLicenseManager.vb +++ b/ToolCollection/ClassPasswordCrypto.vb @@ -1,34 +1,26 @@ -Imports System.Text -Imports System.Security.Cryptography -Imports System.Collections.ObjectModel +Imports System.Security.Cryptography +Imports System.Text -Public Class ClassLicenseManager +Public Class ClassPasswordCrypto Private _password As String - Private _key As String - Public Shared _licenses As ClassLicenses - Public licenseString As String - Public licenseStringArray(,) As String + ' ++++++++++++++++++++++++++++++++++++++++++++++ Properties ++++++++++++++++++++++++++++++++++++++++++++++ + ''' + ''' Liefert das Passwort zum Entschlüsseln des Lizenzschlüssels + ''' + ''' + ''' + ''' + Public ReadOnly Property Password() As String + Get + Return Me._password + End Get + End Property ' ++++++++++++++++++++++++++++++++++++++++++++++ Methoden ++++++++++++++++++++++++++++++++++++++++++++++ - ''' - ''' Konstruktor für den Lizenz-Manager - ''' - ''' Passwort zum Entschlüsseln des Lizenzkeys - ''' verschlüsselter Lizenzkey - ''' - Sub New(ByVal password As String, ByVal key As String) - Me._password = password - Me._key = key - - Me.licenseString = Me.DecodeLicenseKey(Me._key) - Me.licenseStringArray = Me.SplitLicenseString(Me.licenseString) - - Me.LoadLicenses() - End Sub ''' ''' Konstruktor für den Lizenz-Manager ohne License load ''' @@ -37,14 +29,6 @@ Public Class ClassLicenseManager Sub New(ByVal password As String) Me._password = password End Sub - ''' - ''' Lädt alle Lizenzen aus dem Lizenz-Array - ''' - ''' - Public Sub LoadLicenses() - ClassLicenseManager._licenses = New ClassLicenses(Me.licenseStringArray) - End Sub - ''' ''' Codiert eine Zeichenkette @@ -53,7 +37,7 @@ Public Class ClassLicenseManager ''' das zur Verschlüsselung verwendete Passwort ''' liefert eine verschlüsselte Zeichenkette ''' - Public Function EncodeLicenseKey(ByVal str As String, ByVal password As String) + Public Function EncodePassword(ByVal str As String, ByVal password As String) Dim rd As New RijndaelManaged Dim md5 As New MD5CryptoServiceProvider @@ -69,7 +53,7 @@ Public Class ClassLicenseManager ms.Write(iv, 0, iv.Length) Dim cs As New CryptoStream(ms, rd.CreateEncryptor, CryptoStreamMode.Write) - Dim data() As Byte = System.Text.Encoding.UTF8.GetBytes(Str) + Dim data() As Byte = System.Text.Encoding.UTF8.GetBytes(str) cs.Write(data, 0, data.Length) cs.FlushFinalBlock() @@ -82,14 +66,13 @@ Public Class ClassLicenseManager Return result End Function - ''' ''' Decodiert den verschlüsselten Lizenzkey ''' ''' verschlüsselter Lizenzkey ''' ''' - Public Function DecodeLicenseKey(ByVal licenseCodeStr As String) + Public Function DecodePassword(ByVal licenseCodeStr As String) Try Dim rd As New RijndaelManaged Dim rijndaelIvLength As Integer = 16 @@ -121,7 +104,6 @@ Public Class ClassLicenseManager Dim i As Integer = 0 - Try i = cs.Read(data, 0, data.Length) @@ -143,95 +125,4 @@ Public Class ClassLicenseManager Return Nothing End Function - - ''' - ''' Zerlegt den entschlüsselten Lizenzkey - ''' - ''' entschlüsselter Lizenzkey - ''' - ''' - Public Function SplitLicenseString(ByVal licenseStr As String) As String(,) - - Try - If licenseStr IsNot Nothing Then - Dim licenseTemp() As String = licenseStr.Split(";") - - Dim licenses(licenseTemp.Length, 3) As String - - Dim i As Integer = 0 - - If licenseTemp IsNot Nothing Then - For Each lizenz As String In licenseTemp - - Dim temp() = lizenz.Split(":") - - licenses(i, 0) = temp(0) - licenses(i, 1) = temp(1) - If temp.Length > 2 Then - licenses(i, 2) = temp(2) - licenses(i, 3) = temp(3) - Dim expires As Date - Date.TryParse(licenses(i, 1), expires) - End If - - - i += 1 - Next - - Return licenses - End If - End If - Catch ex As Exception - MsgBox("Fehler in SplitLicenseString: " & vbNewLine & ex.Message, MsgBoxStyle.Critical) - End Try - - Return Nothing - - End Function - - - - ' ++++++++++++++++++++++++++++++++++++++++++++++ Properties ++++++++++++++++++++++++++++++++++++++++++++++ - - ''' - ''' Liefert das Passwort zum Entschlüsseln des Lizenzschlüssels - ''' - ''' - ''' - ''' - Public ReadOnly Property Password() As String - Get - Return Me._password - End Get - End Property - - - ''' - ''' Liefert eine Sammlung von Lizenzobjekten - ''' - ''' - ''' - ''' - Public ReadOnly Property Licenses() As ClassLicenses - Get - Return ClassLicenseManager._licenses - End Get - End Property - - - ''' - ''' Liefert oder setzt den Lizenzschlüssel - ''' - ''' - ''' - ''' - Public Property Key() As String - Get - Return Me._key - End Get - Set(ByVal value As String) - Me._key = value - End Set - End Property - End Class diff --git a/ToolCollection/My Project/AssemblyInfo.vb b/ToolCollection/My Project/AssemblyInfo.vb index d5743dd..aa3ff7e 100644 --- a/ToolCollection/My Project/AssemblyInfo.vb +++ b/ToolCollection/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - + diff --git a/ToolCollection/ToolCollection.vbproj b/ToolCollection/ToolCollection.vbproj index 76bfd4f..0d44927 100644 --- a/ToolCollection/ToolCollection.vbproj +++ b/ToolCollection/ToolCollection.vbproj @@ -191,9 +191,7 @@ - - - + diff --git a/ToolCollection/frmNIProfileigenschaften.vb b/ToolCollection/frmNIProfileigenschaften.vb index 0db035b..a80a62d 100644 --- a/ToolCollection/frmNIProfileigenschaften.vb +++ b/ToolCollection/frmNIProfileigenschaften.vb @@ -15,7 +15,7 @@ Public Class frmNIProfileigenschaften ' verhindert (wenn True) das _selectedProfile auf Nothing gesetzt wird, wenn das Panel auf visible = True gesetzt wird Private _flagIgnoreVisibilityChanged As Boolean = False Private Shared _Instance As frmNIProfileigenschaften = Nothing - Private licenseManager As ClassLicenseManager = Nothing + Private passwordCrypto As ClassPasswordCrypto = Nothing Private INDEX_LIST As New List(Of String) Private selectedProfile As ClassNIProfil Public Shared Function Instance() As frmNIProfileigenschaften @@ -435,8 +435,8 @@ Public Class frmNIProfileigenschaften If _selectedProfile.Password <> "" And _selectedProfile.UserId <> "" Then Me.chkbxUserIdent.Checked = False Me.txtLDAP_User.Text = _selectedProfile.UserId - licenseManager = New ClassLicenseManager("#DigitalData9731258!#") - Dim PWDecode As String = licenseManager.DecodeLicenseKey(_selectedProfile.Password) + passwordCrypto = New ClassPasswordCrypto("#DigitalData9731258!#") + Dim PWDecode As String = passwordCrypto.DecodePassword(_selectedProfile.Password) Me.txtLDAP_PW.Text = PWDecode Else Me.chkbxUserIdent.Checked = True @@ -1158,8 +1158,8 @@ Public Class frmNIProfileigenschaften Private Sub txtLDAP_PW_TextChanged(sender As Object, e As EventArgs) Handles txtLDAP_PW.TextChanged If Me._selectedProfile IsNot Nothing Then - licenseManager = New ClassLicenseManager("#DigitalData9731258!#") - Dim encodePW As String = licenseManager.EncodeLicenseKey(txtLDAP_PW.Text, "#DigitalData9731258!#") + passwordCrypto = New ClassPasswordCrypto("#DigitalData9731258!#") + Dim encodePW As String = passwordCrypto.EncodePassword(txtLDAP_PW.Text, "#DigitalData9731258!#") Me._selectedProfile.Password = encodePW If Not Me._selectedProfile.Password = Me._selectedProfile.OriginalPassword Then Me.btnSpeichern.Enabled = True diff --git a/ToolCollection/frmNIProfilhinzufuegen.vb b/ToolCollection/frmNIProfilhinzufuegen.vb index c5f9097..5f6ec28 100644 --- a/ToolCollection/frmNIProfilhinzufuegen.vb +++ b/ToolCollection/frmNIProfilhinzufuegen.vb @@ -4,7 +4,7 @@ Public Class frmNIProfilhinzufuegen Private _oDokumentTypen As WINDREAMLib.WMObjects Public Shared _windream As ClassWindream_allgemein Private Shared _Instance As frmNIProfilhinzufuegen = Nothing - Private licenseManager As ClassLicenseManager = Nothing + Private passwordCrypto As ClassPasswordCrypto = Nothing Public Shared Function Instance() As frmNIProfilhinzufuegen @@ -138,8 +138,8 @@ Public Class frmNIProfilhinzufuegen ' Nachindexierung über AD If Me.txtProfilname.Text <> "" And Me.cmbObjektTypen.SelectedIndex <> -1 And Me.txtWindreamSuche.Text <> "" Then If chkbxUserIdent.Checked = False And txtLDAP_Domaene.Text <> "" And txtLDAP_PW.Text <> "" And txtLDAP_User.Text <> "" Then - Me.licenseManager = New ClassLicenseManager("#DigitalData9731258!#") - Dim key As String = licenseManager.EncodeLicenseKey(txtLDAP_PW.Text, "#DigitalData9731258!#") + Me.passwordCrypto = New ClassPasswordCrypto("#DigitalData9731258!#") + Dim key As String = passwordCrypto.EncodePassword(txtLDAP_PW.Text, "#DigitalData9731258!#") ' das Profil hinzufügen - AD MIT AUTH ClassNIProfile.Add(Me.txtProfilname.Text, Me.cmbObjektTypen.SelectedItem, Me.txtWindreamSuche.Text, "activedirectory", "", "", txtLDAP_Domaene.Text, txtLDAP_User.Text, key, "", Me.cmbIndexValidierung.Text, "", 0, Me.chkbxGetOrdnerRechte.Checked, Me.cmbOrdnertyp.Text) ' und das Formular schließen diff --git a/ToolCollection/frmStart.vb b/ToolCollection/frmStart.vb index cce7318..3c4b242 100644 --- a/ToolCollection/frmStart.vb +++ b/ToolCollection/frmStart.vb @@ -1,27 +1,11 @@ -Imports System.Collections.ObjectModel -Imports System.Reflection -Imports System.Globalization -Imports DigitalData.Modules.Logging -Imports System.IO -Imports DigitalData.Modules.Database +Imports System.IO Imports System.Text.RegularExpressions -Imports System.ComponentModel +Imports DigitalData.Modules.Database +Imports DigitalData.Modules.Logging Public Class frmStart Private _MyLogger As LogConfig Private Shared _Logger As DigitalData.Modules.Logging.Logger - Public _company As String - ' Dim timediff As Integer = 0 - 'Private Sub timUhrzeit_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timUhrzeit.Tick - ' ' der Statusuhr die aktuelle Systemzeit zuweisen - ' Me.Status_Clock.Text = CType(My.Computer.Clock.LocalTime, String) - ' timediff += 1000 - ' If timediff >= 86400000 Then - ' 'LogDateien-löschen - ' Delete_LogFiles() - ' End If - 'End Sub - ' CREATE INSTANCE Private Shared _Instance As frmStart = Nothing