CUST: - Message corrected on not installed password file

This commit is contained in:
Thomas Wiedebusch
2023-10-27 16:36:16 +02:00
parent 79fa88c4e7
commit 1f47e1b31d
7 changed files with 72 additions and 49 deletions
@@ -1341,14 +1341,14 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
fwUpdateSafe.Updates.CordonelDeviceInfos = _cordonelUpdateList;
////TODO THW remove this DEBUG to map from current selection to TEST BOARD
_cordonelUpdateList[0].CustomerSerialNumber = "8 SEN20 1975 6272";
_cordonelUpdateList[0].PcbId = "182100041";
GetPwdFromDb(_cordonelUpdateList[0]);
fwUpdateSafe.License.Build = 5;
var dateTime = fwUpdateSafe.License.ValidTo.AddDays(-1);
fwUpdateSafe.License.ValidTo = dateTime;
var addDays = fwUpdateSafe.SafeInfo.FwUpdateValidDate.AddDays(-1);
fwUpdateSafe.SafeInfo.FwUpdateValidDate = addDays;
//_cordonelUpdateList[0].CustomerSerialNumber = "8 SEN20 1975 6272";
//_cordonelUpdateList[0].PcbId = "182100041";
//GetPwdFromDb(_cordonelUpdateList[0]);
//fwUpdateSafe.License.Build = 5;
//var dateTime = fwUpdateSafe.License.ValidTo.AddDays(-1);
//fwUpdateSafe.License.ValidTo = dateTime;
//var addDays = fwUpdateSafe.SafeInfo.FwUpdateValidDate.AddDays(-1);
//fwUpdateSafe.SafeInfo.FwUpdateValidDate = addDays;
////TODO THW remove this DEBUG to map from current selection to TEST BOARD
var serializedData = JsonConvert.SerializeObject(fwUpdateSafe);
@@ -51,7 +51,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// Genesis (legacy and program internal name for Cordonel)
private GenesisMeter _currentGenesis;
private readonly MeterBatch _meterBatch;
private Byte[] _hashedPwdFile;
private Byte[] _hashedSafePwdFile;
private String _passwordLvl8;
private String _skeletonKey;
@@ -1580,6 +1580,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// <remarks date="2023-Oct-19" author="Thomas Wiedebusch">
/// - Output message changed to get colored error or success messages.
/// </remarks>
/// <remarks date="2023-Oct-27" author="Thomas Wiedebusch">
/// - Message for uninstalled password file moved from <see cref="ExecConnect"/>ExecConnect to here.
/// </remarks>
private Boolean ReadLogAndCompareMeterPwdFile()
{
if (_currentGenesis == null)
@@ -1591,6 +1594,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// log the password file content
var meterFile = new MeterFile(_currentGenesis);
retVal = meterFile.ReadMeterFile(MeterPwdFile.StrPasswordFileName, out var hashedMeterPwdFile);
// separate all passwords for logging each in an individual line
var hashedPwdList = new List<String>();
if (retVal)
{
@@ -1604,17 +1609,26 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// Here the password file may be corrupted or not installed, read it out and compare it with
// the content specified in the FW update safe
var pwdFile = new MeterPwdFile(_currentGenesis);
_passwordFileIsCorrupted = _hashedPwdFile == null || !pwdFile.VerifyMeterPwdFile(_hashedPwdFile);
_passwordFileIsCorrupted = _hashedSafePwdFile == null || !pwdFile.VerifyMeterPwdFile(_hashedSafePwdFile);
if (!_passwordFileIsCorrupted)
{
LogStringList(Resources.StrMessageHashedPwdFile, hashedPwdList,
Resources.StrInstalledPasswordFileComparedSuccessful);
Resources.StrPasswordFileComparedSucceeded);
}
else
{
LogStringList(Resources.StrMessageHashedPwdFile, hashedPwdList,
errorMessage: Resources.StrInstalledPasswordFileCompareFailed);
if (hashedMeterPwdFile == null || hashedMeterPwdFile.Count == 0)
{
// log information about password file is not installed, but go ahead as usual
InfoProcessFailed(null, Resources.StrPasswordFileNotInstalled);
}
else
{
// password file is suspicious
LogStringList(Resources.StrMessageHashedPwdFile, hashedPwdList,
errorMessage: Resources.StrPasswordFileCompareFailed);
}
}
}
catch (Exception)
@@ -2995,6 +3009,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// <remarks date="2023-Oct-18" author="Thomas Wiedebusch">
/// - Avoid report file generation on finalLoginAfterUpdate.
/// </remarks>
/// <remarks date="2023-Oct-27" author="Thomas Wiedebusch">
/// - Message moved to <see cref="ReadLogAndCompareMeterPwdFile"/>.
/// </remarks>
private Boolean ExecConnect()
{
// If the PCB ID is not set (read from meter) this is the first initial login.
@@ -3020,8 +3037,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
if (!string.IsNullOrEmpty(device.CustomerSerialNumber))
_customerSerialNumber = device.CustomerSerialNumber;
_hashedPwdFile = new Byte[MeterPwdDb.PwdFileLength];
_hashedPwdFile = device.PwdContainer.EncryptedPasswordFile;
// extract the hashed safe password file for validation
_hashedSafePwdFile = new Byte[MeterPwdDb.PwdFileLength];
_hashedSafePwdFile = device.PwdContainer.EncryptedPasswordFile;
_genesisInUpdateList = true;
break;
@@ -3211,12 +3229,6 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
return;
}
// log information about password file is not installed, but go ahead as usual
if (_passwordFileIsCorrupted)
{
InfoProcessFailed(null, Resources.StrPasswordFileNotInstalled);
}
_meterFwUpdate?.AssignGenesis(_currentGenesis);
// if authentication succeeded, the cordonel port detection must have succeeded in advance,
@@ -3725,6 +3737,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// <remarks date="2023-Oct-24" author="Thomas Wiedebusch">
/// - Read and log password file after restoring.
/// </remarks>
/// <remarks date="2023-Oct-27" author="Thomas Wiedebusch">
/// - Removed check for password file length, leave it to the <see cref="MeterPwdFile.CheckHashedPwdFile"/>
/// </remarks>
private void RestorePasswordFile(ProcessState successExitState, ProcessState errorExitState = ProcessState.Error)
{
// remind the invoker being able to generate error messages based on the last state
@@ -3741,15 +3756,14 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
InfoProcessActive(lblPasswordFileCheck, Resources.StrPasswordFileRestoreActive);
// try to install password, first get the password file from device info
var pwdFileObject = new MeterPwdFile(_currentGenesis);
if (_hashedPwdFile != null &&
_hashedPwdFile.Length == MeterPwdDb.PwdFileLength &&
pwdFileObject.CheckHashedPwdFile(_hashedPwdFile , _skeletonKey, _passwordLvl8))
if (_hashedSafePwdFile != null &&
pwdFileObject.CheckHashedPwdFile(_hashedSafePwdFile , _skeletonKey, _passwordLvl8))
{
SetControlsCommunicationActive();
_currentGenesis?.ReLogin();
if (pwdFileObject.UnlockEraseWriteMeterPwdFile())
{
if (pwdFileObject.WriteAndVerifyMeterPwdFile(_hashedPwdFile) &&
if (pwdFileObject.WriteAndVerifyMeterPwdFile(_hashedSafePwdFile) &&
ReadLogAndCompareMeterPwdFile())
{
// a reconnect will check for proper installed password file and check the Level 8 pwd.
@@ -538,24 +538,6 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Installed password file is equal to required password file..
/// </summary>
internal static string StrInstalledPasswordFileComparedSuccessful {
get {
return ResourceManager.GetString("StrInstalledPasswordFileComparedSuccessful", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to ERROR: Installed password file is unequal to required file!.
/// </summary>
internal static string StrInstalledPasswordFileCompareFailed {
get {
return ResourceManager.GetString("StrInstalledPasswordFileCompareFailed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to ERROR: Failed to restore items after change of language!.
/// </summary>
@@ -745,6 +727,24 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Installed password file is equal to required password file..
/// </summary>
internal static string StrPasswordFileComparedSucceeded {
get {
return ResourceManager.GetString("StrPasswordFileComparedSucceeded", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to ERROR: Installed password file is unequal to required file!.
/// </summary>
internal static string StrPasswordFileCompareFailed {
get {
return ResourceManager.GetString("StrPasswordFileCompareFailed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to ERROR: Password file from FW update safe is invalid!.
/// </summary>
@@ -577,10 +577,10 @@
<data name="StrRegisterRecoverySucceeded" xml:space="preserve">
<value>Konfigurationswiederherstellung erfolgreich.</value>
</data>
<data name="StrInstalledPasswordFileComparedSuccessful" xml:space="preserve">
<data name="StrPasswordFileComparedSucceeded" xml:space="preserve">
<value>Intallierte Paßwortdatei entspricht der geforderten.</value>
</data>
<data name="StrInstalledPasswordFileCompareFailed" xml:space="preserve">
<data name="StrPasswordFileCompareFailed" xml:space="preserve">
<value>FEHLER: Installierte Paßwortdatei entspricht nicht der geforderten!</value>
</data>
<data name="StrTestReporSafeName" xml:space="preserve">
@@ -577,10 +577,10 @@
<data name="StrRegisterRecoverySucceeded" xml:space="preserve">
<value>Configuration recovery succeeded.</value>
</data>
<data name="StrInstalledPasswordFileComparedSuccessful" xml:space="preserve">
<data name="StrPasswordFileComparedSucceeded" xml:space="preserve">
<value>Installed password file is equal to required password file.</value>
</data>
<data name="StrInstalledPasswordFileCompareFailed" xml:space="preserve">
<data name="StrPasswordFileCompareFailed" xml:space="preserve">
<value>ERROR: Installed password file is unequal to required file!</value>
</data>
<data name="StrTestReporSafeName" xml:space="preserve">