MINI MINI MANI MO

Path : /opt/oracle/product/18c/dbhomeXE/rdbms/xml/xsl/
File Upload :
Current File : //opt/oracle/product/18c/dbhomeXE/rdbms/xml/xsl/kutssclass.xsl

<?xml version="1.0"?>
<!-- 
 Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 
NAME
    kutssclass.xsl
DESCRIPTION
    XSLT stylesheet for XML => DDL conversion of ku$_xssclass_t, 
   (i.e., Triton Security Classes). Because there can be a large number
    of privs associated with a security class they are created first and
    then the privs are add/appended within a seperate anonymous PL/SQL 
    blocks.

EXAMPLE:
    BEGIN
       xs_security_class.create_security_class(
          name => '"SYS"."SC1"',
          description => 'Security Class 1 description',
          priv_list => NULL,
          parent_list => XS$NAME_LIST('"SYS"."PARENTSC0"'));
    END;

    DECLARE
       priv_list     XS$PRIVILEGE_LIST;
    BEGIN
       priv_list := XS$PRIVILEGE_LIST(
            XS$PRIVILEGE(name=>'"P1"'),
            XS$PRIVILEGE(name=>'"AG1"',
            description =>'Children Priv Description',
            implied_priv_list => xs$name_list('"P0"','"P1"')));
      xs_security_class.add_privileges(sec_class=>'"SYS"."SC1"', priv_list=>priv_list);
 END;
NOTES
    Do NOT modify this file under any circumstance. Copy the file
    if you wish to use this stylesheet with an external XML/XSL parser

