DB.SensusOracle.DatabaseCfg : database access passwords are not readable

This commit is contained in:
Milan Hanajik 2021-10-01 13:41:21 +02:00
parent b5e2a7bdc9
commit 13b30b2caf
2 changed files with 47 additions and 14 deletions

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2019 Sensus Slovensko a.s.
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@ -15,6 +15,9 @@ namespace TBF.Rig.Output.DB.SensusOracle
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(DatabaseCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
static readonly string AkaPwd = "········";
static readonly string AkaPwd1 = "·"; /// One character only
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities)
{
return new Configs.ParamsProvider.ComponentCfgCtrl(this, null);
@ -96,13 +99,13 @@ namespace TBF.Rig.Output.DB.SensusOracle
{
case 0: return ProductionDataSource;
case 1: return ProductionUserId;
case 2: return ProductionPassword;
case 2: return AkaPwd;
case 3: return QualityDataSource;
case 4: return QualityUserId;
case 5: return QualityPassword;
case 5: return AkaPwd;
case 6: return TestDataSource;
case 7: return TestUserId;
case 8: return TestPassword;
case 8: return AkaPwd;
case 9: return ProducerId.ToString();
default:
return string.Format("{0}: Production={1} Quality={2} Test={3}",
@ -119,13 +122,40 @@ namespace TBF.Rig.Output.DB.SensusOracle
{
case 0: ProductionDataSource = str; return CfgUpdateFlags.RestartRqrd;
case 1: ProductionUserId = str; return CfgUpdateFlags.RestartRqrd;
case 2: ProductionPassword = str; return CfgUpdateFlags.RestartRqrd;
case 2:
if (!str.Contains(AkaPwd1))
{
ProductionPassword = str;
return CfgUpdateFlags.RestartRqrd;
}
else
{
return CfgUpdateFlags.None;
}
case 3: QualityDataSource = str; return CfgUpdateFlags.RestartRqrd;
case 4: QualityUserId = str; return CfgUpdateFlags.RestartRqrd;
case 5: QualityPassword = str; return CfgUpdateFlags.RestartRqrd;
case 5:
if (!str.Contains(AkaPwd1))
{
QualityPassword = str;
return CfgUpdateFlags.RestartRqrd;
}
else
{
return CfgUpdateFlags.None;
}
case 6: TestDataSource = str; return CfgUpdateFlags.RestartRqrd;
case 7: TestUserId = str; return CfgUpdateFlags.RestartRqrd;
case 8: TestPassword = str; return CfgUpdateFlags.RestartRqrd;
case 8:
if (!str.Contains(AkaPwd1))
{
TestPassword = str;
return CfgUpdateFlags.RestartRqrd;
}
else
{
return CfgUpdateFlags.None;
}
case 9: ProducerId = int.Parse(str); return CfgUpdateFlags.RestartRqrd;
default:
return CfgUpdateFlags.None;

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using log4net;
using Common;
using Config.Entities;
using Results.Output;
@ -16,7 +17,8 @@ namespace TBF.Rig.Output.DB.SensusOracle
{
public class ProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcedureParams) })[0];
private static readonly ILog log = LogManager.GetLogger(typeof(ProcedureParams));
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcedureParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public DBUsed DBUsed; /// 0
@ -140,11 +142,11 @@ namespace TBF.Rig.Output.DB.SensusOracle
}
break;
case 2: WMTypeId = int.Parse(strValue); break;
case 3: YearOfManufacture = int.Parse(strValue); break;
case 4: SaveResults = (strValue == Strings.yes); break;
case 5: ReadStartInfo = (strValue == Strings.yes); break;
case 6: StartInfoIsRequired = (strValue == Strings.yes); break;
case 2: WMTypeId = int.Parse(strValue); return CfgUpdateFlags.None;
case 3: YearOfManufacture = int.Parse(strValue); return CfgUpdateFlags.None;
case 4: SaveResults = (strValue == Strings.yes); return CfgUpdateFlags.None;
case 5: ReadStartInfo = (strValue == Strings.yes); return CfgUpdateFlags.None;
case 6: StartInfoIsRequired = (strValue == Strings.yes); return CfgUpdateFlags.None;
case 7:
for (DesigMode db = 0; db < DesigMode.Count; db++)
@ -267,8 +269,9 @@ namespace TBF.Rig.Output.DB.SensusOracle
if (tmp != null) tmp.CopyContentTo(this);
}
catch
catch (Exception exc)
{
log.ErrorFormat("Failed to UpdateFromDbEntity({0}): {1}", dbEntity, exc.Message);
}
}