These utilities can load, encrypt, tune or debug code objects. This chapter will focus on the utilities that perform these functions, including wrap, dbms_profiler, dbms_debug, loadjava, dropjava and loadpsp.
The first of these utilities to be discussed will be the wrap utility that allows PL/SQL developers to encrypt their code.
Procedure/Function Description
WRAP Overloaded function that returns the wrapped PL/SQL source code when provided with the original source.
CREATE_WRAPPED Procedure that wraps the source code provided as input. It’s faster than using WRAP.
Create Country Table
SQL Code:
CREATE TABLE COUNTRIES
(
C_NAME VARCHAR2(15 BYTE)
);
Insert Data into Country Table
SQL Code:
REM INSERTING into COUNTRIES
Insert into COUNTRIES (C_NAME) values ('Poland');
Insert into COUNTRIES (C_NAME) values ('Germany');
Insert into COUNTRIES (C_NAME) values ('United States');
Insert into COUNTRIES (C_NAME) values ('Portugal');
Insert into COUNTRIES (C_NAME) values ('Czech Republic');
Insert into COUNTRIES (C_NAME) values ('China');
Insert into COUNTRIES (C_NAME) values ('Slovakia');
Insert into COUNTRIES (C_NAME) values ('Slovenia');
The DBMS_DDL package for Dynamic Wrapping
Use the overloaded WRAP function with EXECUTE IMMEDIATE to create the wrapped code, as the following example illustrates:
SQL Code:
DECLARE
v_Procedure VARCHAR2(32767);
BEGIN
v_Procedure := 'create or replace PROCEDURE p_CountryList '
|| 'AS '
|| 'cursor crCountryList is '
|| 'SELECT C_NAME FROM COUNTRIES; '
|| 'BEGIN '
|| ' for rc_countryList in crCountryList loop '
|| ' dbms_output.put_line(rc_countryList.C_NAME);'
|| ' end loop; '
|| ' End;';
EXECUTE IMMEDIATE DBMS_DDL.WRAP(v_Procedure);
END;
To see the wrapped procedure, select the text from the USER_SOURCE view.
SQL Code:
SELECT text
FROM user_source WHERE name = 'P_COUNTRYLIST';
Output:
TEXT
---------------------------------------------------------------------------
PROCEDURE p_CountryList wrapped
a000000
b2
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
7
c2 d2
OBXTyU790UHZX1Pz/x6SK6zaQdowg0zwLcsVfC+EOo7QS9JbZQ2c1RiJi1GYkXCXR+Hnl92a
6yUmVMJdr3L/xdu8xYazffm813KuNLzJ0jnlJ1HKbCYmfWw51ec5hoXDZ2KBtgvDWEsq4RNq
3cHIqVKojYPLLqq6zBQLjSwb9gkM4mO6aOBaz2jrVZ+/wI9dqhpqq1XumZC83+s=
Execute the wrapped procedure to verify all works as expected
Set Serveroutput on
execute p_CountryList;
This returns the following result
Poland
Germany
United States
Portugal
Czech Republic
China
Slovakia
Slovenia
CREATE_WRAPPED
DBMS_DDL.CREATE_WRAPPED works in a similar way. The use of EXECUTE IMMEDIATE is not required.
Use SYS.DBMS_DDL.CREATE_WRAPPED (v_procedure)
with replace of EXECUTE IMMEDIATE DBMS_DDL.WRAP(v_Procedure)
PL/SQL Wrap Utility for Encryption
The wrap utility (wrap.exe) provides a way for PL/SQL developers to protect their intellectual property by making their PL/SQL code unreadable.
Instead, the wrap utility takes a readable, ASCII text file as input and converts it to a file containing byte code. The result is that the DBA, developers or anyone with database access cannot view the source code in any readable format.
The command line options for wrap are:
wrap iname=[file] oname=[file]
· iname – The name of the unencrypted PL/SQL file to be used as input (your source file).
· oname – The name of the output file. This file will be encrypted.
For more information http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/c_wrap.htm
No comments:
Post a Comment