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/kutsacl.xsl

<?xml version="1.0"?>
<!-- 
 Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
NAME
    kutsacl.xsl
DESCRIPTION
    XSLT stylesheet for XML => DDL conversion of ku$_xsacl_t ADTs
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
    bwright  08/21/13 - Bug 17312600: Remove hard tabs from DP src code
    rapayne  10/10/11 - add proper quoting for PRIN_NAME.
    rapayne  10/03/11 - remap support.
    rapayne  08/31/11 - Triton rename to Real Application Security (RAS).
                        Object names will be changed from TS_* to XS_*.
    rapayne  07/04/11 - proj: schema based XDS objects
    rapayne  07/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>
 <!-- Template match for Triton Security ACLs -->
 <xsl:template match="XS_ACL_T">
  <!-- *******************************************************************
Template: XS_ACL_T
Description: top-level template for Triton Security ACLs (XS_ACL_T objects).
   Calls callCreateACL to generate anonymous PL/SQL block which calls
   apropriate Triton Security API (i.e., xs_acl.create_acl) to create Triton
   ACL.
******************************************************************** -->
  <xsl:call-template name="DoParse">
   <xsl:with-param name="Verb">CREATE</xsl:with-param>
   <xsl:with-param name="ObjectType">XS_ACL</xsl:with-param>
   <xsl:with-param name="NameNode" select="XS_OBJ/NAME"/>
  </xsl:call-template>
  <xsl:text>&#xa;</xsl:text>
  <xsl:call-template name="callCreateACL">
   <xsl:with-param name="ACLobj" select="XS_OBJ"/>
  </xsl:call-template>
 </xsl:template>
 <!-- Template match for Triton Security ACL Parameters -->
 <xsl:template match="XS_ACL_PARAM_T">
  <!-- *******************************************************************
Template: XS_ACL_PARAM_T
Description: top-level template for Triton Security ACL Parmeters
 (XS_ACL_PARAM_T objects).
   Calls createACLParameter to generate anonymous PL/SQL block which calls
   apropriate Triton Security API (i.e., xs_data_security.create_acl_parameter)
   to create Triton ACL Parameters.
******************************************************************** -->
  <xsl:call-template name="DoParse">
   <xsl:with-param name="Verb">CREATE</xsl:with-param>
   <xsl:with-param name="ObjectType">XS_ACL_PARAM</xsl:with-param>
   <xsl:with-param name="NameNode" select="NAME"/>
  </xsl:call-template>
  <xsl:call-template name="createACLParameter">
   <xsl:with-param name="aclParamName" select="NAME"/>
  </xsl:call-template>
 </xsl:template>
 <xsl:template name="buildACElist">
  <xsl:param name="aceList" select="''"/>
  <!-- *******************************************************************
