This discussion is archived
3 Replies Latest reply: Jan 2, 2013 7:50 AM by User286067 RSS

Object Encryption

KeenOnOracle Explorer
Currently Being Moderated
Hi Friends.

Is it possible to encrypt all the DB Objects of a specific user without having to use wrap.exe proc by proc?
We got thousands of objects and this would take a lot of time....

We do want to encrypt the source-code at all of a determined user.

Tks!!!
  • 1. Re: Object Encryption
    Marcus Rangel Journeyer
    Currently Being Moderated
    You can use "dbms_ddl.create_wrapped", but you'll have to get the source code from dba_source.
  • 2. Re: Object Encryption
    Marcus Rangel Journeyer
    Currently Being Moderated
    Here is a procedure I used for that a few years ago:
    /***************************************************************************/
    /* WrapItNow: wraps pl/sql code on-the-fly                                 */
    /***************************************************************************/
    /**/
    /* 17/06/2006 - MRangel */
    /**/
    create or replace procedure SYS.WrapItNow (pOwner IN varchar2, pName IN varchar2) is
      --
      cursor cObject is
      select distinct owner, object_name name, object_type type
      from   dba_objects
      where  status      =     'VALID'                  and
             owner       like   pOwner                  and
             object_name like   nvl(pName,object_name)  and
             object_type in   ('FUNCTION','PROCEDURE','PACKAGE','PACKAGE BODY')
      order  by owner, object_name;
      --
      cursor cSource (cpOwner varchar2, cpName varchar2, cpType varchar2) is
      select owner, name, type, line, text
      from   dba_source
      where  owner = cpOwner and
             name  = cpName  and
             type  = cpType
      order  by owner, name, type, line;
      --
      vInputCode   dbms_sql.varchar2a;
      vLastLine    number;
      vText        varchar2(4000);
      vGoAhead     boolean;
      --
    begin
      --
      for rObject in cObject loop
          --
          for rSource in cSource (rObject.owner, rObject.name, rObject.type) loop
              --
              vGoAhead := TRUE;
              --
              if rSource.line = 1 then
                 --
                 -- Is it already wrapped ?
                 --
                 if instr(upper(rSource.text),'WRAPPED') <> 0 then
                    --
                    vGoAhead := FALSE;
                    exit;
                    --
                 end if;
                 --
                 -- Changes the first line for object creation
                 --
                 vText := upper('create or replace ' || rSource.text);
                 vText := replace(vText, rObject.name, rObject.owner || '.' || rObject.name);
                 --
              else
                 --
                 vText := rSource.text;
                 --
              end if;
              --
              vInputCode(rSource.line) := vText;
              -- dbms_output.put_line(vInputCode(rSource.line));
              --
              vLastLine := rSource.line;
              --
          end loop;
          --
          -- Wraps the object
          --
          if vGoAhead then
             --
             dbms_output.put_line(rObject.type || ' ' || rObject.name || ' is being wrapped...');
             --
             begin
               dbms_ddl.create_wrapped (vInputCode,1,vLastLine);
             exception
               when OTHERS then
                 dbms_output.put_line(rObject.type || ' ' || rObject.name || ' could not be wrapped.');
             end;
             --
          else
             --
             dbms_output.put_line(rObject.type || ' ' || rObject.name || ' was already wrapped.');
             --
          end if;
          --
      end loop;
      --
    end;
    /
  • 3. Re: Object Encryption
    User286067 Journeyer
    Currently Being Moderated
    just ensure that you keep a copy of unwrapped code somewhere safe since wrap.exe (or procedure interface) is one way road, there is no unwrap.

    Raj

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points