using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ServerConfig; using Microsoft.Data.SqlClient; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace GB5Shared.Connection { public interface IApplicationConnection { //Task GetSchedulerTemplateConnection(LoginDTO login); Task DBConnectionStringCached(LoginDTO LoginDTO); Task DBConnectionStringCached(string ConnectionName); // The tenant's own MSERVERCONFIG.DATABASETYPE — a given connection can be a completely // different RDBMS (and a completely different physical server) from the GB5 system's own // default. Callers that pick SqlConnection vs NpgsqlConnection must use THIS, not a // single global config value, or they build the wrong provider for that tenant. Task DatabaseTypeCached(LoginDTO LoginDTO); Task DatabaseTypeCached(string ConnectionName); // The tenant's MSERVERCONFIG.AUTHMODE/KEYCLOAKHOST/KEYCLOAKREALM/KEYCLOAKADMINVAULTPATH — // resolved the same cached, per-ConnectionName way as DatabaseTypeCached above. Returns // AuthMode=0 (Native) when no row resolves, so a caller never has to special-case "tenant // not found" as anything other than "this tenant doesn't use Keycloak." Task AuthConfigCached(LoginDTO LoginDTO); Task AuthConfigCached(string ConnectionName); // Reverse lookup — given a Keycloak realm name (from a validated token's issuer), find // which tenant it belongs to. Only matches AuthMode=Keycloak rows. Null if no tenant has // this realm configured (e.g. the realm belongs to a different, unrelated Keycloak client). Task DatabaseConnectionObjectByKeycloakRealmCached(string realm); Task DatabaseConnectionObject(string ConnectionName); Task Gb5SystemConnectionString(); Task DBConnectionStringCachedConnectionName(string ConnectionName); string Decrypt(string encryptedText, string key); string Encrypt(string plaintext, string key = "GB5"); string DecryptPasswordHash(string CipherString, bool UseHashing); string RandomGenerateAlphaNumeric(int Size); } }