Fix licenza user da SMART (reset CF + user key)

This commit is contained in:
Samuele Locatelli
2021-11-15 17:03:41 +01:00
parent f24268856e
commit aae30162f0
9 changed files with 223 additions and 191 deletions
+57 -45
View File
@@ -39,6 +39,51 @@ namespace GPW_data
#region Private Properties
/// <summary>
/// Info applicativo corrente (da cache con eventuale recupero online...)
/// </summary>
private static LiManObj.ApplicativoDTO InfoApplicativo
{
get
{
LiManObj.ApplicativoDTO answ = new LiManObj.ApplicativoDTO();
// cerco da cache
string rawData = memLayer.ML.getRSV(rkeyLicInfo);
// se no ci fosse --> refresh online!
if (string.IsNullOrEmpty(rawData))
{
var fatto = RefreshAppInfo().Result;
if (fatto)
{
rawData = memLayer.ML.getRSV(rkeyLicInfo);
}
}
if (!string.IsNullOrEmpty(rawData))
{
try
{
// verifico se ho 1 risultato o molti...se inizia per "[" è molti
if (rawData.StartsWith("["))
{
// POTREBBE darmi + di 1 risultato, prendo + recente...
List<LiManObj.ApplicativoDTO> infoList = JsonConvert.DeserializeObject<List<LiManObj.ApplicativoDTO>>(rawData);
if (infoList != null)
{
answ = infoList.OrderByDescending(x => x.Scadenza).FirstOrDefault();
}
}
else
{
answ = JsonConvert.DeserializeObject<LiManObj.ApplicativoDTO>(rawData);
}
}
catch
{ }
}
return answ;
}
}
/// <summary>
/// Durata cache statica locale dati licenza, random circa 1 h
/// </summary>
@@ -51,6 +96,8 @@ namespace GPW_data
}
}
private static LiManObj.ApplicativoDTO myInfoApplicativo { get; set; }
#endregion Private Properties
#region Public Properties
@@ -134,7 +181,7 @@ namespace GPW_data
/// </summary>
private static int _attivazioniOnline()
{
return InfoApplicativo().NumLicenzeAttive;
return InfoApplicativo.NumLicenzeAttive;
}
/// <summary>
@@ -270,7 +317,7 @@ namespace GPW_data
/// </summary>
private static int _licenzeOnline()
{
return InfoApplicativo().NumLicenze;
return InfoApplicativo.NumLicenze;
}
/// <summary>
@@ -423,48 +470,6 @@ namespace GPW_data
return answ;
}
/// <summary>
/// Info applicativo corrente (da cache con eventuale recupero online...)
/// </summary>
private static LiManObj.ApplicativoDTO InfoApplicativo()
{
LiManObj.ApplicativoDTO answ = new LiManObj.ApplicativoDTO();
// cerco da cache
string rawData = memLayer.ML.getRSV(rkeyLicInfo);
// se no ci fosse --> refresh online!
if (string.IsNullOrEmpty(rawData))
{
var fatto = RefreshAppInfo().Result;
if (fatto)
{
rawData = memLayer.ML.getRSV(rkeyLicInfo);
}
}
if (!string.IsNullOrEmpty(rawData))
{
try
{
// verifico se ho 1 risultato o molti...se inizia per "[" è molti
if (rawData.StartsWith("["))
{
// POTREBBE darmi + di 1 risultato, prendo + recente...
List<LiManObj.ApplicativoDTO> infoList = JsonConvert.DeserializeObject<List<LiManObj.ApplicativoDTO>>(rawData);
if (infoList != null)
{
answ = infoList.OrderByDescending(x => x.Scadenza).FirstOrDefault();
}
}
else
{
answ = JsonConvert.DeserializeObject<LiManObj.ApplicativoDTO>(rawData);
}
}
catch
{ }
}
return answ;
}
private static void tryCheckPayloadOnline(ref bool answ, ref string currPayload)
{
try
@@ -478,7 +483,14 @@ namespace GPW_data
memLayer.ML.setRSV(rkeyPayload, currPayload, LicCacheTTL);
}
// confronto payload calc con quello della licenza
answ = InfoApplicativo().Payload == currPayload;
var currInfo = InfoApplicativo;
answ = (InfoApplicativo.Payload == currPayload);
// se fallisce --> resetto payload calcolato
if (!answ)
{
memLayer.ML.setRSV(rkeyAppInfo, "", 1);
memLayer.ML.setRSV(rkeyPayload, "", 1);
}
}
catch
{ }
@@ -8,7 +8,7 @@
<asp:ObjectDataSource ID="odsDipendenti" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="getByConditio" TypeName="GPW_data.DS_UtilityTableAdapters.v_selDipendentiTableAdapter">
<SelectParameters>
<asp:Parameter DefaultValue="true" Name="Conditio" Type="Boolean" />
<asp:Parameter DefaultValue="false" Name="Conditio" Type="Boolean" />
</SelectParameters>
</asp:ObjectDataSource>
</div>
+35 -33
View File
@@ -1,68 +1,70 @@
//------------------------------------------------------------------------------
// <generato automaticamente>
// Codice generato da uno strumento.
// <auto-generated>
// This code was generated by a tool.
//
// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se
// il codice viene rigenerato.
// </generato automaticamente>
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GPW.WebUserControls {
public partial class mod_enrollByAuthKey {
namespace GPW.WebUserControls
{
public partial class mod_enrollByAuthKey
{
/// <summary>
/// Controllo ddlIdxDipendente.
/// ddlIdxDipendente control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.DropDownList ddlIdxDipendente;
/// <summary>
/// Controllo odsDipendenti.
/// odsDipendenti control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.ObjectDataSource odsDipendenti;
/// <summary>
/// Controllo txtUserAuthKey.
/// txtUserAuthKey control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtUserAuthKey;
/// <summary>
/// Controllo lblWarning.
/// lblWarning control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblWarning;
/// <summary>
/// Controllo btnConferma.
/// btnConferma control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnConferma;
/// <summary>
/// Controllo btnAnnulla.
/// btnAnnulla control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnAnnulla;
}
@@ -11,7 +11,7 @@
<asp:ObjectDataSource ID="odsDipendenti" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="getByConditio" TypeName="GPW_data.DS_UtilityTableAdapters.v_selDipendentiTableAdapter">
<SelectParameters>
<asp:Parameter DefaultValue="true" Name="Conditio" Type="Boolean" />
<asp:Parameter DefaultValue="false" Name="Conditio" Type="Boolean" />
</SelectParameters>
</asp:ObjectDataSource>
</div>
@@ -11,43 +11,8 @@ namespace GPW.WebUserControls
{
public partial class mod_resetUserAuthKey : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
#region Protected Methods
}
/// <summary>
/// salvo nuovo device...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnConferma_Click(object sender, EventArgs e)
{
// controllo se ho i dati...
string UserAuthKey = txtUserAuthKey.Text.Trim();
string AuthKey = txtAuthKey.Text.Trim();
int idxDip = 0;
try
{
idxDip = Convert.ToInt32(ddlIdxDipendente.SelectedValue);
}
catch
{ }
// controllo password...
if (AuthKey == memLayer.ML.confReadString("authKey"))
{
// calcolo il secret...
string md5UserAuthKey = SteamCrypto.EncryptString(UserAuthKey, "AuthGPW");
DataProxy.DP.taDipendenti.stp_Dip_setAuthKey(idxDip, md5UserAuthKey);
// mostro esito!
lblWarning.Text = string.Format("AuthKey utente {0} aggiornata", idxDip);
lblWarning.Visible = true;
}
else
{
lblWarning.Text = "Key errata";
lblWarning.Visible = true;
}
}
/// <summary>
/// resetto tutto
/// </summary>
@@ -60,5 +25,54 @@ namespace GPW.WebUserControls
txtUserAuthKey.Text = "";
lblWarning.Visible = false;
}
/// <summary>
/// salvo nuovo device...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnConferma_Click(object sender, EventArgs e)
{
// controllo se ho i dati...
string UserAuthKey = txtUserAuthKey.Text.Trim();
string AuthKey = txtAuthKey.Text.Trim();
int idxDip = 0;
bool fatto = false;
try
{
idxDip = Convert.ToInt32(ddlIdxDipendente.SelectedValue);
}
catch
{ }
// controllo password...
if (AuthKey == memLayer.ML.confReadString("authKey"))
{
if (idxDip > 0)
{
var dipRow = DataProxy.DP.getRowDip(idxDip);
if (dipRow != null)
{
// calcolo il secret...
string md5UserAuthKey = SteamCrypto.EncryptString(UserAuthKey, "AuthGPW").ToLowerInvariant();
DataProxy.DP.taDipendenti.stp_Dip_setAuthKey(idxDip, $"{dipRow.CF}.{md5UserAuthKey}");
// mostro esito!
lblWarning.Text = string.Format("AuthKey utente {0} aggiornata", idxDip);
lblWarning.Visible = true;
fatto = true;
}
}
}
if (!fatto)
{
lblWarning.Text = "Key errata";
lblWarning.Visible = true;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
#endregion Protected Methods
}
}
@@ -1,95 +1,97 @@
//------------------------------------------------------------------------------
// <generato automaticamente>
// Codice generato da uno strumento.
// <auto-generated>
// This code was generated by a tool.
//
// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se
// il codice viene rigenerato.
// </generato automaticamente>
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GPW.WebUserControls {
public partial class mod_resetUserAuthKey {
namespace GPW.WebUserControls
{
public partial class mod_resetUserAuthKey
{
/// <summary>
/// Controllo ddlIdxDipendente.
/// ddlIdxDipendente control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.DropDownList ddlIdxDipendente;
/// <summary>
/// Controllo odsDipendenti.
/// odsDipendenti control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.ObjectDataSource odsDipendenti;
/// <summary>
/// Controllo txtUserAuthKey.
/// txtUserAuthKey control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtUserAuthKey;
/// <summary>
/// Controllo rfvUserAuthKey.
/// rfvUserAuthKey control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvUserAuthKey;
/// <summary>
/// Controllo txtAuthKey.
/// txtAuthKey control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtAuthKey;
/// <summary>
/// Controllo rfvAuthKey.
/// rfvAuthKey control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.RequiredFieldValidator rfvAuthKey;
/// <summary>
/// Controllo lblWarning.
/// lblWarning control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblWarning;
/// <summary>
/// Controllo lbtConferma.
/// lbtConferma control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.LinkButton lbtConferma;
/// <summary>
/// Controllo lbtAnnulla.
/// lbtAnnulla control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.LinkButton lbtAnnulla;
}
@@ -8,7 +8,7 @@
<asp:ObjectDataSource ID="odsDipendenti" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="getByConditio" TypeName="GPW_data.DS_UtilityTableAdapters.v_selDipendentiTableAdapter">
<SelectParameters>
<asp:Parameter DefaultValue="true" Name="Conditio" Type="Boolean" />
<asp:Parameter DefaultValue="false" Name="Conditio" Type="Boolean" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:Label runat="server" ID="lblWarning" Visible="false" />
+31 -29
View File
@@ -1,59 +1,61 @@
//------------------------------------------------------------------------------
// <generato automaticamente>
// Codice generato da uno strumento.
// <auto-generated>
// This code was generated by a tool.
//
// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se
// il codice viene rigenerato.
// </generato automaticamente>
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GPW.WebUserControls {
public partial class mod_sendAuthToEmail {
namespace GPW.WebUserControls
{
public partial class mod_sendAuthToEmail
{
/// <summary>
/// Controllo ddlIdxDipendente.
/// ddlIdxDipendente control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.DropDownList ddlIdxDipendente;
/// <summary>
/// Controllo odsDipendenti.
/// odsDipendenti control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.ObjectDataSource odsDipendenti;
/// <summary>
/// Controllo lblWarning.
/// lblWarning control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblWarning;
/// <summary>
/// Controllo lbtSendEmail.
/// lbtSendEmail control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.LinkButton lbtSendEmail;
/// <summary>
/// Controllo lbtAnnulla.
/// lbtAnnulla control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.LinkButton lbtAnnulla;
}