12 Real Application Security HRデモ
12.1 セキュリティHRデモの概要
この人事管理(HR)デモは、基本的なReal Application Security (RAS)機能の使用方法を示します。このチュートリアルは、エンドツーエンドのユースケース・シナリオです。PL/SQLスクリプト、Javaプログラム・ソース・ファイルおよびログ・ファイルはReal Application Security HRデモ・ファイルを参照してください。
HRデモは、次の3つのレルムを持つデータ・セキュリティ・ポリシーを適用することでHR.EMPLOYEE
表を保護します。
-
従業員の固有のレコード・レルム。ACL
EMP_ACL
はこのレルムを制御し、SALARY
列を含むレルムにアクセスするためのemployee
権限をアプリケーション・ロールに付与します。 -
IT部門レルム内のすべてのレコード。ACL
IT_ACL
はこのレルムを制御し、SALARY
列を除くレルムにアクセスするためのit_engineer
権限をアプリケーション・ロールに付与します。 -
すべての従業員レコード・レルム。ACL HR_ACLは、このレルムを制御し、
SALARY
列を含むレルムにアクセスするためのhr_representative
権限をアプリケーション・ロールに付与します。
HRデモは、ポリシーの効果を示すために2人のアプリケーション・ユーザーを定義します。
-
IT部門のアプリケーション・ユーザーである
DAUSTIN
。彼はアプリケーション・ロールemployee
およびit_engineer
を持っています。そのため、前述のレルム#1およびレルム#2にアクセスできます。つまり、IT部門の従業員レコードを表示できますが、自分の給与レコードを除いてSALARY
列は表示できません。 -
HR部門のアプリケーション・ユーザーである
SMAVRIS
。彼女はアプリケーション・ロールemployee
およびhr_representative
を持っています。そのため、前述のレルム#1およびレルム#3にアクセスできます。つまり、すべての従業員レコードを表示および更新できます。
HRデモ・スクリプトは次のことを示します。
-
Real Application Securityオブジェクト(アプリケーション・ユーザー、アプリケーション・ロール、ACL、セキュリティ・クラスおよびデータ・セキュリティ・ポリシー)の作成方法。
-
データ・セキュリティ・ポリシーを使用して表の行(レルム制約を使用)および列(列制約を使用)を保護する方法。
-
アプリケーション・ユーザーとしてデータベースに直接ログオンする方法(パスワードが必要)、およびReal Application Securityセッションを作成、連結、連結解除および破棄する方法。
-
Real Application Securityセッションでアプリケーション・ロールを有効および無効にする方法。
12.2 各スクリプトで実行される処理
セキュリティHRデモのユースケースは、次の一連のPL/SQLスクリプトを実行して、コンポーネントを設定し、デモを実行します。
-
hrdemo_setup.sql
: 次の処理を行うことでデモのコンポーネントを設定します。-
Real Application Security管理者としてデータベース・ユーザーを作成し、Real Application Security管理者として接続してコンポーネントを作成します。
-
データベース・ロール
DB_EMP
を作成します。 -
ITアプリケーション・ユーザー
DAUSTIN
を作成します。 -
HRアプリケーション・ユーザー
SMAVRIS
を作成します。 -
アプリケーション・ロール
employee
、it_engineer
およびhr_representative
を作成し、これらの各アプリケーション・ロールにデータベース・ロールDB_EMP
を付与します。 -
アプリケーション・ロール
employee
およびit_engineer
をアプリケーション・ユーザーDAUSTIN
に付与します。 -
アプリケーション・ロール
employee
およびhr_representative
をアプリケーション・ユーザーSMAVRIS
に付与します。 -
VIEW_SALARY
権限を作成し、権限の有効範囲を設定するhr_privileges
セキュリティ・クラスを作成します。 -
EMP_ACL
、IT_ACL
およびHR_ACL
の3つのACLを作成します。-
EMP_ACL
は、SALARY
列を含む従業員自身のレコードを表示するためのSELECT
データベース権限とVIEW_SALARY
アプリケーション権限をemployee
ロールに付与します。 -
IT_ACL
は、it_engineer
ロールにIT部門内の従業員レコードを表示するためのSELECT
データベース権限のみ付与し、SALARY
列へのアクセスに必要なVIEW_SALARY
権限は付与しません。 -
HR_ACL
は、hr_representative
ロールに対して、すべての従業員のレコードの表示と更新を行うためのSELECT
、INSERT
、UPDATE
、DELETE
データベース権限と、SALARY
列を表示するためのVIEW_SALARY
アプリケーション権限を付与します。
-
-
HRデモは、次の3つのレルムと列制約を持つデータ・セキュリティ・ポリシー
EMPLOYEES_DS
を作成および適用することで、HR.EMPLOYEE
表を保護します。-
従業員の固有のレコード・レルム。ACL
EMP_ACL
はこのレルムを制御し、SALARY
列を含むレルムにアクセスするためのemployee
権限をアプリケーション・ロールに付与します。 -
IT部門レルム内のすべてのレコード。ACL
IT_ACL
はこのレルムを制御し、SALARY
列を除くレルムにアクセスするためのit_engineer
権限をアプリケーション・ロールに付与します。 -
すべての従業員レコード・レルム。ACL
HR_ACL
は、このレルムを制御し、SALARY
列を含むレルムにアクセスするためのhr_representative
権限をアプリケーション・ロールに付与します。 -
機密データの表示に
VIEW_SALARY
権限を要求することでSALARY
列を保護する列制約。
-
-
作成されたすべてのオブジェクトを検証して、すべての構成が正しいことを確認します。
-
DISPATCHER
ユーザーを作成し、このユーザーのパスワードを設定し、ロールXSCONNECT
およびxsdispatcher
をこのDISPATCHER
ユーザーに付与することで、中間層関連の構成を設定します。
-
-
hrdemo.sql
: 直接ログオンでデモを実行し、次のことを示します。-
ITアプリケーション・ユーザー
DAUSTIN
は、IT部門のレコードを表示できますが、自分の給与レコードのみ表示でき、自分のレコードの更新はできません。 -
HRアプリケーション・ユーザー
SMAVRIS
は、SALARY
列のすべての給与行を含むすべてのレコードを表示でき、任意のレコードを更新できます。
-
-
hrdemo_session.sql
: Real Application Securityセッションを作成および連結するデモを実行し、次のことを示します。-
Real Application Security管理者として接続し、アプリケーション・ユーザー
SMAVRIS
のアプリケーション・セッションを作成して連結します。 -
現在のユーザーを
SMAVRIS
として表示します。 -
現在のユーザー
SMAVRIS
に対して有効になっているデータベース・ロールをDB_EMP
、アプリケーション・ロールをemployee
、hr_representative
およびXSPUBLIC
として表示します。 -
SMAVRIS
アプリケーション・ユーザーは、SALARY
列のすべての給与行を含むすべてのレコードを表示できます。 -
hr_representative
を無効にして、アプリケーション・ユーザーSMAVRIS
が自分の従業員レコードのみ表示できるように制限します。 -
hr_representative
を有効にして、SMAVRIS
アプリケーション・ユーザーが、SALARY
列のすべての給与行を含むすべてのレコードを再び表示できるようにします。 -
アプリケーション・セッションから連結解除します。
-
アプリケーション・セッションを破棄します。
-
-
hrdemo_clean.sql
: アプリケーション・ロール、アプリケーション・ユーザー、ACL、データベース・セキュリティ・ポリシー、データベース・ロール、Real Application Security管理ユーザーおよび中間層ディスパッチャ・ユーザーを削除するクリーンアップ操作を実行します。 -
hrdemo.java
: Javaインタフェースを使用してHRデモを実行します。
セキュリティHRデモ・コンポーネントの設定で、Real Application Securityの各コンポーネントが作成される方法を他のいくつかの重要タスクの実行とともに詳細に説明します。
12.3 セキュリティHRデモ・コンポーネントの設定
Real Application Securityのコンポーネントを作成するには、まずSYS/
ユーザーとしてSYSDBA
で接続する必要があります。
define passwd=&1
connect sys/&passwd as sysdba
12.3.1 ロールおよびアプリケーション・ユーザーの作成について
アプリケーション・ロールEMPLOYEE
、IT_ENGINEER
、HR_REPRESENTATIVE
およびデータベース・ロールDB_EMP
を作成します。DB_EMP
ロールは、作成したDAUSTIN
とSMAVRIS
の2つのアプリケーション・ユーザーに、必要なオブジェクト権限を付与するために使用します。最後に、HR
ユーザーにポリシー管理権限ADMIN_ANY_SEC_POLICY
を付与します。
SYS/
ユーザーとしてSYSDBA
で接続します。
define passwd=&1 connect sys/&passwd as sysdba
一般的な従業員用のアプリケーション・ロールEMPLOYEE
を作成します。
exec sys.xs_principal.create_role(name => 'employee', enabled => true);
IT部門用のアプリケーション・ロールIT_ENGINEER
を作成します。
exec sys.xs_principal.create_role(name => 'it_engineer', enabled => true);
HR部門用のアプリケーション・ロールHR_REPRESENTATIVE
を作成します。
exec sys.xs_principal.create_role(name => 'hr_representative', enabled => true);
オブジェクト権限付与のためのデータベース・ロールDB_EMP
を作成します。
create role db_emp;
3つのアプリケーション・ロールにDB_EMP
データベース・ロールを付与して、それぞれが表へのアクセスに必要なオブジェクト権限を持つようにします。
grant db_emp to employee; grant db_emp to it_engineer; grant db_emp to hr_representative;
アプリケーション・ユーザーを作成します。
アプリケーション・ユーザーDAUSTIN
を(IT部門に)作成し、ユーザー・アプリケーション・ロールEMPLOYEE
およびIT_ENGINEER
を付与します。
exec sys.xs_principal.create_user(name => 'daustin', schema => 'hr'); exec sys.xs_principal.set_password('daustin', 'welcome1'); exec sys.xs_principal.grant_roles('daustin', 'XSCONNECT'); exec sys.xs_principal.grant_roles('daustin', 'employee'); exec sys.xs_principal.grant_roles('daustin', 'it_engineer');
アプリケーション・ユーザーSMAVRIS
を(HR部門に)作成し、ユーザー・アプリケーション・ロールEMPLOYEE
およびHR_REPRESENTATIVE
を付与します。
exec sys.xs_principal.create_user(name => 'smavris', schema => 'hr'); exec sys.xs_principal.set_password('smavris', 'welcome1'); exec sys.xs_principal.grant_roles('smavris', 'XSCONNECT'); exec sys.xs_principal.grant_roles('smavris', 'employee'); exec sys.xs_principal.grant_roles('smavris', 'hr_representative');
HR
ユーザーにポリシー管理権限ADMIN_ANY_SEC_POLICY
を付与します。
exec sys.xs_admin_util.grant_system_privilege('ADMIN_ANY_SEC_POLICY','HR');
12.3.2 セキュリティ・クラスおよびACLの作成について
最初に、必要な表権限をDB_EMP
ロールに付与します。
次に、事前定義済のDMLセキュリティ・クラスに基づいてセキュリティ・クラスHR_PRIVILEGES
を作成します。HR_PRIVILEGES
には、SALARY
列へのアクセスを制御する新しい権限VIEW_SALARY
があります。最後に、EMP_ACL
、IT_ACL
およびHR_ACL
の3つのACLを作成します。
HR
ユーザーとして接続します。
connect hr/hr;
必要なオブジェクト権限をDB_EMP
ロールに付与します。このロールを使用して、アプリケーション・ユーザーに必要なオブジェクト権限を付与します。
grant select, insert, update, delete on hr.employees to db_emp;
declare begin sys.xs_security_class.create_security_class( name => 'hr_privileges', parent_list => xs$name_list('sys.dml'), priv_list => xs$privilege_list(xs$privilege('view_salary'))); end; /
EMP_ACL
、IT_ACL
およびHR_ACL
の3つのACLを作成して、後で定義するデータ・セキュリティ・ポリシーの権限を付与します。
declare aces xs$ace_list := xs$ace_list(); begin aces.extend(1); -- EMP_ACL: This ACL grants EMPLOYEE role the privileges to view an employee's -- own record including SALARY column. aces(1) := xs$ace_type(privilege_list => xs$name_list('select','view_salary'), principal_name => 'employee'); sys.xs_acl.create_acl(name => 'emp_acl', ace_list => aces, sec_class => 'hr_privileges'); -- IT_ACL: This ACL grants IT_ENGINEER role the privilege to view the employee -- records in IT department, but it does not grant the VIEW_SALARY -- privilege that is required for access to SALARY column. aces(1) := xs$ace_type(privilege_list => xs$name_list('select'), principal_name => 'it_engineer'); sys.xs_acl.create_acl(name => 'it_acl', ace_list => aces, sec_class => 'hr_privileges'); -- HR_ACL: This ACL grants HR_REPRESENTITIVE role the privileges to view and update all -- employees' records including SALARY column. aces(1):= xs$ace_type(privilege_list => xs$name_list('select', 'insert', 'update', 'delete', 'view_salary'), principal_name => 'hr_representative'); sys.xs_acl.create_acl(name => 'hr_acl', ace_list => aces, sec_class => 'hr_privileges'); end; /
12.3.3 データ・セキュリティ・ポリシーの作成について
EMPLOYEE
表のデータ・セキュリティ・ポリシーを作成します。ポリシーは、3つのレルム制約とSALARY
列を保護する列制約を定義します。
declare realms xs$realm_constraint_list := xs$realm_constraint_list(); cols xs$column_constraint_list := xs$column_constraint_list(); begin realms.extend(3); -- Realm #1: Only the employee's own record. -- The EMPLOYEE role can view the realm including SALARY column. realms(1) := xs$realm_constraint_type( realm => 'email = xs_sys_context(''xs$session'',''username'')', acl_list => xs$name_list('emp_acl')); -- Realm #2: The records in the IT department. -- The IT_ENGINEER role can view the realm excluding SALARY column. realms(2) := xs$realm_constraint_type( realm => 'department_id = 60', acl_list => xs$name_list('it_acl')); -- Realm #3: All the records. -- The HR_REPRESENTATIVE role can view and update the realm including SALARY column. realms(3) := xs$realm_constraint_type( realm => '1 = 1', acl_list => xs$name_list('hr_acl')); -- Column constraint protects SALARY column by requiring VIEW_SALARY -- privilege. cols.extend(1); cols(1) := xs$column_constraint_type( column_list => xs$list('salary'), privilege => 'view_salary'); sys.xs_data_security.create_policy( name => 'employees_ds', realm_constraint_list => realms, column_constraint_list => cols); end; /
EMPLOYEES
表にデータ・セキュリティ・ポリシーを適用します。
begin sys.xs_data_security.apply_object_policy( policy => 'employees_ds', schema => 'hr', object =>'employees'); end; /
12.3.4 Real Application Securityオブジェクトの検証について
これらのReal Application Securityオブジェクトを作成した後で、これらを検証してすべて正しく構成されていることを確認します。
begin if (sys.xs_diag.validate_workspace()) then dbms_output.put_line('All configurations are correct.'); else dbms_output.put_line('Some configurations are incorrect.'); end if; end; / -- XS$VALIDATION_TABLE contains validation errors if any. -- Expect no rows selected. select * from xs$validation_table order by 1, 2, 3, 4;
12.3.5 中間層関連構成の設定について
後で使用する中間層関連の構成を設定します。これには、Real Application Security管理権限(XS_SESSION_ADMIN
およびCREATE SESSION
)のみを持ちデータ権限を持たない、セッション管理者hr_session
の作成も含まれます。セッション管理者は、各アプリケーション・ユーザーのReal Application Securityセッションを管理することに責任を持ちます。さらに、これにはDISPATCHER
ユーザーおよびパスワードを作成することと、このユーザーにXSCONNECT
およびXSDISPATCHER
のReal Application Security管理者権限を付与することが含まれます。
grant xs_session_admin, create session to hr_session identified by hr_session; grant create session to hr_common identified by hr_common;
アプリケーション・ユーザーのセッションを設定するための、Javaデモのディスパッチャ・ユーザーを作成します。
exec sys.xs_principal.create_user(name=>'dispatcher', schema=>'HR'); exec sys.xs_principal.set_password('dispatcher', 'welcome1'); exec sys.xs_principal.grant_roles('dispatcher', 'XSCONNECT'); exec sys.xs_principal.grant_roles('dispatcher', 'xsdispatcher');
12.4 直接ログオンを使用したセキュリティHRデモの実行
HRデモを実行するには、まず、EMPLOYEE
およびIT_ENGINEER
アプリケーション・ロールのみ持つアプリケーション・ユーザーDAUSTIN
として接続します。
conn daustin/welcome1;
列値のかわりにデフォルトのインジケータ・アスタリスク(*******)を使用してセキュリティで保護された列値をSQL*Plusに表示する方法をカスタマイズします。
SET SECUREDCOL ON UNAUTH *******
問合せを実行して、アプリケーション・ユーザーDAUSTIN
はIT部門のレコードを表示できるが自分のSALARY
列のみ表示できることを示します。
select email, first_name, last_name, department_id, manager_id, salary from employees order by email; SQL> select email, first_name, last_name, department_id, manager_id, salary 2 from employees order by email; EMAIL FIRST_NAME LAST_NAME DEPARTMENT_ID MANAGER_ID SALARY ---------- --------------- --------------- ------------- ---------- ------- AHUNOLD Alexander Hunold 60 102 ******* BERNST Bruce Ernst 60 103 ******* DAUSTIN David Austin 60 103 4800 DLORENTZ Diana Lorentz 60 103 ******* VPATABAL Valli Pataballa 60 103 ******* 5 rows selected.
認可のないアプリケーション・ユーザーの列値およびセキュリティ・レベルが不明な列値のかわりにnull値を表示することで、セキュリティで保護された列値をSQL*Plusに表示する方法のデフォルト表示に設定します。
SET SECUREDCOL OFF
更新操作を実行して、アプリケーション・ユーザーがレコードの更新を認可されないことを示します。
update employees set manager_id = 102 where email = 'DAUSTIN'; SQL> update employees set manager_id = 102 where email = 'DAUSTIN'; 0 rows updated.
問合せを実行して、レコードが変更されていないことを示します。
select email, first_name, last_name, department_id, manager_id, salary from employees where email = 'DAUSTIN'; SQL> select email, first_name, last_name, department_id, manager_id, salary 2 from employees where email = 'DAUSTIN'; EMAIL FIRST_NAME LAST_NAME DEPARTMENT_ID MANAGER_ID SALARY ---------- --------------- --------------- ------------- ---------- ------- DAUSTIN David Austin 60 103 4800 1 row selected.
EMPLOYEE
とHR_REPRESENTATIVE
の両方のロールを持つアプリケーション・ユーザーSMAVRIS
として接続します。
conn smavris/welcome1;
問合せを実行して、アプリケーション・ユーザーSMAVRIS
がSALARY
列を含むすべてのレコードを表示できることを示します。
select email, first_name, last_name, department_id, manager_id, salary from employees where department_id = 60 or department_id = 40 order by department_id, email; SQL> select email, first_name, last_name, department_id, manager_id, salary 2 from employees where department_id = 60 or department_id = 40 3 order by department_id, email; EMAIL FIRST_NAME LAST_NAME DEPARTMENT_ID MANAGER_ID SALARY ---------- --------------- --------------- ------------- ---------- ------- SMAVRIS Susan Mavris 40 101 6500 AHUNOLD Alexander Hunold 60 102 9000 BERNST Bruce Ernst 60 103 6000 DAUSTIN David Austin 60 103 4800 DLORENTZ Diana Lorentz 60 103 4200 VPATABAL Valli Pataballa 60 103 4800 6 rows selected.
問合せを実行して、アプリケーション・ユーザーSMAVRIS
がすべてのレコードにアクセスできることを示します。
select count(*) from employees; SQL> select count(*) from employees; COUNT(*) ---------- 107 1 row selected.
レコードの更新を実行して、アプリケーション・ユーザーSMAVRIS
がレコードを更新できることを示します。
update employees set manager_id = 102 where email = 'DAUSTIN'; SQL> update employees set manager_id = 102 where email = 'DAUSTIN'; 1 row updated.
問合せを実行して、レコードが変更されていることを示します。
select email, first_name, last_name, department_id, manager_id, salary from employees where email = 'DAUSTIN'; SQL> select email, first_name, last_name, department_id, manager_id, salary 2 from employees where email = 'DAUSTIN'; EMAIL FIRST_NAME LAST_NAME DEPARTMENT_ID MANAGER_ID SALARY ---------- --------------- --------------- ------------- ---------- ------- DAUSTIN David Austin 60 102 4800 1 row selected.
レコードを更新して、元の状態に戻します。
update employees set manager_id = 103 where email = 'DAUSTIN'; SQL> update employees set manager_id = 103 where email = 'DAUSTIN'; 1 row updated.
12.5 Real Application Securityセッションに連結されたセキュリティHRデモの実行
Real Application Securityセッションに連結されているデモを実行するには、Real Application Security管理者が最初にアプリケーション・ユーザーのセッションを作成し、それに連結する必要があります。プロセスで、セッションIDを記憶する変数を作成します。
connect hr_session/hr_session; var gsessionid varchar2(32); declare sessionid raw(16); begin sys.dbms_xs_sessions.create_session('SMAVRIS', sessionid); :gsessionid := rawtohex(sessionid); sys.dbms_xs_sessions.attach_session(sessionid, null); end ; /
現在のユーザーを表示します。
select xs_sys_context('xs$session','username') from dual; SQL> select xs_sys_context('xs$session','username') from dual; XS_SYS_CONTEXT('XS$SESSION','USERNAME') -------------------------------------------------------------------------------- SMAVRIS 1 row selected.
現在のアプリケーション・ユーザーに対して有効になっているデータベースおよびアプリケーション・ロールを表示します。
select role_name from v$xs_session_roles union select role from session_roles order by 1; SQL> select role_name from v$xs_session_roles union 2 select role from session_roles order by 1; ROLE_NAME -------------------------------------------------------------------------------- DB_EMP EMPLOYEE HR_REPRESENTATIVE XSPUBLIC 4 rows selected.
問合せを実行して、アプリケーション・ユーザーSMAVRIS
がSALARY
列を含むすべてのレコードを表示できることを示します。
select email, first_name, last_name, department_id, manager_id, salary from employees where department_id = 60 or department_id = 40 order by department_id, email; SQL> select email, first_name, last_name, department_id, manager_id, salary 2 from employees where department_id = 60 or department_id = 40 3 order by department_id, email; EMAIL FIRST_NAME LAST_NAME DEPARTMENT_ID MANAGER_ID SALARY ---------- --------------- --------------- ------------- ---------- ------- SMAVRIS Susan Mavris 40 101 6500 AHUNOLD Alexander Hunold 60 102 9000 BERNST Bruce Ernst 60 103 6000 DAUSTIN David Austin 60 103 4800 DLORENTZ Diana Lorentz 60 103 4200 VPATABAL Valli Pataballa 60 103 4800 6 rows selected.
問合せを実行して、アプリケーション・ユーザーSMAVRIS
がすべてのレコードにアクセスできることを示します。
select count(*) from employees; SQL> select count(*) from employees; COUNT(*) ---------- 107 1 row selected.
HR_REPRESENTATIVE
ロールを無効にします。これにより、アプリケーション・ユーザーSMAVRIS
は自分のレコードのみ表示できるように制限されます。
exec dbms_xs_sessions.disable_role('hr_representative');
問合せの実行
select email, first_name, last_name, department_id, manager_id, salary from employees where department_id = 60 or department_id = 40 order by department_id, email; SQL> select email, first_name, last_name, department_id, manager_id, salary 2 from employees where department_id = 60 or department_id = 40 3 order by department_id, email; EMAIL FIRST_NAME LAST_NAME DEPARTMENT_ID MANAGER_ID SALARY ---------- --------------- --------------- ------------- ---------- ------- SMAVRIS Susan Mavris 40 101 6500 1 row selected.
HR_REPRESENTATIVE
ロールを有効にして、アプリケーション・ユーザーがSALARY
列を含むすべてのレコードを表示できるようにします。
exec dbms_xs_sessions.enable_role('hr_representative');
問合せを実行して、アプリケーション・ユーザーがSALARY
列を含むすべてのレコードを表示できることを示します。
select email, first_name, last_name, department_id, manager_id, salary from employees where department_id = 60 or department_id = 40 order by department_id, email; SQL> -- SMAVRIS can view all the records again. SQL> select email, first_name, last_name, department_id, manager_id, salary 2 from employees where department_id = 60 or department_id = 40 3 order by department_id, email; EMAIL FIRST_NAME LAST_NAME DEPARTMENT_ID MANAGER_ID SALARY ---------- --------------- --------------- ------------- ---------- ------- SMAVRIS Susan Mavris 40 101 6500 AHUNOLD Alexander Hunold 60 102 9000 BERNST Bruce Ernst 60 103 6000 DAUSTIN David Austin 60 103 4800 DLORENTZ Diana Lorentz 60 103 4200 VPATABAL Valli Pataballa 60 103 4800 6 rows selected.
問合せを実行して、アプリケーション・ユーザーSMAVRIS
がすべてのレコードにアクセスできることを示します。
select count(*) from employees; SQL> select count(*) from employees; COUNT(*) ---------- 107 1 row selected.
アプリケーション・セッションを連結解除して破棄します。
declare sessionid raw(16); begin sessionid := hextoraw(:gsessionid); sys.dbms_xs_sessions.detach_session; sys.dbms_xs_sessions.destroy_session(sessionid); end; /
12.6 セキュリティHRデモ・クリーンアップ・スクリプトの実行
HRデモを実行した後で、クリーン・アップ・スクリプトを実行して、すべてのReal Application Securityコンポーネントを削除できます。
開始するには、Real Application Security管理者として接続し、コンポーネントの削除を開始します。
define passwd=&1 connect hr/hr;
EMPLOYEES
表からデータ・セキュリティ・ポリシーを削除します。
begin xs_data_security.remove_object_policy(policy=>'employees_ds', schema=>'hr', object=>'employees'); end; /
セキュリティ・クラスとACLを削除します。
exec sys.xs_security_class.delete_security_class('hrprivs', xs_admin_util.cascade_option); exec sys.xs_acl.delete_acl('emp_acl', xs_admin_util.cascade_option); exec sys.xs_acl.delete_acl('it_acl', xs_admin_util.cascade_option); exec sys.xs_acl.delete_acl('hr_acl', xs_admin_util.cascade_option);
データ・セキュリティ・ポリシーを削除します。
exec sys.xs_data_security.delete_policy('employees_ds', xs_admin_util.cascade_option);
SYS/
ユーザーとしてSYSDBA
で接続します。
connect sys/&passwd as sysdba
アプリケーション・ロールおよびアプリケーション・ユーザーを削除します。
exec sys.xs_principal.delete_principal('employee', xs_admin_util.cascade_option); exec sys.xs_principal.delete_principal('hr_representative', xs_admin_util.cascade_option); exec sys.xs_principal.delete_principal('it_engineer', xs_admin_util.cascade_option); exec sys.xs_principal.delete_principal('smavris', xs_admin_util.cascade_option); exec sys.xs_principal.delete_principal('daustin', xs_admin_util.cascade_option);
データベース・ロールを削除します。
drop role db_emp;
Real Application Securityセッション管理者を削除します。
drop user hr_session;
データベースへの接続に使用した一般ユーザーを削除します。
drop user hr_common;
中間層で使用されているDISPATCHER
ユーザーを削除します。
exec sys.xs_principal.delete_principal('dispatcher', xs_admin_util.cascade_option);
12.7 JavaインタフェースでのセキュリティHRデモの実行
JavaインタフェースでのセキュリティHRデモの実行により戻される2つの問合せの説明は、人事管理のユースケース: Javaでの実装の「出力」の項を参照してください。