multiple cases and changes (whups forgot to commit)
cases 3664, 3663, 3520 (redux)
This commit is contained in:
@@ -64,4 +64,4 @@ using System.Security.Permissions;
|
||||
// Configure log4net using the .config file
|
||||
//[assembly: log4net.Config.XmlConfigurator(ConfigFile="Log4Net.config",Watch=true)]
|
||||
//[assembly: log4net.Config.XmlConfigurator( ConfigFile="Log4Net.config",Watch=true )]
|
||||
[assembly: AssemblyFileVersionAttribute("7.5.8.0")]
|
||||
[assembly: AssemblyFileVersionAttribute("7.5.9.0")]
|
||||
|
||||
@@ -158,8 +158,8 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Newtonsoft.Json.5.0.4\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\3rdprtylibs\json.net.40\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System">
|
||||
<Name>System</Name>
|
||||
@@ -293,11 +293,15 @@
|
||||
<Compile Include="GZTW.AyaNova.BLL\FollowUpListForUser.cs" />
|
||||
<Compile Include="GZTW.AyaNova.BLL\HeadOfficeExistanceChecker.cs" />
|
||||
<Compile Include="GZTW.AyaNova.BLL\HeadOfficeUnitPickList.cs" />
|
||||
<Compile Include="GZTW.AyaNova.BLL\IntegrationLogList.cs" />
|
||||
<Compile Include="GZTW.AyaNova.BLL\IntegrationSimple.cs" />
|
||||
<Compile Include="GZTW.AyaNova.BLL\MemoList.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GZTW.AyaNova.BLL\MemoListRi.cs" />
|
||||
<Compile Include="GZTW.AyaNova.BLL\NotifyDeliveryLogList.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GZTW.AyaNova.BLL\OSVersionInfo.cs" />
|
||||
<Compile Include="GZTW.AyaNova.BLL\PartInventoryAdjustmentListDetailed.cs" />
|
||||
<Compile Include="GZTW.AyaNova.BLL\GuidFetcher.cs" />
|
||||
@@ -508,9 +512,6 @@
|
||||
<Compile Include="GZTW.AyaNova.BLL\NotifyDeliveryLog.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GZTW.AyaNova.BLL\NotifyDeliveryLogList.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GZTW.AyaNova.BLL\NotifyDeliveryMessageFormats.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace GZTW.AyaNova.BLL
|
||||
//Case 508
|
||||
private string _DigestValue;
|
||||
|
||||
// private string _status;
|
||||
private string _LicenseValidationStatus;
|
||||
private DateTime _Generated;
|
||||
private DateTime _InstallableUntil;
|
||||
private bool _Installable;
|
||||
@@ -337,7 +337,7 @@ namespace GZTW.AyaNova.BLL
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return _status;
|
||||
// return _LicenseValidationStatus;
|
||||
// }
|
||||
|
||||
//}
|
||||
@@ -691,44 +691,56 @@ namespace GZTW.AyaNova.BLL
|
||||
/// <param name="Criteria"></param>
|
||||
protected override void DataPortal_Fetch(object Criteria)
|
||||
{
|
||||
this._LicenseValidationStatus = "";
|
||||
//Fetching license key
|
||||
//sets all settings to safe mode before fetch and validate
|
||||
InValidate();
|
||||
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 2";
|
||||
|
||||
|
||||
Criteria crit = (Criteria)Criteria;
|
||||
#if(FIPS_MODE)
|
||||
//case 3378
|
||||
bool bMustUpdate = false;//if it has to decrypt the key and ex data then it should save it back immediately here
|
||||
#endif
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 3";
|
||||
using (SafeDataReader dataReader = DBUtil.GetReaderFromSQLString("SELECT * FROM aGlobalEx"))
|
||||
{
|
||||
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 4";
|
||||
if (dataReader.Read())
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 5";
|
||||
try
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 6";
|
||||
//schema version
|
||||
mDBSchema = dataReader.GetInt32("aDBSchema");
|
||||
|
||||
//Global data
|
||||
int nTempsize = dataReader.GetInt32("aGlobalDataSize");
|
||||
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 7";
|
||||
if (nTempsize > 0)
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 8";
|
||||
byte[] temp = new Byte[nTempsize];
|
||||
|
||||
dataReader.GetBytes("aGlobalData", 0, temp, 0, nTempsize);
|
||||
|
||||
#if(FIPS_MODE)
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 9";
|
||||
//case 3378
|
||||
string sKey = new UTF8Encoding().GetString(temp);
|
||||
if (sKey.Contains("LicenseKey"))
|
||||
{ //already stored decrypted
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 9-PathA";
|
||||
_FIPS_READY = true;//flag for the globalEx block below which is not as easily identifiable as decrypted
|
||||
mbGlobalData = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 9-PathB";
|
||||
//trigger a save after all is decrypted
|
||||
bMustUpdate = true;
|
||||
/*shaM.ComputeHash(enc.GetBytes("Who is John Galt?"))*/
|
||||
@@ -742,7 +754,7 @@ namespace GZTW.AyaNova.BLL
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 9-PathC";
|
||||
/*shaM.ComputeHash(enc.GetBytes("Who is John Galt?"))*/
|
||||
byte[] bkey = new byte[32] { 0xAE, 0x6E, 0x53, 0x24, 0xC6, 0x53, 0x1D, 0x88, 0x90, 0x12, 0x80, 0xCC, 0x19, 0x88, 0x71, 0x38, 0xA3, 0xBF, 0x63, 0x64, 0xCB, 0x0C, 0xED, 0x50, 0x47, 0xCA, 0x96, 0x8C, 0x27, 0xCD, 0xD2, 0x64 };
|
||||
/*shaM.ComputeHash(enc.GetBytes("License IV"))*/
|
||||
@@ -756,7 +768,7 @@ namespace GZTW.AyaNova.BLL
|
||||
else
|
||||
throw new InvalidOperationException();
|
||||
|
||||
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 10";
|
||||
|
||||
//Global data EX
|
||||
nTempsize = dataReader.GetInt32("aGlobalDataExSize");
|
||||
@@ -764,16 +776,18 @@ namespace GZTW.AyaNova.BLL
|
||||
if (nTempsize > 0)
|
||||
{
|
||||
|
||||
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 11";
|
||||
//Get the data...
|
||||
byte[] temp = new Byte[nTempsize];
|
||||
dataReader.GetBytes("aGlobalDataEx", 0, temp, 0, nTempsize);
|
||||
|
||||
|
||||
//Into a memory stream...
|
||||
MemoryStream mstream = null;
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 12";
|
||||
#if(FIPS_MODE)
|
||||
if (!_FIPS_READY)
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 12-A";
|
||||
//Decrypt the data...
|
||||
UTF8Encoding enc = new UTF8Encoding();
|
||||
//SHA256 shaM = new SHA256Managed();
|
||||
@@ -787,11 +801,13 @@ namespace GZTW.AyaNova.BLL
|
||||
}
|
||||
else
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 12-B";
|
||||
//already fips ready (decrypted in db) so just process it
|
||||
mstream = new MemoryStream(temp);
|
||||
}
|
||||
|
||||
#else
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 12-C";
|
||||
//Decrypt the data...
|
||||
UTF8Encoding enc = new UTF8Encoding();
|
||||
//SHA256 shaM = new SHA256Managed();
|
||||
@@ -801,18 +817,20 @@ namespace GZTW.AyaNova.BLL
|
||||
byte[] biv = new byte[32] { 0x9F, 0xDF, 0x65, 0x02, 0xA8, 0x48, 0x79, 0x2D, 0xC2, 0xD9, 0xCB, 0xCB, 0x9F, 0x0C, 0x8B, 0x55, 0x3F, 0x2E, 0x92, 0x3C, 0x48, 0xAD, 0xDC, 0xF4, 0x53, 0x03, 0x82, 0x29, 0x80, 0x28, 0x45, 0x1D };
|
||||
|
||||
CipherWrapper c = new CipherWrapper(bkey);
|
||||
mstream = new MemoryStream(c.DecryptMessage(temp, biv));
|
||||
mstream = new MemoryStream(c.DecryptMessage(temp, biv));
|
||||
#endif
|
||||
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 13";
|
||||
//De-serialize it into the AGlobalExData object...
|
||||
BinaryFormatter bformatter = new BinaryFormatter();
|
||||
bformatter.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
|
||||
try
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 13-A";
|
||||
_AGlobalExData = (AGlobalExData)bformatter.Deserialize(mstream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 13-B";
|
||||
_AGlobalExData = new AGlobalExData();
|
||||
_AGlobalExData.EvalExpire = System.DateTime.Now;
|
||||
_AGlobalExData.EvalAdvanceReference = System.DateTime.Now;
|
||||
@@ -822,9 +840,13 @@ namespace GZTW.AyaNova.BLL
|
||||
else
|
||||
throw new InvalidOperationException();
|
||||
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 14";
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{//this will be caught if the fields requested above don't exist
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 15";
|
||||
//this will be caught if the fields requested above don't exist
|
||||
//or there is *any* problem dealing with them
|
||||
//which generally will be that the database is a pre-release one they
|
||||
//are trying to use or they have screwed with the data somehow
|
||||
@@ -832,21 +854,22 @@ namespace GZTW.AyaNova.BLL
|
||||
//string s=ex.Message;
|
||||
|
||||
#else
|
||||
throw new System.ApplicationException(
|
||||
"\r\n************************************************\r\n" +
|
||||
"Database is missing startup information.\r\n " +
|
||||
"It is either damaged, tamped with or not a valid AyaNova database.\r\n" +
|
||||
"(Note that a pre-release database can not be used with AyaNova)\r\n" +
|
||||
"\r\n************************************************\r\n" ,ex
|
||||
);
|
||||
throw new System.ApplicationException(
|
||||
"\r\n************************************************\r\n" +
|
||||
"Database is missing startup information.\r\n " +
|
||||
"It is either damaged, tamped with or not a valid AyaNova database.\r\n" +
|
||||
"(Note that a pre-release database can not be used with AyaNova)\r\n" +
|
||||
"\r\n************************************************\r\n", ex
|
||||
);
|
||||
#endif
|
||||
}
|
||||
finally
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 16";
|
||||
dataReader.Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -856,29 +879,53 @@ namespace GZTW.AyaNova.BLL
|
||||
|
||||
try
|
||||
{
|
||||
Validate(false);
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 17";//this is the last logged line before 18 and then finally 18a
|
||||
Validate(false);//this must be throwing an exception
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 17-A";//this doesn't log
|
||||
if (_Valid == false)
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 17-B";
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch(Exception ex)
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 18";
|
||||
_Valid = false;
|
||||
#if(FIPS_MODE)
|
||||
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 18-A";
|
||||
|
||||
_LicenseValidationStatus += "\r\nValidate Exception:\r\n" + ex.Message;
|
||||
_LicenseValidationStatus += "\r\nValidate Exception stack:\r\n" + ex.StackTrace;
|
||||
|
||||
throw new InvalidOperationException(
|
||||
"**** A VALID AYANOVA LICENSE WAS NOT FOUND ***\r\n\r\n " +
|
||||
"Diagnostic info:\r\n\r\n"+_LicenseValidationStatus);
|
||||
|
||||
#else
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 18-B";
|
||||
//_LicenseValidationStatus
|
||||
throw new InvalidOperationException(
|
||||
"**** A VALID AYANOVA LICENSE WAS NOT FOUND ***\r\n\r\n " +
|
||||
"The license key has been tampered with or damaged.\r\n\r\n" +
|
||||
"** License violations are logged for the protection of the licensee and licensor **\r\n\r\n" +
|
||||
"Restore the database from a backup or contact AyaNova technical\r\n" +
|
||||
"support for assistance.");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if(FIPS_MODE)
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 19";
|
||||
//case 3378
|
||||
if (bMustUpdate)
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 20";
|
||||
DataPortal_Update();
|
||||
}
|
||||
#endif
|
||||
//_LicenseValidationStatus += "\r\nDataPortal_Fetch: 21-FIN";
|
||||
}
|
||||
|
||||
|
||||
@@ -908,7 +955,7 @@ namespace GZTW.AyaNova.BLL
|
||||
//contains a signature that disallows editing, this is just
|
||||
//to prevent casual users from bothering to try messing with it in the first place
|
||||
//by seeing it when opening the db in a db admin tool
|
||||
|
||||
|
||||
/*shaM.ComputeHash(enc.GetBytes("Who is John Galt?"))*/
|
||||
byte[] bkey = new byte[32] { 0xAE, 0x6E, 0x53, 0x24, 0xC6, 0x53, 0x1D, 0x88, 0x90, 0x12, 0x80, 0xCC, 0x19, 0x88, 0x71, 0x38, 0xA3, 0xBF, 0x63, 0x64, 0xCB, 0x0C, 0xED, 0x50, 0x47, 0xCA, 0x96, 0x8C, 0x27, 0xCD, 0xD2, 0x64 };
|
||||
/*shaM.ComputeHash(enc.GetBytes("License IV"))*/
|
||||
@@ -1033,7 +1080,7 @@ namespace GZTW.AyaNova.BLL
|
||||
|
||||
this._ScheduleableUsers = 0;
|
||||
this._SchemaVersion = 0;
|
||||
//this._status = "";
|
||||
|
||||
this._Expires = System.DateTime.Now;
|
||||
|
||||
//case 999
|
||||
@@ -1057,14 +1104,14 @@ namespace GZTW.AyaNova.BLL
|
||||
private void Validate(bool CheckInstallableUntilDate)
|
||||
{
|
||||
|
||||
|
||||
//_LicenseValidationStatus += "\r\nValidate: 1";
|
||||
|
||||
InValidate();
|
||||
UTF8Encoding utf8 = new UTF8Encoding();
|
||||
|
||||
string Key = utf8.GetString(mbGlobalData);
|
||||
|
||||
|
||||
// throw new System.NotSupportedException("TEST");
|
||||
|
||||
//case 1172
|
||||
string sKeyType = "AyaNovaLiteLicenseKey";
|
||||
@@ -1079,14 +1126,16 @@ namespace GZTW.AyaNova.BLL
|
||||
bool containsXML = Key.Contains("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?>");
|
||||
bool containsJSON = Key.Contains("[KEY");
|
||||
|
||||
//_LicenseValidationStatus += "\r\nValidate: 2";
|
||||
|
||||
if (!containsXML && !containsJSON)
|
||||
{
|
||||
_Valid = false;
|
||||
//_status = "Error: could not find license key in text provided";
|
||||
_LicenseValidationStatus = "Error: could not find license key in text provided";
|
||||
return;
|
||||
}
|
||||
|
||||
//_LicenseValidationStatus += "\r\nValidate: 3";
|
||||
|
||||
if (containsXML)
|
||||
{
|
||||
@@ -1155,7 +1204,7 @@ namespace GZTW.AyaNova.BLL
|
||||
{
|
||||
_Valid = false;
|
||||
//log.Error("Internal error # 1002");
|
||||
//_status="Error: exception in LoadXml:\r\n." + ex.Message + "\r\n" + ex.InnerException;
|
||||
//_LicenseValidationStatus="Error: exception in LoadXml:\r\n." + ex.Message + "\r\n" + ex.InnerException;
|
||||
return;
|
||||
|
||||
}
|
||||
@@ -1174,7 +1223,7 @@ namespace GZTW.AyaNova.BLL
|
||||
{
|
||||
_Valid = false;
|
||||
//log.Error("Internal error # 1003");
|
||||
//_status="Error: no signature found." + ex.Message + "\r\n" + ex.InnerException;
|
||||
//_LicenseValidationStatus="Error: no signature found." + ex.Message + "\r\n" + ex.InnerException;
|
||||
return;
|
||||
|
||||
|
||||
@@ -1185,7 +1234,7 @@ namespace GZTW.AyaNova.BLL
|
||||
{
|
||||
_Valid = false;
|
||||
//log.Error("Internal error # 1004");
|
||||
//_status="Error: Signature not valid, key has been tampered with.";
|
||||
//_LicenseValidationStatus="Error: Signature not valid, key has been tampered with.";
|
||||
return;
|
||||
|
||||
}
|
||||
@@ -1227,7 +1276,7 @@ namespace GZTW.AyaNova.BLL
|
||||
_Installable = false;
|
||||
_Valid = false;
|
||||
//log.Error("Internal error # 1005");
|
||||
//_status="Error: Installation key has expired.";
|
||||
//_LicenseValidationStatus="Error: Installation key has expired.";
|
||||
//return;
|
||||
|
||||
}
|
||||
@@ -1319,7 +1368,7 @@ namespace GZTW.AyaNova.BLL
|
||||
{
|
||||
_Valid = false;
|
||||
//log.Error("Internal error # 1006");
|
||||
//_status="Error: Signature not valid - exception Processing fields:\r\n." + ex.Message + "\r\n" + ex.InnerException;
|
||||
//_LicenseValidationStatus="Error: Signature not valid - exception Processing fields:\r\n." + ex.Message + "\r\n" + ex.InnerException;
|
||||
return;
|
||||
|
||||
}
|
||||
@@ -1327,6 +1376,7 @@ namespace GZTW.AyaNova.BLL
|
||||
}
|
||||
else
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nValidate: 4";
|
||||
#region PARSE JSON KEY
|
||||
string licenseFileData = Key;
|
||||
//extract between [KEY and KEY]
|
||||
@@ -1336,10 +1386,11 @@ namespace GZTW.AyaNova.BLL
|
||||
!licenseFileData.Contains("SIGNATURE]"))
|
||||
{
|
||||
_Valid = false;
|
||||
//throw new System.FormatException("KEY IS NOT VALID! Missing one or more required delimiters");
|
||||
//_LicenseValidationStatus = "KEY IS NOT VALID! Missing one or more required delimiters";
|
||||
return;
|
||||
}
|
||||
|
||||
//_LicenseValidationStatus += "\r\nValidate: 5";
|
||||
|
||||
string keyNoWS = System.Text.RegularExpressions.Regex.Replace(AyaBizUtils.ExtractString(licenseFileData, "[KEY", "KEY]").Trim(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1");
|
||||
string keySig = AyaBizUtils.ExtractString(licenseFileData, "[SIGNATURE", "SIGNATURE]").Trim();
|
||||
@@ -1368,12 +1419,12 @@ EQIDAQAB
|
||||
if (!signer.VerifySignature(expectedSig))
|
||||
{
|
||||
_Valid = false;
|
||||
//_status = "Error: Signature not valid, key has been tampered with.";
|
||||
_LicenseValidationStatus = "Error: Signature not valid, key has been tampered with.";
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion check signature
|
||||
|
||||
//_LicenseValidationStatus += "\r\nValidate: 6";
|
||||
//valid key (has valid signature)
|
||||
_Valid = true;
|
||||
try
|
||||
@@ -1482,14 +1533,17 @@ EQIDAQAB
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//_LicenseValidationStatus += "\r\nValidate: 7";
|
||||
#endregion get values
|
||||
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
//_LicenseValidationStatus += "\r\nValidate: 8";
|
||||
_Valid = false;
|
||||
// _status = "Error: Signature not valid - exception processing fields:\r\n." + ex.Message + "\r\n" + ex.InnerException;
|
||||
//_LicenseValidationStatus += "Error: Signature not valid - exception processing fields:\r\n." + ex.Message;
|
||||
if (ex.InnerException != null)
|
||||
//_LicenseValidationStatus += "\r\n" + ex.InnerException.Message;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user