Friday, 21 March 2014

using ODI DecryptingPassword Protected Documents

How to do it...

  1. Open a command line console and go to the c:\temp directory. Add a text file of your choice in this directory. Here we are using a file called test.txt
  2. Run the following from the command line:
    c:\temp> aescrypt -e -p oracledi test.txt
    This will generate an encrypted file named test.txt.aes that is protected with the password oracledi. If you try to edit the content of this new file, you will see that it has indeed been encrypted:
           
Rename the original test.txt file to test.txt.ori. We will now use ODI to decrypt the file and restore the original content.
3. In ODI Topology, create a new Data Server in the File technology called AESCRYPT. We will use this data server as a placeholder for the password that we need for this operation. We can also use this to locate the file that we will work on. You can leave the User name empty (we do not need it here), but do set the Password value to oracledi.
getInfo("SRC_PASS")@> <%=odiRef.getInfo("SRC_SCHEMA")%>\foo.txt.
aes
Save the procedure and run it.


In the JDBC tab, select the ODI File JDBC Driver and use the default JDBC URL:
jdbc:snps:dbfile.
4. Create a physical schema under that server. Set both the Schema name and Work Schema name toc:\temp.
Create a logical schema to point to this physical schema for the default context:
FILE_AESCRYPT
5. Switch to the Designer operator, and in the project of your choice, create a procedure calledCh11_Password_Decrypt_File.
Add a new step to this procedure, and call this Decrypt.
In the Command on Target tab, set the Technology to OS Command (leave all other fields to their default values) and type the following command (this is all one line of code, so please ignore the carriage returns that are only due to formatting):
<%=odiRef.getInfo("SRC_SCHEMA")%>\aescrypt -d -p <@=odiRef.getInfo("SRC_PASS")@> <%=odiRef.getInfo("SRC_SCHEMA")%>\test.txt.aes
The technology OS Command (Operating System) can be used execute any type of command at the OS level. One note of caution though: if the script or program that you execute returns anything else than 0, ODI will consider that the program failed. Typically there are two techniques that can be combined to solve this problem:
Redirect any output or errors to other files. For instance, dir 1>dir.out 2>dir.err, where 1 represents the standard output and 2 represents the errors output.
Use Jython code to execute the code and retrieve the return code in a variable. Then evaluate this variable to see whether the returned value indicates an error or is simply informational.
In the Command on Source tab, set the Technology to File, set the logical Schema name toFILE_AESCRYPT, and leave all other fields to their default values. There will be no code on the source side.
6. Save the procedure and execute it.
7. Now, if you go to the Operator window to look into the details of the code that was generated, you can see that the password is not revealed in the operator logs. We are looking in the following screenshot at the code generated for the task:
Now back to the console, You can see the original Document

0 comments:

Post a Comment