declare
v_count number;
uprinciple varchar2(20);
principle varchar2(20);
begin
uprinciple := upper('&wssl_user');
select count(1) into v_count from dba_network_acls where acl like '%httprepuestpermission01.xml%';
if v_count <> 0 then
dbms_network_acl_admin.drop_acl(acl=> 'httprepuestpermission01.xml');
commit;
end if;
--1.0 创建 ACL 以及相关操作
dbms_network_acl_admin.create_acl(acl => 'httprepuestpermission01.xml',
description => 'Network permissions',
principal => uprinciple,
is_grant => TRUE,
privilege => 'connect',
start_date => systimestamp,
end_date => null);
commit;
--1.1 授予普通用户可以使用ACL的权限
dbms_network_acl_admin.add_privilege(acl => 'httprepuestpermission01.xml',
principal => uprinciple, --要使用acl的用户
is_grant => true,
privilege => 'connect',
start_date => systimestamp,
end_date => null);
commit;
--1.2授予普通用户可以使用ACL的权限
dbms_network_acl_admin.assign_acl(acl => 'httprepuestpermission01.xml',
host => '&url_ip', --要访问的目标主机
lower_port => &url_port, --要访问的端口
upper_port => &url_port);
commit;
end;
/