17.07.2015 Views

Download eBook (PDF) - Red Gate Software

Download eBook (PDF) - Red Gate Software

Download eBook (PDF) - Red Gate Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5 – Cell-Level EncryptionFor example, the WOLFBA user will have the decrypted version of the encrypteddata appearing in their results; while the KELLEYWB user will see the value"" in the sensitive column.Creating the Stored ProceduresRequirement 1 dictates that only members of the Sensitive_high databaserole can execute INSERT and UPDATE methods on a table that containscolumns with the sensitivity classification of "High". We have alreadyestablished that the Borrower_Identification table contains one ofthese columns.In addition, Requirement 2 dictates that all interaction with tables is to beperformed through views and stored procedures. Requirement 6 dictates that alldata modifications occur through stored procedures. In compliance with theserequirements we will create two stored procedures.The first stored procedure, named Update_Borrower_Identification,will perform the following:• Open the HighSymKey1 symmetric key with the MyHighCertcertificate through the OPEN SYMMETRIC KEY method.• Execute the UPDATE method while using the EncryptByKey methodto encrypt the value that is passed in the @Identification_Valueargument. This encryption includes the use of the @Borrower_IDargument as the authenticator.• Catch the occurrence of an error so that the stored procedure failsgracefully. This is accomplished by the use of the TRY…CATCHmethod.• Check the HighSymKey1 symmetric key to determine if it is openbefore attempting to close it through the sys.openkeys catalogview. If it is open, the key is closed using the CLOSE SYMMETRIC KEYmethod.Listing 5-16 shows the full code for the stored procedure.USE HomeLending;GOCREATE PROCEDURE dbo.Update_Borrower_Identification@Borrower_Identification_ID bigint,@Borrower_ID bigint,@Identification_Value varchar(250)AS122

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!