From 93f815ad73908f405ddb56f4b1e8d638568d0fba Mon Sep 17 00:00:00 2001 From: claudiamurialdo <33756655+claudiamurialdo@users.noreply.github.com> Date: Mon, 13 Jun 2022 16:39:52 -0300 Subject: [PATCH] Move functions to super class so they are visible from BC transactions. (#609) (cherry picked from commit 1d693360bd5ea60107ec163fb91b8e1ab913bda0) # Conflicts: # dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs # dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs --- .../GxClasses/Middleware/GXHttp.cs | 7 ++- .../GxClasses/Model/GXBaseObject.cs | 44 ++++++++++++++++++- .../dotnetframework/GxClasses/Model/gxproc.cs | 32 -------------- 3 files changed, 49 insertions(+), 34 deletions(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs b/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs index 09a05e426..e9cc5500b 100644 --- a/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs +++ b/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs @@ -1368,6 +1368,7 @@ protected virtual void ValidateSpaRequest() sendSpaHeaders(); } } +#if !NETCORE protected string GetEncryptedHash(string value, string key) { @@ -1405,7 +1406,11 @@ protected String Decrypt64(String value, String key) } return sRet; } - + protected string UriDecrypt64(string value, string key) + { + return Decrypt64(value, key, true); + } +#endif protected string DecryptAjaxCall(string encrypted) { this.validEncryptedParm = false; diff --git a/dotnet/src/dotnetframework/GxClasses/Model/GXBaseObject.cs b/dotnet/src/dotnetframework/GxClasses/Model/GXBaseObject.cs index a5e078762..f4a11e896 100644 --- a/dotnet/src/dotnetframework/GxClasses/Model/GXBaseObject.cs +++ b/dotnet/src/dotnetframework/GxClasses/Model/GXBaseObject.cs @@ -1,6 +1,9 @@ +using GeneXus.Diagnostics; +using GeneXus.Encryption; using GeneXus.Http; using GeneXus.Utils; using Jayrock.Json; +using log4net; #if NETCORE using Microsoft.AspNetCore.Http.Extensions; #endif @@ -12,6 +15,7 @@ namespace GeneXus.Application public class GXBaseObject { + static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXBaseObject)); private Dictionary callTargetsByObject = new Dictionary(); protected IGxContext _Context; public virtual IGxContext context @@ -102,7 +106,45 @@ public virtual string UrlEncode(string s) { return GXUtil.UrlEncode(s); } + protected string GetEncryptedHash(string value, string key) + { + return Encrypt64(GXUtil.GetHash(GeneXus.Web.Security.WebSecurityHelper.StripInvalidChars(value), Cryptography.Constants.SecurityHashAlgorithm), key); + } - } + protected string Encrypt64(string value, string key) + { + string sRet = string.Empty; + try + { + sRet = Crypto.Encrypt64(value, key); + } + catch (InvalidKeyException) + { + GXLogging.Error(log, "440 Invalid encryption key"); + } + return sRet; + } + protected string UriEncrypt64(string value, string key) + { + return Encrypt64(value, key); + } + protected string Decrypt64(string value, string key) + { + String sRet = string.Empty; + try + { + sRet = Crypto.Decrypt64(value, key); + } + catch (InvalidKeyException) + { + GXLogging.Error(log, "440 Invalid encryption key"); + } + return sRet; + } + protected string UriDecrypt64(string value, string key) + { + return Decrypt64(value, key); + } + } } diff --git a/dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs b/dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs index a5c8c9be3..550fd54ca 100644 --- a/dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs +++ b/dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs @@ -107,38 +107,6 @@ protected void exitApplication() protected virtual void printHeaders(){} protected virtual void printFooters(){} - protected string GetEncryptedHash(string value, string key) - { - return Encrypt64(GXUtil.GetHash(GeneXus.Web.Security.WebSecurityHelper.StripInvalidChars(value), Cryptography.Constants.SecurityHashAlgorithm), key); - } - - protected String Encrypt64(String value, String key) - { - String sRet = ""; - try - { - sRet = Crypto.Encrypt64(value, key); - } - catch (InvalidKeyException) - { - GXLogging.Error(log, "440 Invalid encryption key"); - } - return sRet; - } - - protected String Decrypt64(String value, String key) - { - String sRet = ""; - try - { - sRet = Crypto.Decrypt64(value, key); - } - catch (InvalidKeyException) - { - GXLogging.Error(log, "440 Invalid encryption key"); - } - return sRet; - } public msglist GX_msglist { get { return context.GX_msglist ; }