MODIFIED      MM/DD/YY
   rapayne      07/20/12 - bug 13823879: limit the number of privs and 
                                       add them in seperate exec blocks.
    taahmed     02/21/12 - defacl cleanup
    rapayne     12/17/11 - Triton PRIVS are no longer schema based.
    rapayne   10/26/11 - OWNER changed to  OWNER_NAME
    rapayne   08/31/11 - Triton rename to Real Application Security (RAS).
                         Object names will be changed from TS_* to XS_*.
    rapayne   07/04/11   Add support for schema-based XDS objects.
    rapayne   08/17/10 - Creation 
 -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <!-- Import required scripts -->
 <xsl:import href="kucommon.xsl"/>
 <!-- Top-level parameters -->
 <xsl:param name="PRETTY">1</xsl:param>
 <xsl:param name="SQLTERMINATOR">1</xsl:param>
 <!-- params for parse -->
 <xsl:param name="PRS_DDL">0</xsl:param>
 <xsl:param name="PRS_DELIM">\{]`</xsl:param>
 <xsl:param name="PRS_VERB">0</xsl:param>
 <xsl:param name="PRS_OBJECT_TYPE">0</xsl:param>
 <xsl:param name="PRS_SCHEMA">0</xsl:param>
 <xsl:param name="PRS_NAME">0</xsl:param>
 <xsl:param name="PRS_GRANTEE">0</xsl:param>
 <xsl:param name="PRS_GRANTOR">0</xsl:param>
 <xsl:param name="PRS_BASE_OBJECT_SCHEMA">0</xsl:param>
 <xsl:param name="PRS_BASE_OBJECT_NAME">0</xsl:param>
 <xsl:param name="PRS_BASE_OBJECT_TYPE">0</xsl:param>
 <xsl:template match="XS_SECURITY_CLASS_T">
  <xsl:call-template name="DoParse">
   <xsl:with-param name="Verb">CREATE</xsl:with-param>
   <xsl:with-param name="ObjectType">XS_SECURITY_CLASS</xsl:with-param>
   <xsl:with-param name="NameNode" select="XS_OBJ/NAME"/>
  </xsl:call-template>
  <!-- Create the anonymous PL/SQL block to create the XS_SECURITY_CLASS-->
  <xsl:call-template name="CreateSecurityClass"/>
  <!-- Create the anonymous PL/SQL block to add all of the XS_PRIVILEGES to the SCLASS-->
  <xsl:call-template name="AddPrivilegeLists">
   <xsl:with-param name="PrivList" select="PRIV_LIST"/>
   <xsl:with-param name="SecClass" select="XS_OBJ"/>
  </xsl:call-template>
 </xsl:template>
 <xsl:template name="CreateSecurityClass">
  <!-- *******************************************************************
Template: CreateSecurityClass
Decription: Simply instantiate the XS_SECURITY_CLASS. The privilege list
               will be added after the create of the class.
******************************************************************** -->
  <xsl:text>&#xa;</xsl:text>
  <xsl:text>BEGIN</xsl:text>
  <xsl:text>&#xa;   </xsl:text>
  <xsl:text>xs_security_class.create_security_class(</xsl:text>
  <xsl:text>&#xa;     </xsl:text>
  <xsl:text>name => </xsl:text>
  <xsl:call-template name="TSQuoteObject">
   <xsl:with-param name="Schema" select="XS_OBJ/OWNER_NAME"/>
   <xsl:with-param name="Object" select="XS_OBJ/NAME"/>
  </xsl:call-template>
  <!-- generate DESCRIPTION parameter if appropriate -->
  <xsl:if test="DESCRIPTION">
   <xsl:text>,&#xa;     </xsl:text>
   <xsl:text>description => </xsl:text>
   <xsl:call-template name="SingleQuotedName">
    <xsl:with-param name="NameNode" select="DESCRIPTION"/>
   </xsl:call-template>
  </xsl:if>
  <!-- add NULL privilege_list - it will be process thru the add_privilieges api.-->
  <xsl:text>,&#xa;     </xsl:text>
  <xsl:text>priv_list => NULL</xsl:text>
  <!-- Process PARENT_LIST is present-->
  <xsl:if test="PARENT_LIST/PARENT_LIST_ITEM">
   <xsl:text>,&#xa;     </xsl:text>
   <xsl:text>parent_list => </xsl:text>
   <xsl:call-template name="buildParentList">
    <xsl:with-param name="ParentList" select="PARENT_LIST/PARENT_LIST_ITEM"/>
   </xsl:call-template>
  </xsl:if>
  <xsl:text>);</xsl:text>
  <xsl:text>&#xa;</xsl:text>
  <xsl:text>END;&#xa;</xsl:text>
  <xsl:if test="$SQLTERMINATOR=1">
   <xsl:text>/</xsl:text>
  </xsl:if>
 </xsl:template>
 <xsl:template name="buildParentList">
  <xsl:param name="ParentList" select="''"/>
  <!-- *******************************************************************
Template: buildParentList
Parameters:
 privList  - PARENT_LIST/PARENT_LIST_ITEM 
******************************************************************** -->
  <xsl:text>XS$NAME_LIST(</xsl:text>
  <xsl:for-each select="$ParentList">
   <xsl:call-template name="TSQuoteObject">
    <xsl:with-param name="Schema" select="PARENT_OWNER"/>
    <xsl:with-param name="Object" select="PARENT_NAME"/>
   </xsl:call-template>
   <xsl:choose>
    <xsl:when test="position()=last()">
     <xsl:text>)</xsl:text>
    </xsl:when>
    <xsl:otherwise>, </xsl:otherwise>
   </xsl:choose>
  </xsl:for-each>
 </xsl:template>
 <xsl:template name="AddPrivilegeLists">
  <xsl:param name="PrivList" select="''"/>
  <xsl:param name="SecClass" select="''"/>
  <!-- *******************************************************************
Template:  AddPrivilegeLists
Decription: Although its possible to add_privileges in the create_secutity_class call
   the XS$PRIVILEGE_LIST macro has a limit of 1000 elements. Although this is somewhat
   pathological it behooves us to accommodate a large priv list. Consequently,  we process
   these privs in blocks of 1000 and for each block we add them to the security class.
Parameters:
 privList  - PRIV_LIST (containing items for each ace associated with the security class
 SecClass  - XS_OBJ node containing name of Security Class
******************************************************************** -->
  <xsl:for-each select="$PrivList/PRIV_LIST_ITEM [position() mod 500 = 1]">
   <xsl:call-template name="DoParse">
    <xsl:with-param name="Verb">APPEND</xsl:with-param>
    <xsl:with-param name="ObjectType">XS_SECURITY_CLASS</xsl:with-param>
    <xsl:with-param name="NameNode" select="$SecClass/NAME"/>
   </xsl:call-template>
   <xsl:text>&#xa;</xsl:text>
   <xsl:text>DECLARE</xsl:text>
   <xsl:text>&#xa; </xsl:text>
   <xsl:text>priv_list     XS$PRIVILEGE_LIST;</xsl:text>
   <xsl:text>&#xa;</xsl:text>
   <xsl:text>BEGIN</xsl:text>
   <xsl:text>&#xa; </xsl:text>
   <xsl:text>priv_list := XS$PRIVILEGE_LIST(</xsl:text>
   <xsl:for-each select=". |following-sibling::*[not(position() >= 500)]">
    <xsl:text>&#xa;   XS$PRIVILEGE(name=></xsl:text>
    <!-- Triton PRIVILEGES do not have owners (i.e., unlike ACLs, SECURITY_CLASSes, etc).
              Simply don't pass the OWNER and TSQuoteObject should do the right thing
       -->
    <xsl:call-template name="TSQuoteObject">
     <xsl:with-param name="Object" select="NAME"/>
    </xsl:call-template>
    <xsl:if test="DESCRIPTION">
     <xsl:text>, &#xa;       description =></xsl:text>
     <xsl:call-template name="SingleQuotedName">
      <xsl:with-param name="NameNode" select="DESCRIPTION"/>
     </xsl:call-template>
    </xsl:if>
    <xsl:if test="AGGR_PRIV_LIST/AGGR_PRIV_LIST_ITEM">
     <xsl:text>, &#xa;       implied_priv_list => xs$name_list(</xsl:text>
     <xsl:for-each select="AGGR_PRIV_LIST/AGGR_PRIV_LIST_ITEM">
      <xsl:sort order="ascending" select="NAME"/>
      <!-- Triton PRIVILEGES do not have owners (i.e., unlike ACLs, SECURITY_CLASSes, etc).
              Simply don't pass the OWNER and TSQuoteObject should do the right thing
     -->
      <xsl:call-template name="TSQuoteObject">
       <xsl:with-param name="Object" select="NAME"/>
      </xsl:call-template>
      <xsl:choose>
       <xsl:when test="position()=last()">
        <xsl:text>)</xsl:text>
       </xsl:when>
       <xsl:otherwise>
        <xsl:text>,</xsl:text>
       </xsl:otherwise>
      </xsl:choose>
     </xsl:for-each>
    </xsl:if>
    <xsl:text>)</xsl:text>
    <xsl:choose>
     <xsl:when test="position()=last()">);</xsl:when>
     <xsl:otherwise>,</xsl:otherwise>
    </xsl:choose>
   </xsl:for-each>
   <xsl:text>&#xa;     </xsl:text>
   <xsl:text>&#xa; xs_security_class.add_privileges(sec_class=></xsl:text>
   <xsl:call-template name="TSQuoteObject">
    <xsl:with-param name="Schema" select="$SecClass/OWNER_NAME"/>
    <xsl:with-param name="Object" select="$SecClass/NAME"/>
   </xsl:call-template>
   <xsl:text>, priv_list=>priv_list);</xsl:text>
   <xsl:text>&#xa;END;&#xa;</xsl:text>
   <xsl:if test="$SQLTERMINATOR=1">
    <xsl:text>/</xsl:text>
   </xsl:if>
  </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>

OHA YOOOO