Template: buildACElist
Parameters:
 aceList  - ACE_LIST (containing items for each ace associated
       with ACL
******************************************************************** -->
  <xsl:text>&#xa; </xsl:text>
  <xsl:text>ace_list := XS$ACE_LIST(</xsl:text>
  <xsl:text>&#xa;</xsl:text>
  <xsl:for-each select="$aceList/ACE_LIST_ITEM">
   <xsl:text>   XS$ACE_TYPE(</xsl:text>
   <xsl:text>&#xa;     </xsl:text>
   <!-- Generate PRIVILEGE_LIST arg -->
   <xsl:text>privilege_list => </xsl:text>
   <xsl:call-template name="XSNameList">
    <xsl:with-param name="nameList" select="PRIV_LIST/PRIV_LIST_ITEM"/>
   </xsl:call-template>
   <!-- Generator GRANTED arg if appropriate (default = true) -->
   <xsl:if test="ACE_TYPE='0'">
    <xsl:text>,    &#xa;     granted => false</xsl:text>
   </xsl:if>
   <!-- Generate INVERT arg if appropriate (default=false)-->
   <xsl:if test="PRIN_INVERT='1'">
    <xsl:text>,   &#xa;     </xsl:text>
    <xsl:text>inverted=>true</xsl:text>
   </xsl:if>
   <!-- Generate Principal name if appropriate -->
   <xsl:if test="PRIN_NAME">
    <xsl:text>,   &#xa;     </xsl:text>
    <!-- Principal name -->
    <xsl:text>principal_name=></xsl:text>
    <xsl:call-template name="TSQuoteObject">
     <xsl:with-param name="Object" select="PRIN_NAME"/>
    </xsl:call-template>
   </xsl:if>
   <!-- Generate PRINCIPAL_TYPE arg:
              1 = PTYPE_XS (default)
              2 = PTYPE_DB
              3 = PTYPE_DN (not supported)
             -->
   <xsl:choose>
    <xsl:when test="PRIN_TYPE='2'">
     <xsl:text>,   &#xa;     principal_type=>XS_ACL.PTYPE_DB</xsl:text>
    </xsl:when>
    <xsl:when test="PRIN_TYPE='3'">
     <xsl:text>,   &#xa;     principal_type=>XS_ACL.PTYPE_DN</xsl:text>
    </xsl:when>
   </xsl:choose>
   <!-- Process START_DATE and END_DATE if present   -->
   <xsl:call-template name="XSDateArgs">
    <xsl:with-param name="startDate" select="START_DATE"/>
    <xsl:with-param name="endDate" select="END_DATE"/>
   </xsl:call-template>
   <!-- close out the current XS$ACE_TYPE arglist -->
   <xsl:text>)</xsl:text>
   <xsl:choose>
    <xsl:when test="position()=last()">);</xsl:when>
    <xsl:otherwise>,</xsl:otherwise>
   </xsl:choose>
   <xsl:text>&#xa;</xsl:text>
  </xsl:for-each>
 </xsl:template>
 <xsl:template name="callCreateACL">
  <xsl:param name="ACLobj" select="''"/>
  <!-- *******************************************************************
Template: callCreateACL
Parameters:
 aclName  - xs$obj node for ACL
******************************************************************** -->
  <xsl:if test="ACE_LIST/ACE_LIST_ITEM">
   <xsl:text>DECLARE&#xa; </xsl:text>
   <xsl:text>ace_list      XS$ACE_LIST;</xsl:text>
   <xsl:text>&#xa;</xsl:text>
  </xsl:if>
  <xsl:text>BEGIN</xsl:text>
  <xsl:if test="ACE_LIST/ACE_LIST_ITEM">
   <xsl:call-template name="buildACElist">
    <xsl:with-param name="aceList" select="ACE_LIST"/>
   </xsl:call-template>
  </xsl:if>
  <xsl:text>&#xa; </xsl:text>
  <xsl:text>xs_acl.create_acl(</xsl:text>
  <xsl:text>&#xa;     </xsl:text>
  <xsl:text>name=></xsl:text>
  <xsl:call-template name="TSQuoteObject">
   <xsl:with-param name="Schema" select="$ACLobj/OWNER_NAME"/>
   <xsl:with-param name="Object" select="$ACLobj/NAME"/>
  </xsl:call-template>
  <!-- generate ace_list arg if present -->
  <xsl:text>,&#xa;     ace_list=></xsl:text>
  <xsl:choose>
   <xsl:when test="ACE_LIST/ACE_LIST_ITEM">
    <xsl:text>ace_list</xsl:text>
   </xsl:when>
   <xsl:otherwise>
    <xsl:text>NULL</xsl:text>
   </xsl:otherwise>
  </xsl:choose>
  <!-- generate security_class arg if present -->
  <xsl:if test="SCLASS_NAME">
   <xsl:text>,&#xa;     </xsl:text>
   <xsl:text>sec_class=></xsl:text>
   <xsl:call-template name="TSQuoteObject">
    <xsl:with-param name="Schema" select="SCLASS_OWNER"/>
    <xsl:with-param name="Object" select="SCLASS_NAME"/>
   </xsl:call-template>
  </xsl:if>
  <!-- generate description arg if present -->
  <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>
  <!-- If there is a parent ACL then go ahead and set it -->
  <xsl:if test="PARENT_NAME">
   <xsl:text>,&#xa;     </xsl:text>
   <xsl:text>parent=> </xsl:text>
   <xsl:call-template name="TSQuoteObject">
    <xsl:with-param name="Schema" select="PARENT_OWNER"/>
    <xsl:with-param name="Object" select="PARENT_NAME"/>
   </xsl:call-template>
   <!-- Generate the PARENT ACL type  (REQUIRE if Parent present)-->
   <xsl:text>,   &#xa;     inherit_mode=></xsl:text>
   <xsl:choose>
    <xsl:when test="FLAG='1'">
     <xsl:text>XS_ACL.EXTENDED</xsl:text>
    </xsl:when>
    <xsl:when test="FLAG='2'">
     <xsl:text>XS_ACL.CONSTRAINED</xsl:text>
    </xsl:when>
    <xsl:when test="FLAG='3'">
     <xsl:text>XS_ACL.SYS_CONSTRAINED</xsl:text>
    </xsl:when>
   </xsl:choose>
  </xsl:if>
  <xsl:text>);</xsl:text>
  <xsl:text>&#xa;</xsl:text>
  <!-- Add ACL parameters if present -->
  <xsl:if test="PARAM_LIST/PARAM_LIST_ITEM">
   <xsl:call-template name="AddACLParams">
    <xsl:with-param name="ACLowner" select="OWNER_NAME"/>
    <xsl:with-param name="ACLname" select="NAME"/>
    <xsl:with-param name="paramList" select="PARAM_LIST/PARAM_LIST_ITEM"/>
   </xsl:call-template>
  </xsl:if>
  <!-- end the anonymous plsql block -->
  <xsl:text>END;</xsl:text>
  <xsl:if test="$SQLTERMINATOR=1">
   <xsl:text>&#xa;</xsl:text>
   <xsl:text>/</xsl:text>
  </xsl:if>
 </xsl:template>
 <xsl:template name="AddACLParams">
  <!-- *******************************************************************
Template: AddACLParams - loops thru all of the ACL parameters
   and generate calls to xs_acl.add_acl_parameter.
Parameters:
   ACLName - name of the current ACL
   paramList - <PARAM_LIST>
*******************************************************************-->
  <xsl:param name="ACLowner" select="''"/>
  <xsl:param name="ACLname" select="''"/>
  <xsl:param name="paramList" select="''"/>
  <xsl:text>&#xa;</xsl:text>
  <!-- loop thru and add each parameter. 
      Note: we order the parameters by name to allow for consistent
               test logs.
-->
  <xsl:for-each select="$paramList">
   <xsl:sort order="ascending" select="NAME"/>
   <xsl:text> xs_acl.add_acl_parameter(</xsl:text>
   <xsl:text>&#xa;     </xsl:text>
   <xsl:text>acl=></xsl:text>
   <xsl:call-template name="TSQuoteObject">
    <xsl:with-param name="Schema" select="$ACLowner"/>
    <xsl:with-param name="Object" select="$ACLname"/>
   </xsl:call-template>
   <xsl:text>, &#xa;     </xsl:text>
   <xsl:text>policy=></xsl:text>
   <xsl:call-template name="TSQuoteObject">
    <xsl:with-param name="Schema" select="POLICY_OWNER"/>
    <xsl:with-param name="Object" select="POLICY_NAME"/>
   </xsl:call-template>
   <xsl:text>, &#xa;     </xsl:text>
   <xsl:text>parameter=></xsl:text>
   <xsl:call-template name="SingleQuotedName">
    <xsl:with-param name="NameNode" select="NAME"/>
   </xsl:call-template>
   <xsl:text>, &#xa;     </xsl:text>
   <xsl:text>value=></xsl:text>
   <xsl:choose>
    <xsl:when test="TYPE='2'">
     <xsl:call-template name="SingleQuotedName">
      <xsl:with-param name="NameNode" select="PVALUE2"/>
     </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="PVALUE1"/>
    </xsl:otherwise>
   </xsl:choose>
   <xsl:text>);</xsl:text>
   <xsl:text>&#xa;</xsl:text>
  </xsl:for-each>
 </xsl:template>
 <xsl:template name="createACLParameter">
  <!-- *******************************************************************
Template:    createACLParameter - 
Description: generate call to xs_data_securityl.create_acl_parameter.
Parameters:
   aclParamName - name of the current ACL Parameter
*******************************************************************-->
  <xsl:param name="aclParamName" select="''"/>
  <xsl:text>&#xa;</xsl:text>
  <xsl:text>BEGIN</xsl:text>
  <xsl:text>&#xa; </xsl:text>
  <xsl:text>xs_data_security.create_acl_parameter(</xsl:text>
  <xsl:text>&#xa;     </xsl:text>
  <xsl:text>policy=></xsl:text>
  <xsl:call-template name="TSQuoteObject">
   <xsl:with-param name="Schema" select="POLICY_OWNER"/>
   <xsl:with-param name="Object" select="POLICY_NAME"/>
  </xsl:call-template>
  <xsl:text>,&#xa;     </xsl:text>
  <xsl:text>parameter=></xsl:text>
  <xsl:call-template name="SingleQuotedName">
   <xsl:with-param name="NameNode" select="NAME"/>
  </xsl:call-template>
  <xsl:text>,&#xa;     </xsl:text>
  <xsl:text>param_type=></xsl:text>
  <xsl:value-of select="TYPE"/>
  <!-- end the call to create_acl_parameter -->
  <xsl:text>);&#xa;</xsl:text>
  <!-- end the anonymous plsql block -->
  <xsl:text>END;</xsl:text>
  <xsl:if test="$SQLTERMINATOR=1">
   <xsl:text>&#xa;</xsl:text>
   <xsl:text>/</xsl:text>
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>

OHA YOOOO