-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
119f88c
commit 7315f5f
Showing
42 changed files
with
6,259 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ bin | |
obj | ||
*.user | ||
/KeyManager.Setup/packages | ||
/KeyManager.Library.KeyStore.SAM_SE/DLL/Debug/* |
21 changes: 21 additions & 0 deletions
21
KeyManager.Library.KeyStore.SAM_SE.UI/Domain/SAM_SEConverters.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,21 @@ | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
using System.Windows; | ||
|
||
namespace Leosac.KeyManager.Library.KeyStore.SAM_SE.UI.Domain | ||
{ | ||
public class BooleanToVisibilityConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
bool boolValue = (bool)value; | ||
boolValue = (parameter != null) ? !boolValue : boolValue; | ||
return boolValue ? Visibility.Visible : Visibility.Collapsed; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
134 changes: 134 additions & 0 deletions
134
KeyManager.Library.KeyStore.SAM_SE.UI/Domain/SAM_SEKeyStorePropertiesControlViewModel.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,134 @@ | ||
using Leosac.KeyManager.Library.KeyStore.SAM_SE.DLL; | ||
using Leosac.KeyManager.Library.Plugin.UI.Domain; | ||
using System.Collections.ObjectModel; | ||
using System.Windows.Input; | ||
|
||
namespace Leosac.KeyManager.Library.KeyStore.SAM_SE.UI.Domain | ||
{ | ||
public class SAM_SEKeyStorePropertiesControlViewModel : KeyStorePropertiesControlViewModel | ||
{ | ||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod()?.DeclaringType); | ||
|
||
public SAM_SEKeyStorePropertiesControlViewModel() | ||
{ | ||
_properties = new SAM_SEKeyStoreProperties(); | ||
SAM_SEReaders = new ObservableCollection<string>(); | ||
SAM_SEDll = new SAM_SEDllProgrammingStation(); | ||
} | ||
|
||
public SAM_SEKeyStoreProperties? SAM_SEProperties | ||
{ | ||
get { return Properties as SAM_SEKeyStoreProperties; } | ||
} | ||
|
||
public ObservableCollection<string> SAM_SEReaders { get; set; } | ||
public SAM_SEDllProgrammingStation SAM_SEDll { get; set; } | ||
|
||
private int stationIndex = 0; | ||
public int SAM_SEStationIndex | ||
{ | ||
get => stationIndex; | ||
set | ||
{ | ||
if (SetProperty(ref stationIndex, value)) | ||
{ | ||
//Stopping all the blinking leds | ||
for (uint i = 0; i < SAM_SEDll.GetNumberSAM_SE(); i++) | ||
{ | ||
SAM_SEDll.BlinkLedId(i, 0); | ||
} | ||
//And making blink the selected one | ||
SAM_SEDll.BlinkLedId((uint)stationIndex, 1); | ||
} | ||
} | ||
} | ||
|
||
private bool refreshList = true; | ||
public bool RefreshList | ||
{ | ||
get => refreshList; | ||
set => SetProperty(ref refreshList, value); | ||
} | ||
|
||
private bool keystorePropertiesErrorEnable = false; | ||
Check notice on line 53 in KeyManager.Library.KeyStore.SAM_SE.UI/Domain/SAM_SEKeyStorePropertiesControlViewModel.cs Codacy Production / Codacy Static Code AnalysisKeyManager.Library.KeyStore.SAM_SE.UI/Domain/SAM_SEKeyStorePropertiesControlViewModel.cs#L53
|
||
public bool KeyStorePropertiesErrorEnable | ||
{ | ||
get => keystorePropertiesErrorEnable; | ||
set => SetProperty(ref keystorePropertiesErrorEnable, value); | ||
} | ||
|
||
private string programmingStation = string.Empty; | ||
public string ProgrammingStation | ||
{ | ||
get => programmingStation; | ||
set | ||
{ | ||
if (SetProperty(ref programmingStation, value)) | ||
{ | ||
if (ProgrammingStation != null) | ||
{ | ||
//Extraction of MAC to identify the SAM-SE | ||
SAM_SEProperties!.SAM_SEMac = ProgrammingStation.Split('\t')[1]; | ||
} | ||
else | ||
{ | ||
SAM_SEProperties!.SAM_SEMac = string.Empty; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public async Task RefreshStationProgrammationList() | ||
{ | ||
try | ||
{ | ||
RefreshList = false; | ||
KeyStorePropertiesErrorEnable = false; | ||
string prevru = ProgrammingStation; | ||
SAM_SEReaders.Clear(); | ||
Mouse.OverrideCursor = Cursors.Wait; | ||
await SAM_SEDll.DetectSAM_SE(); | ||
uint nb = SAM_SEDll.GetNumberSAM_SE(); | ||
for (uint i = 0; i < nb; i++) | ||
{ | ||
SAM_SEDll.BlinkLedId(i, 0); | ||
|
||
String version = SAM_SEDll.GetVersion(i); | ||
String mac = SAM_SEDll.GetMac(i); | ||
String type = SAM_SEDll.GetType(i); | ||
|
||
SAM_SEReaders.Add(type + '\t' + mac + '\t' + version + '\t'); | ||
} | ||
//If we find the old element which was selected before the refresh | ||
if (SAM_SEReaders.Contains(prevru)) | ||
{ | ||
//We select it back and make the Led blink to notify the user | ||
ProgrammingStation = prevru; | ||
SAM_SEDll.BlinkLedId((uint)SAM_SEStationIndex, 1); | ||
} | ||
//If we don't find the old element, and if there is at least one programming station | ||
else if (SAM_SEReaders.Count != 0) | ||
{ | ||
//We select the first one of the list, and we make its Led blink | ||
ProgrammingStation = SAM_SEReaders.First(); | ||
SAM_SEDll.BlinkLedId(0, 1); | ||
} | ||
//If there is no programming station, we put the string as empty | ||
else | ||
{ | ||
ProgrammingStation = string.Empty; | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
KeyStorePropertiesErrorEnable = true; | ||
log.Error(ex); | ||
} | ||
finally | ||
{ | ||
RefreshList = true; | ||
Mouse.OverrideCursor = null; | ||
} | ||
} | ||
} | ||
} |
185 changes: 185 additions & 0 deletions
185
KeyManager.Library.KeyStore.SAM_SE.UI/Domain/SAM_SEKeyStoreToolsControlViewModel.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,185 @@ | ||
using CommunityToolkit.Mvvm.Input; | ||
using Leosac.KeyManager.Library.KeyStore.SAM_SE.UI.Properties; | ||
using Leosac.KeyManager.Library.UI.Domain; | ||
using Leosac.WpfApp; | ||
using System.Windows.Input; | ||
|
||
namespace Leosac.KeyManager.Library.KeyStore.SAM_SE.UI.Domain | ||
{ | ||
public class SAM_SEKeyStoreToolsControlViewModel : KeyStoreAdditionalControlViewModel | ||
{ | ||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod()?.DeclaringType); | ||
public SAM_SEKeyStoreToolsControlViewModel() | ||
{ | ||
SAM_SELockCommand = new RelayCommand(SAM_SELockState); | ||
SAM_SEDefaultConfigFileCommand = new RelayCommand(SAM_SECreateDefaultConfigFile); | ||
} | ||
|
||
public RelayCommand SAM_SEDefaultConfigFileCommand { get; } | ||
public RelayCommand SAM_SELockCommand { get; } | ||
|
||
private string configuration1 = Resources.DESFireModeUid; | ||
public string Configuration1 | ||
{ | ||
get => configuration1; | ||
set | ||
{ | ||
if (SetProperty(ref configuration1, value)) | ||
{ | ||
if (value == Resources.ConfFileDisabled) | ||
{ | ||
Configuration2Displayed = false; | ||
} | ||
else | ||
{ | ||
Configuration2Displayed = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private bool configuration2Displayed = true; | ||
public bool Configuration2Displayed | ||
{ | ||
get => configuration2Displayed; | ||
set | ||
{ | ||
if(SetProperty(ref configuration2Displayed, value)) | ||
{ | ||
if (value == false) | ||
{ | ||
Configuration3Displayed = false; | ||
Configuration4Displayed = false; | ||
} | ||
else | ||
{ | ||
Configuration3Displayed = true; | ||
Configuration4Displayed = false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private string configuration2 = Resources.ConfFileDisabled; | ||
public string Configuration2 | ||
{ | ||
get => configuration2; | ||
set | ||
{ | ||
if (SetProperty(ref configuration2, value)) | ||
{ | ||
if (value == Resources.ConfFileDisabled) | ||
{ | ||
Configuration3Displayed = false; | ||
} | ||
else | ||
{ | ||
Configuration3Displayed = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private bool configuration3Displayed = false; | ||
public bool Configuration3Displayed | ||
{ | ||
get => configuration3Displayed; | ||
set | ||
{ | ||
if (SetProperty(ref configuration3Displayed, value)) | ||
{ | ||
if (value == false) | ||
{ | ||
Configuration4Displayed = false; | ||
} | ||
else | ||
{ | ||
Configuration4Displayed = true; | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
private string configuration3 = Resources.ConfFileDisabled; | ||
public string Configuration3 | ||
{ | ||
get => configuration3; | ||
set | ||
{ | ||
if (SetProperty(ref configuration3, value)) | ||
{ | ||
if (value == Resources.ConfFileDisabled) | ||
{ | ||
Configuration4Displayed = false; | ||
} | ||
else | ||
{ | ||
Configuration4Displayed = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private bool configuration4Displayed = false; | ||
public bool Configuration4Displayed | ||
{ | ||
get => configuration4Displayed; | ||
set => SetProperty(ref configuration4Displayed, value); | ||
} | ||
|
||
private string configuration4 = Resources.ConfFileDisabled; | ||
public string Configuration4 | ||
{ | ||
get => configuration4; | ||
set | ||
{ | ||
SetProperty(ref configuration4, value); | ||
} | ||
} | ||
|
||
private async void SAM_SECreateDefaultConfigFile() | ||
{ | ||
Mouse.OverrideCursor = Cursors.Wait; | ||
try | ||
{ | ||
var ks = (KeyStore as SAM_SEKeyStore); | ||
ks?.GetSAM_SEDll()!.GetCurrentSAM_SE()!.SetDefaultConfigurationFile(); | ||
await ks!.GetAll(); | ||
SnackbarHelper.EnqueueMessage(SnackbarMessageQueue, Resources.ToolsConfFileDefaultOk); | ||
} | ||
catch (Exception ex) | ||
{ | ||
log.Error("Creating default file failed.", ex); | ||
SnackbarHelper.EnqueueError(SnackbarMessageQueue, ex); | ||
} | ||
finally | ||
{ | ||
Mouse.OverrideCursor = null; | ||
} | ||
} | ||
|
||
private void SAM_SELockState() | ||
{ | ||
Mouse.OverrideCursor = Cursors.Wait; | ||
var ks = (KeyStore as SAM_SEKeyStore); | ||
try | ||
{ | ||
ks?.GetSAM_SEDll()!.GetCurrentSAM_SE()!.SetLockLevel(ks!.GetFileProperties().LockedLevel); | ||
SnackbarHelper.EnqueueMessage(SnackbarMessageQueue, Resources.ToolsLockLevelOk); | ||
} | ||
catch (Exception ex) | ||
{ | ||
log.Error("Changing lock level failed.", ex); | ||
SnackbarHelper.EnqueueError(SnackbarMessageQueue, ex); | ||
ks!.GetFileProperties().LockedLevel = ks!.GetSAM_SEDll()!.GetCurrentSAM_SE()!.GetLockLevel(); | ||
ks!.GetFileProperties().DefaultExpanderExpanded = true; | ||
} | ||
finally | ||
{ | ||
ks!.GetFileProperties().LockedLevelExpanded = false; | ||
Mouse.OverrideCursor = null; | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...er.Library.KeyStore.SAM_SE.UI/Domain/SAM_SESymmetricKeyEntryPropertiesControlViewModel.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,45 @@ | ||
using Leosac.KeyManager.Library.Plugin.UI.Domain; | ||
using Leosac.KeyManager.Library.KeyStore.SAM_SE.UI.Properties; | ||
|
||
namespace Leosac.KeyManager.Library.KeyStore.SAM_SE.UI.Domain | ||
{ | ||
public class SAM_SESymmetricKeyEntryPropertiesControlViewModel : KeyEntryPropertiesControlViewModel | ||
{ | ||
public SAM_SESymmetricKeyEntryPropertiesControlViewModel() | ||
{ | ||
Properties = new SAM_SESymmetricKeyEntryProperties(); | ||
} | ||
|
||
public SAM_SESymmetricKeyEntryProperties? SAM_SEProperties | ||
{ | ||
get { return Properties as SAM_SESymmetricKeyEntryProperties; } | ||
} | ||
|
||
public Dictionary<SAM_SESymmetricKeyEntryProperties.SAM_SEKeyEntryType, string> SAM_SE_Key_Entry_Types { get; } = | ||
new Dictionary<SAM_SESymmetricKeyEntryProperties.SAM_SEKeyEntryType, string>() | ||
Check notice on line 19 in KeyManager.Library.KeyStore.SAM_SE.UI/Domain/SAM_SESymmetricKeyEntryPropertiesControlViewModel.cs Codacy Production / Codacy Static Code AnalysisKeyManager.Library.KeyStore.SAM_SE.UI/Domain/SAM_SESymmetricKeyEntryPropertiesControlViewModel.cs#L19
|
||
{ | ||
{SAM_SESymmetricKeyEntryProperties.SAM_SEKeyEntryType.DESFire, Resources.SAM_SEKeyEntryDESFire}, | ||
{SAM_SESymmetricKeyEntryProperties.SAM_SEKeyEntryType.DESFireUID, Resources.SAM_SEKeyEntryDESFireUid}, | ||
{SAM_SESymmetricKeyEntryProperties.SAM_SEKeyEntryType.Authenticate, Resources.SAM_SEKeyEntryAuthenticate}, | ||
}; | ||
|
||
public Dictionary<SAM_SESymmetricKeyEntryPropertiesDESFire.SAM_SEDESFireMode, string> SAM_SE_DESFire_Mode_Text { get; } = | ||
new Dictionary<SAM_SESymmetricKeyEntryPropertiesDESFire.SAM_SEDESFireMode, string>() | ||
{ | ||
{SAM_SESymmetricKeyEntryPropertiesDESFire.SAM_SEDESFireMode.Disable, Resources.DESFireModeDeactivated}, | ||
{SAM_SESymmetricKeyEntryPropertiesDESFire.SAM_SEDESFireMode.IDP, Resources.DESFireModeIdp}, | ||
}; | ||
|
||
public Dictionary<SAM_SESymmetricKeyEntryPropertiesDESFire.SAM_SEDESFireEncryptMode, string> SAM_SE_DESFire_Encrypt { get; } = | ||
new Dictionary<SAM_SESymmetricKeyEntryPropertiesDESFire.SAM_SEDESFireEncryptMode, string>() | ||
{ | ||
{SAM_SESymmetricKeyEntryPropertiesDESFire.SAM_SEDESFireEncryptMode.AES, Resources.DESFireCipherAes}, | ||
}; | ||
|
||
public Dictionary<SAM_SESymmetricKeyEntryPropertiesDESFire.SAM_SEDESFireCommunicationMode, string> SAM_SE_DESFire_Communication { get; } = | ||
new Dictionary<SAM_SESymmetricKeyEntryPropertiesDESFire.SAM_SEDESFireCommunicationMode, string>() | ||
{ | ||
{SAM_SESymmetricKeyEntryPropertiesDESFire.SAM_SEDESFireCommunicationMode.Encrypted, Resources.DESFireCommunicationEncrypted}, | ||
}; | ||
} | ||
} |
Oops, something went wrong.