其中牵涉到几个名词,解释一下:
Policy:就是安全策略,一个安全策略是level,compartment,group,label的集合。
Level:等级,这是最基础的安全控制等级,必须设置。
Compartment:分隔(这不是官方翻译),提供第二级的安全控制,是可选的。
Group:组(这不是官方翻译),提供第三级的安全控制,是可选的。
Label:标签,最终体现到每一行上的安全标签,必须设置。只有用户被赋予的标签和此行上的标签相同或者等级更高的时候,该行才能够被用户存取。
1。创建策略:
EXEC sa_sysdba.create_policy('DOC_POLICY','DOC_LABEL');
2。创建敏感等级:
EXEC sa_components.create_level('DOC_POLICY', 1000, 'PUBLIC', 'Public Level');
EXEC sa_components.create_level('DOC_POLICY', 2000, 'INTERNAL', 'Internal Level');
3。创建分隔:
EXEC sa_components.create_compartment('DOC_POLICY', 200, 'FIN', 'FINANCE');
EXEC sa_components.create_compartment('DOC_POLICY', 100, 'HR', 'HUMAN_RESOURCE');
4。创建分组:
EXEC sa_components.create_group('DOC_POLICY', 10, 'ALL', 'ALL_REGIONS');
EXEC sa_components.create_group('DOC_POLICY', 20, 'WEST','WEST_REGION', 'ALL');
EXEC sa_components.create_group('DOC_POLICY', 30, 'EAST', 'EAST_REGION', 'ALL');
((级别:分隔:组) 组成标签)(就是对于某个部门某个区域的用户的数据(记录)分别分配一个不同的标记,也就是标签的数字号,对用户也分配同样的标记)
5。创建标签:
EXEC sa_label_admin.create_label('DOC_POLICY', '10000', 'PUBLIC', TRUE);
EXEC sa_label_admin.create_label('DOC_POLICY', '20200','INTERNAL:HR:WEST', TRUE);
EXEC sa_label_admin.create_label('DOC_POLICY', '20400','INTERNAL:FIN:EAST', TRUE);
EXEC sa_label_admin.create_label('DOC_POLICY', '30900','INTERNAL:HR,FIN:ALL', TRUE);
7。向用户分配标签:
EXEC sa_user_admin.set_user_labels -
( policy_name => 'DOC_POLICY' -
, user_name => 'TEST' -
, max_read_label => 'INTERNAL:HR,FIN:ALL' -
, max_write_label => 'INTERNAL:HR,FIN:ALL' -
, min_write_label => 'PUBLIC' -
, def_label => 'INTERNAL:HR,FIN:ALL' -
, row_label => 'PUBLIC');
EXEC sa_user_admin.set_user_labels -
( policy_name => 'DOC_POLICY' -
, user_name => 'HR' -
, max_read_label => 'INTERNAL:HR:WEST' -
, max_write_label => 'INTERNAL:HR:WEST' -
, min_write_label => 'PUBLIC' -
, def_label => 'INTERNAL:HR:WEST' -
, row_label => 'PUBLIC');
EXEC sa_user_admin.set_user_labels -
( policy_name => 'DOC_POLICY' -
, user_name => 'SCOTT' -
, max_read_label => 'PUBLIC' -
, max_write_label => 'PUBLIC' -
, min_write_label => 'PUBLIC' -
, def_label => 'PUBLIC' -
, row_label => 'PUBLIC');
INSERT INTO ts.document VALUES(1, 'SHARE_WARE',CHAR_TO_LABEL('DOC_POLICY','PUBLIC'));
INSERT INTO ts.document VALUES (2, 'WEST_PAYROLL', 20200);
INSERT INTO ts.document VALUES (3, 'EAST_SALES', 20400);
INSERT INTO ts.document VALUES (4, 'COMP_PAYROLL', 30900);