-2

I need to make a materialized view, based on few of the tables in our database, but the catch is, few columns in the underlying tables are encrypted using Jasypt, and all the columns are required to be plain text in the materialized view.

Is there any implicit function in Oracle which can be used for Jasypt decryption or any suggestions around writing own function to achieve this ?

PS : Encryption used is decrypt-able.

Vivek Gupta
  • 2,534
  • 3
  • 15
  • 28

1 Answers1

1

You could create a java stored procedure in oracle. It's fairly easy - Create the source like so:

create or replace and compile java source named JasyptWrapper as
public class JasyptWrapper
{
  public static String decrypt(String str)
  {
         String decryptedStr = "";
         //code to decrypt
         return decryptedStr;
  }
}

Created the stored proc wrapper like so:

FUNCTION jasypt_decrypt(p_str VARCHAR2) RETURN VARCHAR2 AS
LANGUAGE JAVA NAME 'JasyptWrapper.decrypt(java.lang.String) return String';

You can then write java code to utilize jasypt to perform the decryption, but you'll have the ability to call it like any other PL/SQL procedure.

You'll have to load the jasypt libraries into the oracle database using loadjava. You'll likely need assistance from your DBA to perform some of these operations, and they'll also probably need to grant additional access using the dbms_java package.

Then use the function you created in the materialized view query to decrypt the values as it processes.

slambeth
  • 887
  • 5
  • 17