An example of protecting sensitive data is the database connection string. The organization has chosen to store SQL Server connection string in an encrypted format in a centrally-accessed database. When an ASP.NET application starts up, a procedure in the Global.asax file calls the database through an application service, and stores the encrypted connection strings (there may be more than one; e.g. synchronous and asynchronous strings) in an application object variable:
protected void Application_Start(object sender, EventArgs e)
{
//Get the Application ID from the web.config file
string appID = ConfigurationSettings.AppSettings["AppKey"];
//Convert the Application ID from string to integer, call the service,
//pass the Applicaiton ID parameter, assign the returning object
//to the data contract object instantiated above
appData = svc.GetAppDataByApplicationID(Convert.ToInt32(appID));
//Assign the contract data to the Application Object properties
appInfo.ApplicationID = appData.ApplicationID;
appInfo.EnvironmentID = appData.EnvironmentID;
appInfo.SyncConnectionString = appData.SyncConnectionString.Trim(); appInfo.AsyncConnectionString = appData.ASyncConnectionString.Trim();
//Store the Application Object in an application variable
Context.Application["AppInfo"] = appInfo;
//Get rid of the objects instantiated above in application end
}
When the application requires access to the database connection string, then a call is made through the domain BLL where the connection string is decrypted at the server with a 3DES method accessed in the base BLL.