passwords handling now safe
bin verfify and fix code
This commit is contained in:
@@ -206,6 +206,27 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verify Meter password file
|
||||
/// generated passowrd file has to be present
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-JAn-24" author="Thomas Wiedebusch&Roalnd Drabesch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
|
||||
public Boolean VerifyMeterPwdFile()
|
||||
{
|
||||
if (_hashedPasswordFile == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _meterFile.VerifyMeterFile(StrPasswordFileName, _hashedPasswordFile);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Erase the meter password file
|
||||
/// </summary>
|
||||
|
||||
+21
-12
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using ProductionUiCordonel.ProductionProcesses.Enum;
|
||||
using ProductionUiCordonel.UserControls.FinalTest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Windows.Controls;
|
||||
using Newtonsoft.Json;
|
||||
using ProductionUiCordonel.ProductionProcesses.Enum;
|
||||
using ProductionUiCordonel.UserControls.FinalTest;
|
||||
using Xylem.Common.CommonCore.Configuration;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
|
||||
using Xylem.Common.Logic.SoftwareAccessHelper;
|
||||
@@ -52,8 +52,10 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
Boolean ret = RequestPassword();
|
||||
updateImage(UserControl.RequestPassword, ret);
|
||||
Progress += 16;
|
||||
|
||||
if (Encoding.UTF8.GetString(pwContainer.listOfPasswords.Last()) == pwContainer.Skeleton)//pwContainer.Skeleton )
|
||||
//if password file is written the password from pwContainer (DB) is equal to lvl 8
|
||||
//password being used in production
|
||||
// initailly Password from contain is the Skeletonkey wich can not be in the listofPasswords
|
||||
if (Encoding.UTF8.GetString(pwContainer.listOfPasswords.Last()) == pwContainer.Password)
|
||||
{
|
||||
NewStatus("Passwörter schon geschrieben. Prozess wird übersprungen");
|
||||
currentProcessState = ProductionProcessState.Done;
|
||||
@@ -70,17 +72,20 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
|
||||
if (ret)
|
||||
{
|
||||
ret = WritePasswordFileToMeter();
|
||||
ret = WriteAndVerifyPasswordFileToMeter();
|
||||
}
|
||||
updateImage(UserControl.WriteToMeter, ret);
|
||||
Progress += 16;
|
||||
//Check if new password is in the meter ... even the file write wasn't successful
|
||||
if (!ret)
|
||||
if (ret)
|
||||
{
|
||||
Meter.Logout();
|
||||
ret = Meter.Login(Encoding.UTF8.GetString(pwContainer.listOfPasswords.Last()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Password in Production DB can be updated
|
||||
if (ret)
|
||||
{
|
||||
ret = UpdatePasswordinDb();
|
||||
@@ -95,7 +100,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
updateImage(UserControl.Logout, ret);
|
||||
Progress += 16;
|
||||
|
||||
|
||||
//test the production database password
|
||||
if (ret)
|
||||
{
|
||||
ret = Meter.Login();
|
||||
@@ -123,6 +128,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
public Int64? orderNumber = null;
|
||||
public Int64? radioAdress = null;
|
||||
public String Skeleton = "";
|
||||
public String Password = "";
|
||||
public List<Byte[]> listOfHashes = new List<Byte[]>();
|
||||
public List<Byte[]> listOfPasswords = new List<Byte[]>();
|
||||
}
|
||||
@@ -158,11 +164,14 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
meterPwdFile = new MeterPwdFile(Meter);
|
||||
return meterPwdFile.BuildPwdFile(pwContainer.listOfPasswords, 1, pwContainer.Skeleton);
|
||||
}
|
||||
public Boolean WritePasswordFileToMeter()
|
||||
public Boolean WriteAndVerifyPasswordFileToMeter()
|
||||
{
|
||||
if (meterPwdFile.UnlockEraseWriteMeterPwdFile())
|
||||
{
|
||||
return meterPwdFile.WriteMeterPwdFile();
|
||||
if (meterPwdFile.WriteMeterPwdFile())
|
||||
{
|
||||
return meterPwdFile.VerifyMeterPwdFile();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -324,6 +324,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
public Int64? orderNumber = null;
|
||||
public Int64? radioAdress = null;
|
||||
public String Skeleton = "";
|
||||
public String Password = "";
|
||||
public List<Byte[]> listOfHashes = new List<Byte[]>();
|
||||
public List<Byte[]> listOfPasswords = new List<Byte[]>();
|
||||
|
||||
@@ -383,6 +384,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
sbQuery.AppendLine($" ,[Vergabe_am] ");
|
||||
sbQuery.AppendLine($" ,passwordtbl.KeySetId ");
|
||||
sbQuery.AppendLine($" ,passwordtbl.orderNumber ");
|
||||
sbQuery.AppendLine($" ,passwordtbl.Password ");
|
||||
sbQuery.AppendLine($" ,passwordtbl.KitronSkeletonKey as Skeleton ");
|
||||
sbQuery.AppendLine($" ,passwordtbl.ProcessorID as ProcessorUid ");
|
||||
sbQuery.AppendLine($" FROM [Auftrag].[dbo].[Genesis_Meter] meter ");
|
||||
@@ -410,6 +412,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
result.orderNumber = (Int32)item["FertigungsauftragNr"];
|
||||
result.radioAdress = (Int64)item["Adresse"];
|
||||
result.Skeleton = (String)item["Skeleton"];
|
||||
result.Password = (String)item["Password"];
|
||||
if (item["KeySetId"].GetType() != typeof(System.DBNull))
|
||||
{
|
||||
result.KeySetId = (String)item["KeySetId"];
|
||||
@@ -418,7 +421,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//todo add NA with serailnumber
|
||||
if (!result.orderNumber.HasValue || !result.radioAdress.HasValue)
|
||||
{
|
||||
return Request.CreateResponse(HttpStatusCode.InternalServerError, new PcbIdNotException(new Guid("160B4C44-6EF7-41DC-A48D-4B4105B4779B")));
|
||||
|
||||
Reference in New Issue
Block a user