diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 542ab049..755f4210 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -296,8 +296,6 @@ STAT:release:
paths:
- publish/
script:
- - dotnet publish -c Release -o ./publish MP.Land/MP.Land.csproj
- - dotnet publish -c Release -o ./publish MP.Prog/MP.Prog.csproj
- dotnet publish -c Release -o ./publish MP.Stats/MP.Stats.csproj
diff --git a/Egw.Core/Egw.Core.csproj b/Egw.Core/Egw.Core.csproj
new file mode 100644
index 00000000..132c02c5
--- /dev/null
+++ b/Egw.Core/Egw.Core.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/Egw.Core/LiManObj.cs b/Egw.Core/LiManObj.cs
new file mode 100644
index 00000000..c6e409f8
--- /dev/null
+++ b/Egw.Core/LiManObj.cs
@@ -0,0 +1,220 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Egw.Core
+{
+ public class LiManObj
+ {
+ #region Public Enums
+
+ public enum StatoRichiesta
+ {
+ ND = 0,
+
+ Richiesta,
+
+ Valutazione,
+
+ Approvata,
+
+ Rifiutata
+ }
+
+ public enum TipoLicenza
+ {
+ ND = 0,
+
+ ///
+ /// Licenza LEgacy Steamware
+ ///
+ GLS,
+
+ ///
+ /// Master Key License, che ha una data di scadenza globale ed un token = numero di utenti/token massimi associati
+ ///
+ MasterKey,
+
+ ///
+ /// UserKey License (licenza che consuma un token utente della licenza master) - es GPW
+ ///
+ UserKey,
+
+ ///
+ /// Chiave tiupo Checksum basata su licenza masster + checksum MD5 di una serie di dati (child licenses)
+ ///
+ CheckSumKey
+ }
+
+ #endregion Public Enums
+
+ #region Public Classes
+
+ public class ApplicativoDTO
+ {
+ #region Public Properties
+
+ public string Chiave { get; set; } = "";
+ public string CodApp { get; set; } = "";
+ public string CodInst { get; set; } = "";
+ public DateTime DataEnigma { get; set; } = DateTime.Today.AddYears(-1);
+ public string Descrizione { get; set; } = "";
+ public string Enigma { get; set; } = "";
+ public int IdxLic { get; set; } = 0;
+
+ public bool IsActive
+ {
+ get => (Scadenza.Subtract(DateTime.Today).TotalDays > 0);
+ }
+
+ public bool Locked { get; set; } = false;
+ public int NumLicenze { get; set; } = 0;
+ public int NumLicenzeAttive { get; set; } = 0;
+ public string Payload { get; set; } = "";
+ public DateTime Scadenza { get; set; } = DateTime.Today.AddYears(-1);
+ public TipoLicenza Tipo { get; set; } = TipoLicenza.ND;
+
+ #endregion Public Properties
+ }
+
+ public class AttivazioneDTO
+ {
+ #region Public Properties
+
+ public string Chiave { get; set; } = "";
+ public string CodApp { get; set; } = "";
+ public string CodImpiego { get; set; } = "";
+ public string CodInst { get; set; } = "";
+ public string Descrizione { get; set; } = "";
+ public int IdxLic { get; set; } = 0;
+ public int IdxSubLic { get; set; } = 0;
+ public TipoLicenza Tipo { get; set; } = TipoLicenza.UserKey;
+ public DateTime VetoUnlock { get; set; } = DateTime.Today.AddMonths(2);
+
+ #endregion Public Properties
+ }
+
+ public class LicenseCoord
+ {
+ #region Public Properties
+
+ public string CodApp { get; set; } = "";
+ public string CodInst { get; set; } = "";
+ public string Enigma { get; set; } = "";
+ public string MasterKey { get; set; } = "";
+
+ #endregion Public Properties
+ }
+
+ public class SupportRequest
+ {
+ #region Public Properties
+
+ public string CodApp { get; set; } = "";
+ public string CodImp { get; set; } = "";
+ public string CodInst { get; set; } = "";
+ public string ContactEmail { get; set; } = "";
+ public string ContactName { get; set; } = "";
+ public string ContactPhone { get; set; } = "";
+ public int idxSubLic { get; set; } = 0;
+
+ public bool IsValid
+ {
+ get => !string.IsNullOrEmpty(MasterKey) && !string.IsNullOrEmpty(ContactName) && !string.IsNullOrEmpty(ContactEmail) && !string.IsNullOrEmpty(CodInst) && !string.IsNullOrEmpty(CodApp);
+ }
+
+ public string MasterKey { get; set; } = "";
+ public string ReqBody { get; set; } = "";
+
+ #endregion Public Properties
+ }
+
+ ///
+ /// Oggetto Ticket
+ ///
+ public class TicketDTO
+ {
+ #region Public Properties
+
+ ///
+ /// Codice univoco della sub licenza (opzionale)
+ ///
+ public string CodImpiego { get; set; } = "";
+
+ ///
+ /// Contatto email del cliente richiedente
+ ///
+ public string ContactEmail { get; set; } = "";
+
+ ///
+ /// Contatto del cliente richiedente
+ ///
+ public string ContactName { get; set; } = "";
+
+ ///
+ /// Contatto telefonico del cliente richiedente
+ ///
+ public string ContactPhone { get; set; } = "";
+
+ public DateTime DtReq { get; set; } = DateTime.Now;
+
+ ///
+ /// IDX licenza master
+ ///
+ public int IdxLic { get; set; } = 0;
+
+ ///
+ /// IDX licenza child (opzionale)
+ ///
+ public int IdxSubLic { get; set; } = 0;
+
+ public int IdxTicket { get; set; } = 0;
+
+ ///
+ /// Motivazione della richiesta
+ ///
+ public string ReqBody { get; set; } = "";
+
+ ///
+ /// Stato richiesta
+ ///
+ public StatoRichiesta Status { get; set; } = StatoRichiesta.ND;
+
+ ///
+ /// Risposta alla richiesta
+ ///
+ public string SupplAnsw { get; set; } = "";
+
+ ///
+ /// Email del responsabile dell'azione (interno - supplier)
+ ///
+ public string SupplEmail { get; set; } = "";
+
+ ///
+ /// Cod dell'user responsabile dell'azione (interno - supplier)
+ ///
+ public string SupplUserCode { get; set; } = "";
+
+ ///
+ /// Tipologia di licenza gestita
+ ///
+ public TipoLicenza Tipo { get; set; } = TipoLicenza.UserKey;
+
+ #endregion Public Properties
+ }
+
+ public class UserLicenseRequest
+ {
+ #region Public Properties
+
+ public string MasterKey { get; set; } = "";
+ public Dictionary ParamDict { get; set; } = new Dictionary();
+
+ #endregion Public Properties
+ }
+
+ #endregion Public Classes
+ }
+}
diff --git a/Egw.Core/SteamCrypto.cs b/Egw.Core/SteamCrypto.cs
new file mode 100644
index 00000000..1f021d25
--- /dev/null
+++ b/Egw.Core/SteamCrypto.cs
@@ -0,0 +1,186 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Egw.Core
+{
+ ///
+ /// utils x cifrature e Crypto
+ ///
+ public class SteamCrypto
+ {
+ #region Public Methods
+
+ ///
+ /// decifra un messaggio con una password
+ ///
+ ///
+ ///
+ ///
+ public static string DecryptString(string Message, string Passphrase)
+ {
+ string answ = Message;
+ byte[] Results = null;
+ UTF8Encoding UTF8 = new UTF8Encoding();
+
+ // Step 1. We hash the passphrase using MD5
+ // We use the MD5 hash generator as the result is a 128 bit byte array
+ // which is a valid length for the TripleDES encoder we use below
+
+ MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
+ byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase));
+
+ // Step 2. Create a new TripleDESCryptoServiceProvider object
+ TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();
+
+ // Step 3. Setup the decoder
+ TDESAlgorithm.Key = TDESKey;
+ TDESAlgorithm.Mode = CipherMode.ECB;
+ TDESAlgorithm.Padding = PaddingMode.PKCS7;
+
+ // Step 4. Convert the input string to a byte[]
+ byte[] DataToDecrypt = null;
+ try
+ {
+ DataToDecrypt = Convert.FromBase64String(Message);
+ }
+ catch
+ { }
+ if (DataToDecrypt != null)
+ {
+ // Step 5. Attempt to decrypt the string
+ try
+ {
+ ICryptoTransform Decryptor = TDESAlgorithm.CreateDecryptor();
+ Results = Decryptor.TransformFinalBlock(DataToDecrypt, 0, DataToDecrypt.Length);
+ }
+ finally
+ {
+ // Clear the TripleDes and Hashprovider services of any sensitive information
+ TDESAlgorithm.Clear();
+ HashProvider.Clear();
+ }
+ // Step 6. Return the decrypted string in UTF8 format
+ answ = UTF8.GetString(Results);
+ }
+ return answ;
+ }
+
+ ///
+ /// cifra un messaggio con una password
+ ///
+ ///
+ ///
+ ///
+ public static string EncryptString(string Message, string Passphrase)
+ {
+ byte[] Results;
+ UTF8Encoding UTF8 = new UTF8Encoding();
+
+ // Step 1. We hash the passphrase using MD5
+ // We use the MD5 hash generator as the result is a 128 bit byte array
+ // which is a valid length for the TripleDES encoder we use below
+
+ MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
+ byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase));
+
+ // Step 2. Create a new TripleDESCryptoServiceProvider object
+ TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();
+
+ // Step 3. Setup the encoder
+ TDESAlgorithm.Key = TDESKey;
+ TDESAlgorithm.Mode = CipherMode.ECB;
+ TDESAlgorithm.Padding = PaddingMode.PKCS7;
+
+ // Step 4. Convert the input string to a byte[]
+ byte[] DataToEncrypt = UTF8.GetBytes(Message);
+
+ // Step 5. Attempt to encrypt the string
+ try
+ {
+ ICryptoTransform Encryptor = TDESAlgorithm.CreateEncryptor();
+ Results = Encryptor.TransformFinalBlock(DataToEncrypt, 0, DataToEncrypt.Length);
+ }
+ finally
+ {
+ // Clear the TripleDes and Hashprovider services of any sensitive information
+ TDESAlgorithm.Clear();
+ HashProvider.Clear();
+ }
+
+ // Step 6. Return the encrypted string as a base64 encoded string
+ return Convert.ToBase64String(Results);
+ }
+
+ ///
+ /// genera hash di una stringa in MD5 (es x hash gravatar)
+ ///
+ ///
+ ///
+ public static string getHashStringMD5(string Message)
+ {
+ string hash = "";
+ using (MD5 md5Hash = MD5.Create())
+ {
+ hash = GetMd5Hash(md5Hash, Message);
+ }
+ return hash;
+ }
+
+ ///
+ /// Crea un hash MD5
+ ///
+ ///
+ ///
+ ///
+ public static string GetMd5Hash(MD5 md5Hash, string input)
+ {
+ // Convert the input string to a byte array and compute the hash.
+ byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
+
+ // Create a new Stringbuilder to collect the bytes
+ // and create a string.
+ StringBuilder sBuilder = new StringBuilder();
+
+ // Loop through each byte of the hashed data
+ // and format each one as a hexadecimal string.
+ for (int i = 0; i < data.Length; i++)
+ {
+ sBuilder.Append(data[i].ToString("x2"));
+ }
+
+ // Return the hexadecimal string.
+ return sBuilder.ToString();
+ }
+
+ ///
+ /// Verify a hash against a string.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool VerifyMd5Hash(MD5 md5Hash, string input, string hash)
+ {
+ // Hash the input.
+ string hashOfInput = GetMd5Hash(md5Hash, input);
+
+ // Create a StringComparer an compare the hashes.
+ StringComparer comparer = StringComparer.OrdinalIgnoreCase;
+
+ if (0 == comparer.Compare(hashOfInput, hash))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ #endregion Public Methods
+ }
+}
\ No newline at end of file
diff --git a/Egw.Core/licenseManGLS.cs b/Egw.Core/licenseManGLS.cs
new file mode 100644
index 00000000..616ba977
--- /dev/null
+++ b/Egw.Core/licenseManGLS.cs
@@ -0,0 +1,98 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Egw.Core
+{
+ ///
+ /// Gestione licenze applicativi GLS (Legacy SteamWare)
+ ///
+ public class licenseManGLS
+ {
+ #region Public Methods
+
+ ///
+ /// restituisce data decodificata da authKey + applicazione + cliente...
+ ///
+ /// The cliente.
+ /// The applicativo.
+ /// The licenze.
+ /// The authentication key.
+ ///
+ public static DateTime expiryDateByAuthKey(string cliente, string applicativo, int licenze, string authKey)
+ {
+ DateTime answ = DateTime.Today.AddYears(-10);
+
+ string plainAuthKey = "";
+ try
+ {
+ string passPhrase = string.Format("{0}|{1}", cliente.PadLeft(50, ':'), applicativo);
+ plainAuthKey = SteamCrypto.DecryptString(authKey, passPhrase); // uso combinazione cliente+applicativo come passphrase!
+ answ = Convert.ToDateTime(plainAuthKey.Replace(string.Format("{0}#{1}-", cliente, applicativo.PadLeft(20, '-')), "").Replace(string.Format("%{0}%", licenze), ""));
+ }
+ catch (Exception exc)
+ {
+ //logger.lg.scriviLog(string.Format("Errore decodifica auth key:{0}AuthKey: {1}{0}cliente:{2}{0}applicativo:{3}{0}errore:{4}", Environment.NewLine, authKey, cliente, applicativo, exc), tipoLog.EXCEPTION);
+ }
+ return answ;
+ }
+
+ ///
+ /// Fornisce chiave MD5 x un cliente/applicativo/expiryDate
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string getAuthKey(string cliente, string applicativo, int licenze, DateTime expiryDate)
+ {
+ string answ = "";
+ // algoritmo MD5 formato cliente#applicativo#expDate, via SQLdiventa
+ // SELECT CONVERT(VARCHAR(32), HashBytes('MD5', 'ETS#GPW#2013/12/31'), 2)
+ string plainAuthKey = string.Format("{0}#{1}-{2}%{3}%", cliente, applicativo.PadLeft(20, '-'), expiryDate.ToString("yyyy/MM/dd"), licenze);
+ string passPhrase = string.Format("{0}|{1}", cliente.PadLeft(50, ':'), applicativo);
+ answ = SteamCrypto.EncryptString(plainAuthKey, passPhrase); // uso combinazione cliente+applicativo come passphrase!
+ return answ;
+ }
+
+ ///
+ /// Fornisce chiave MD5 x una chiave secondaria/di checksum data dai parametri in ingresso
+ /// MasterKey/string[] chiavi singole child/expiryDate
+ ///
+ /// Chiave master da cui si parte
+ /// Payload che contiene le chiavi SUB (child) riferite alla master in formato JSon (compresso/no indent)
+ ///
+ public static string getChecksumKey(string MasterKey, string Payload)
+ {
+ string answ = "";
+ answ = SteamCrypto.EncryptString(Payload, MasterKey);
+ return answ;
+ }
+
+ ///
+ /// numero di licenze attive per cliente/applicativo
+ ///
+ ///
+ ///
+ ///
+ public static int getLicenseNum(string cliente, string applicativo)
+ {
+ // !!!FARE!!! chiamata a webservice 1/mese
+ int answ = 1;
+ // molto hard-coded e discutibile... licenze "perenni"
+ switch (cliente)
+ {
+ default:
+ answ = 1;
+ break;
+ }
+
+ return answ;
+ }
+
+ #endregion Public Methods
+ }
+}
diff --git a/MP-LAND.sln b/MP-LAND.sln
index f4e0ede6..85cb3e47 100644
--- a/MP-LAND.sln
+++ b/MP-LAND.sln
@@ -1,12 +1,14 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.31229.75
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Land", "MP.Land\MP.Land.csproj", "{D949AB45-9B65-4594-A97E-182BC3831707}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.AppAuth", "MP.AppAuth\MP.AppAuth.csproj", "{E8B1E617-87BC-4638-A8B6-04EEBA3B8F47}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Egw.Core", "Egw.Core\Egw.Core.csproj", "{D3D348EF-1313-43DF-94FB-28CD38B68212}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
{E8B1E617-87BC-4638-A8B6-04EEBA3B8F47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8B1E617-87BC-4638-A8B6-04EEBA3B8F47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8B1E617-87BC-4638-A8B6-04EEBA3B8F47}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D3D348EF-1313-43DF-94FB-28CD38B68212}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D3D348EF-1313-43DF-94FB-28CD38B68212}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D3D348EF-1313-43DF-94FB-28CD38B68212}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D3D348EF-1313-43DF-94FB-28CD38B68212}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/MP.AppAuth/Controllers/MPController .cs b/MP.AppAuth/Controllers/MPController .cs
index 81c577ca..794b7d64 100644
--- a/MP.AppAuth/Controllers/MPController .cs
+++ b/MP.AppAuth/Controllers/MPController .cs
@@ -42,9 +42,9 @@ namespace MP.AppAuth.Controllers
/// Elenco Record x AnagKeyValue
///
///
- public List AnagKeyValuesGetAll()
+ public List AnagKeyValuesGetAll()
{
- List dbResult = new List();
+ List dbResult = new List();
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
{
dbResult = localDbCtx
diff --git a/MP.AppAuth/MP.AppAuth.csproj b/MP.AppAuth/MP.AppAuth.csproj
index 757a2c47..13d4315a 100644
--- a/MP.AppAuth/MP.AppAuth.csproj
+++ b/MP.AppAuth/MP.AppAuth.csproj
@@ -1,7 +1,7 @@
- net5.0
+ net6.0
@@ -23,4 +23,8 @@
+
+
+
+
diff --git a/MP.AppAuth/Models/AnagKeyValue.cs b/MP.AppAuth/Models/AnagKeyValueModel.cs
similarity index 93%
rename from MP.AppAuth/Models/AnagKeyValue.cs
rename to MP.AppAuth/Models/AnagKeyValueModel.cs
index d2be5358..6efcc279 100644
--- a/MP.AppAuth/Models/AnagKeyValue.cs
+++ b/MP.AppAuth/Models/AnagKeyValueModel.cs
@@ -11,7 +11,7 @@ namespace MP.AppAuth.Models
// This is here so CodeMaid doesn't reorganize this document
//
[Table("AnagKeyValue")]
- public partial class AnagKeyValue
+ public partial class AnagKeyValueModel
{
#region Public Properties
diff --git a/MP.AppAuth/MoonProContext.cs b/MP.AppAuth/MoonProContext.cs
index 7c4d02d8..09f1d31c 100644
--- a/MP.AppAuth/MoonProContext.cs
+++ b/MP.AppAuth/MoonProContext.cs
@@ -63,7 +63,7 @@ namespace MP.AppAuth
public virtual DbSet AnagraficaOperatoris { get; set; }
public virtual DbSet Configs { get; set; }
public virtual DbSet DatiMacchines { get; set; }
- public virtual DbSet DbSetAnagKeyValues { get; set; }
+ public virtual DbSet DbSetAnagKeyValues { get; set; }
public virtual DbSet FamigliaTipoIngressis { get; set; }
public virtual DbSet FamiglieMacchines { get; set; }
public virtual DbSet KeepAlives { get; set; }
@@ -151,7 +151,7 @@ namespace MP.AppAuth
entity.Property(e => e.Descrizione).HasMaxLength(500);
});
- modelBuilder.Entity(entity =>
+ modelBuilder.Entity(entity =>
{
entity.HasKey(e => e.NomeVar);
diff --git a/MP.Land/Components/HomeLink.razor b/MP.Land/Components/HomeLink.razor
index b1e34f83..272ed60c 100644
--- a/MP.Land/Components/HomeLink.razor
+++ b/MP.Land/Components/HomeLink.razor
@@ -3,8 +3,8 @@
@using Microsoft.Extensions.Configuration
@inject IConfiguration Configuration
-
@inject AppAuthService DataService
+@inject LicenseService LicServ