Using an encrypted connection string (Adapter)

Posts   
 
    
Posts: 3
Joined: 15-Feb-2006
# Posted on: 16-Feb-2006 23:35:17   

We are currently in the process of reegineering our system, and have made the decision to go with LLBLGen Pro.

One thing we do is store the connection string encrypted in our app/web/.config files. So I need to decrypt these before they can be used.

The code to do it is very simple (psuedocode)

string unecrypt = Security.Decrypt(connectionstring).

Where is the best place to place this? Change the template for DataAccessAdapter or is there a no-override code block I code use?

We are using the adapter pattern, build 1.0.2005.1, VS 2003 .Net 1.1

Thanks, Andrew

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 17-Feb-2006 00:59:29   

One of the constructors of the DataAccessAdapter is the connectionstring.

I use a helper function in the app that allows me centralize the DatabaseSpecific adapter type AND specify the connection string throughout the app.

Excuse the VB, but the idea is the same.


Public Class DataBase
    Public Shared Function GetAdapter() As SD.LLBLGen.Pro.ORMSupportClasses.IDataAccessAdapter
        Dim adapter As SD.LLBLGen.Pro.ORMSupportClasses.IDataAccessAdapter = _
                New DatabaseSpecific.DataAccessAdapter(Security.Decrypt(connectionstring))
        Return adapter
    End Function
''' other shared code here
End Class

Usage:


        Using adapter As IDataAccessAdapter = DataBase.GetAdapter()
                adapter.FetchEntityCollection(ecCustomer, Nothing)
        End Using

Posts: 3
Joined: 15-Feb-2006
# Posted on: 19-Feb-2006 20:20:29   

Thanks Jim, thats a good approach.