Oracle XS_NAMESPACE
Version 21c

General Information
Library Note Morgan's Library Page Header
ACE Director Alum Daniel Morgan, founder of Morgan's Library, is scheduling complimentary technical Workshops on Database Security for the first 30 Oracle Database customers located anywhere in North America, EMEA, LATAM, or APAC that send an email to asra_us@oracle.com. Request a Workshop for your organization today.
Purpose Real Application Security Namespace Management
AUTHID CURRENT_USER
Constants
Name Data Type Value
Attribute Events
NO_EVENT PLS_INTEGER 0
FIRSTREAD_EVENT PLS_INTEGER 1
UPDATE_EVENT PLS_INTEGER 2
FIRSTREAD_PLUS_UPDATE_EVENT PLS_INTEGER 3
Data Types -- the full DDL can be found in {ORACLE_HOME}/rdbms/admin/xsns.sql
CREATE OR REPLACE NONEDITIONABLE TYPE sys.xs$ns_attribute_list AS
VARRAY(1000) OF XS$NS_ATTRIBUTE;
/

CREATE OR REPLACE NONEDITIONABLE TYPE sys.xs$list IS
VARRAY(1000) OF VARCHAR2(4000);
Dependencies
CDB_XS_NS_TEMPLATES XS$LIST XS_ADMIN_INT
CDB_XS_NS_TEMPLATE_ATTRIBUTES XS$NS_ATTRIBUTE XS_ADMIN_UTIL
PLITBLM XS$NS_ATTRIBUTE_LIST XS_NAMESPACE_INT
Documented Yes
First Available 12.1
Pragma -- Enable log based replication for this package
PRAGMA SUPPLEMENTAL_LOG_DATA(default, AUTO);
Security Model Owned by SYS with EXECUTE granted to PUBLIC
Source {ORACLE_HOME}/rdbms/admin/xsns.sql

The DBA role is granted to the ADMIN_ANY_SEC_POLICY, which allows it to administer namespace templates and attributes.
Subprograms
 
ADD_ATTRIBUTES
Add a attributes to the namespace template

Overload 1
xs_namespace.add_attributes(
template         IN VARCHAR2,
attribute        IN VARCHAR2,
default_value    IN VARCHAR2    := NULL,
attribute_events IN PLS_INTEGER := xs_namespace.no_event);
-- demo from Oracle RAS doc
BEGIN
  sys.xs_namespace.add_attributes('POAttrs', 'item_type', 'generic', xs_namespace.update_event);
  sys.xs_namespace.remove_attributes('POAttrs', 'item_type');
END;
/
Add a attributes to the namespace template

Overload 2
xs_namespace.add_attributes(
template  IN VARCHAR2,
attr_list IN xs$ns_attribute_list);
TBD
 
CREATE_TEMPLATE
Document creation API xs_namespace.create_template(
name        IN VARCHAR2,
attr_list   IN XS$NS_ATTRIBUTE_LIST := NULL,
schema      IN VARCHAR2             := NULL,
package     IN VARCHAR2             := NULL,
function    IN VARCHAR2             := NULL,
acl         IN VARCHAR2             := 'SYS.NS_UNRESTRICTED_ACL',
description IN VARCHAR2             := NULL);
-- based on demo from Oracle RAS doc
DECLARE
 attrlist xs$ns_attribute_list;
BEGIN
  attrlist := xs$ns_attribute_list();
  attrlist.extend(2);
  attrlist(1) := xs$ns_attribute('desc', 'general');
  attrlist(2) := xs$ns_attribute(name=>'item_no',
  attribute_events => xs_namespace.firstread_event);

  sys.xs_namespace.create_template(POAttrs, attrlist, 'SH', 'order','fulfillment', 'sys.ns_unrestricted_acl', 'Purchase Order');
END;
/

col acl format a20
col description format a42

SELECT name, acl, description
FROM cdb_xs_ns_templates;

col attribute format a23
col namespace format a15
col default_value format a20

SELECT *
FROM cdb_xs_ns_template_attributes
 
DELETE_TEMPLATE
Delete the namespace template xs_namespace.delete_template(
template      IN VARCHAR2,
delete_option IN PLS_INTEGER := xs_admin_util.default_option);
exec xs_namespace.delete_template('POAttrs', xs_admin_util.cascade_option);
 
REMOVE_ATTRIBUTES
Remove all attributes to the namespace template

Overload 1
xs_namespace.remove_attributes(template IN VARCHAR2);
exec sys.xs_namespace.remove_attributes('POAttrs');
Remove a single attribute from the namespace template

Overload 2
xs_namespace.remove_attributes(
template  IN VARCHAR2,
attribute IN VARCHAR2);
See ADD_ATTRIBUTES Demo Above
Remove a list of attribute from the namespace template

Overload 3
xs_namespace.remove_attributes(
template  IN VARCHAR2,
attr_list IN XS$LIST);
TBD
 
SET_DESCRIPTION
Set namespace description xs_namespace.set_description(
template    IN VARCHAR2,
description IN VARCHAR2);
exec sys.xs_namespace.set_description('POAttrs','Purchase Order Attributes');
 
SET_HANDLER
Set handler for attribute events xs_namespace.set_handler(
template IN VARCHAR2,
schema   IN VARCHAR2,
package  IN VARCHAR2,
function IN VARCHAR2);
exec sys.xs_namespace.set_handler(POAttrs', 'SH', 'orders', 'populate_po');

Related Topics
Built-in Functions
Built-in Packages
Database Security
DBMS_XS_PRINCIPALS
DBMS_XS_SESSIONS_FFI
DBMS_XS_SIDP
DBMS_XS_SYSTEM
DBMS_XS_SYSTEM_FFI
XS_ACL
XS_ADMIN_UTIL
XS_DATA_SECURITY
XS_DATA_SECURITY_UTIL
XS_DIAG
XS_DIAG_INT
XS_NAMESPACE_INT
XS_SECURITY_CLASS
What's New In 21c
What's New In 23c

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2023 Daniel A. Morgan All Rights Reserved
  DBSecWorx