Example #1
0
        /// <summary>
        /// Gets an entity name representation suitable for logging.
        /// </summary>
        /// <param name="entityLogicalName">The entity logical name to be logged.</param>
        /// <returns>
        /// Returns the logical name unchanged if it matches the whitelist of known entities, otherwise returns a
        /// hashed representation.
        /// </returns>
        public static string GetEntityName(string entityLogicalName)
        {
            if (string.IsNullOrEmpty(entityLogicalName))
            {
                return(entityLogicalName);
            }

            return(PortalEntityAllowedList.Contains(entityLogicalName)
                                ? entityLogicalName
                                : Convert.ToBase64String(HashPii.ComputeHashPiiSha256(Encoding.UTF8.GetBytes(entityLogicalName))));
        }
Example #2
0
 /// <summary>
 /// Determines whether a given entity logical name is allowed to be logged un-hashed.
 /// </summary>
 /// <param name="entityLogicalName">The entity logical name to be logged.</param>
 /// <returns>
 /// True if the given entity logical name is not null or empty and can be logged, otherwise false.
 /// </returns>
 public static bool IsPortalEntityAllowed(string entityLogicalName)
 {
     return(!string.IsNullOrEmpty(entityLogicalName) && PortalEntityAllowedList.Contains(entityLogicalName));
 }