What Each Script Does
The Security HR demo use case runs the following set of PL/SQL scripts to set up components and run the demo:
-
hrdemo_setup.sql: sets up the demo components by:-
Creating a database user as the Real Application Security Administrator and then connecting as the Real Application Security Administrator to create the components.
-
Creating a database role,
DB_EMP. -
Creating an IT application user,
DAUSTIN. -
Creating an HR application user,
SMAVRIS. -
Creating application roles:
employee,it_engineer, andhr_representative, and then granting the database roleDB_EMPto each of these application roles. -
Granting application roles
employeeandit_engineerto application userDAUSTIN. -
Granting application roles
employeeandhr_representativeto application userSMAVRIS. -
Creating the
VIEW_SALARYprivilege and creating thehr_privilegessecurity class in which to scope the privilege. -
Creating three ACLs:
EMP_ACL,IT_ACL, andHR_ACL, in which:-
EMP_ACLgrants theemployeerole theSELECTdatabase privilege andVIEW_SALARYapplication privilege to view an employee’s own record, including theSALARYcolumn. -
IT_ACLgrants theit_engineerrole only theSELECTdatabase privilege to view the employee records in the IT department, but it does not grant theVIEW_SALARYprivilege that is required for access to theSALARYcolumn. -
HR_ACLgrants thehr_representativeroleSELECT,INSERT,UPDATE, andDELETEdatabase privileges to view and update all employee’s records, and granting theVIEW_SALARYapplication privilege to view theSALARYcolumn.
-
-
The HR demo secures the
HR.EMPLOYEEtable by creating and applying the data security policy,EMPLOYEES_DS, that has the following three realms and column constraint:-
An employee’s own record realm. The ACL,
EMP_ACLcontrols this realm, which grants application roleemployeeprivileges to access the realm, including theSALARYcolumn. -
All the records in the IT department realm. The ACL,
IT_ACLcontrols this realm, which grants application roleit_engineerprivileges to access the realm, but excluding theSALARYcolumn. -
All the employee records realm. The ACL,
HR_ACLcontrols this realm, which grants application rolehr_representativeprivileges to access the realm, including theSALARYcolumn. -
A column constraint that protects the
SALARYcolumn by requiring theVIEW_SALARYprivilege to view its sensitive data.
-
-
Validating all the objects that have been created to ensure that all configurations are correct.
-
Setting up the mid-tier related configuration by creating a
DISPATCHERuser, setting the password for this user, and granting the roles,XSCONNECTandxsdispatcherto thisDISPATCHERuser.
-
-
hrdemo.sql: runs the demo with direct logon, demonstrating:-
That the IT application user,
DAUSTIN, can view the records in the IT department, but can only view his own salary record, and cannot update his own record. -
That the HR application user,
SMAVRIS, can view all the records, including all salary rows in theSALARYcolumn, and can update any record.
-
-
hrdemo_session.sql: runs the demo creating and attaching to a Real Application Security session, demonstrating:-
Connecting as the Real Application Security Administrator and creating an application session for application user
SMAVRISand attaching to it. -
Displaying the current user as
SMAVRIS. -
Displaying the enabled database roles as
DB_EMPand application roles asemployee,hr_representative, andXSPUBLICfor the current userSMAVRIS. -
That
SMAVRISapplication user can view all records including all salary rows in theSALARYcolumn. -
Disabling the
hr_representativeand thus limiting application userSMAVRISto viewing only her own employee record. -
Enabling the
hr_representative, thus allowingSMAVRISapplication user to view all records, including all salary rows in theSALARYcolumn again. -
Detaching from the application session.
-
Destroying the application session.
-
-
hrdemo_clean.sql: performs a cleanup operation that removes: application roles, application users, ACLs, the data security policy, the database role, the Real Application Security administrative user, and the mid-tier dispatcher user. -
hrdemo.java: runs the HR Demo using the Java interface.
“Setting Up the Security HR Demo Components” describes in more detail how each of the Real Application Security components is created along with performing some other important tasks.