- DBMS_NETWORK_ACL_ADMIN 包提供管理 the network Access Control List (ACL) 的接口。
- DBMS_NETWORK_ACL_ADMIN.CREATE_ACL
- DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE
- DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL
这个方法是用来创建xml配置文件,并进行设置。
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL (
acl IN VARCHAR2, -- acl xml stored in '/sys/acls'
description IN VARCHAR2, -- a description for xml
principal IN VARCHAR2, -- database user or role the acl.xml is for
is_grant IN BOOLEAN, -- Privilege is granted or not (denied)
privilege IN VARCHAR2, -- Network privilege to be granted or denied - 'connect | resolve' (case sensitive)
start_date IN TIMESTAMP WITH TIMEZONE DEFAULT NULL,
end_date IN TIMESTAMP WITH TIMEZONE DEFAULT NULL );
/* note:
for principal :
principal must be in upper case.
for parameter privilege:
1. connect privilege is needed when the UTL_TCP, UTL_HTTP, UTL_SMTP, and UTL_MAIL utility packages are used.
2. the resolve privilege is needed when the UTL_INADDR package is used.
*/
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE这个方法用于修改配置文件。
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE (
acl IN VARCHAR2,
principal IN VARCHAR2,
is_grant IN BOOLEAN,
privilege IN VARCHAR2,
position IN PLS_INTEGER DEFAULT NULL,
start_date IN TIMESTAMP WITH TIMESTAMP DEFAULT NULL,
end_date IN TIMESTAMP WITH TIMESTAMP DEFAULT NULL );
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL这个方法用于管理访问host和使用端口。
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (
acl IN VARCHAR2,
host IN VARCHAR2, -- the host (name and ip both are ok )
lower_port IN PLS_INTEGER DEFAULT NULL,
upper_port IN PLS_INTEGER DEFAULT NULL);
/*note:
1. both lower_port and upper_port must not be NULL and upper_port must be greater than or equal to lower_port.
2. 'www.baidu.com' ,'*.baidu.com','*.com' and '*' can all be used for www.baidu.com,but precedence will be lower
*/
例子
BEGIN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl => 'www.xml',
description => 'WWW ACL',
principal => 'TEST',
is_grant => true,
privilege => 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'www.xml',
principal => 'TEST',
is_grant => true,
privilege => 'resolve');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(
acl => 'www.xml',
host => 'www.baidu.com',
lower_port => 80);
END;
/
COMMIT;