1 procedure DBMS_FEATURE_RAS
2 ( feature_boolean OUT NUMBER,
3 aux_count OUT NUMBER,
4 feature_info OUT CLOB)
5 AS
6 row_count1 PLS_INTEGER;
7 row_count2 PLS_INTEGER;
8 policy_count PLS_INTEGER;
9 applied_policy_count PLS_INTEGER;
10 acl_count PLS_INTEGER;
11 ace_count PLS_INTEGER;
12 user_count PLS_INTEGER;
13 role_count PLS_INTEGER;
14 sc_count PLS_INTEGER;
15 privilege_count PLS_INTEGER;
16 session_count PLS_INTEGER;
17 external_session_count PLS_INTEGER;
18 regular_session_count PLS_INTEGER;
19 dispatcher_used VARCHAR2(5);
20 midtier_cache_used VARCHAR2(5);
21 max_seeded_id NUMBER := 2147493647;
22 begin
23 feature_boolean := 0;
24 feature_info := to_clob('Real Application Security usage not detected');
25 aux_count := 0;
26
27 begin
28
29 /* Check if Real Application Security objects are created. */
30 select count(*) into row_count1 from sys.xs$obj where id > max_seeded_id and BITAND(flags,1) = 0;
31 if row_count1 > 0 then
32 feature_boolean := 1;
33
34 /* Find the number of XDS policies. */
35 select count(*) into policy_count from sys.xs$dsec;
36
37 if policy_count > 0 then
38
39 /* Find the number of applied XDS policies. */
40 select count(*) into applied_policy_count from sys.DBA_XS_APPLIED_POLICIES p
41 where p.status = 'ENABLED';
42 end if;
43
44 /* Find the number of ACLs. */
45 select count(*) into acl_count from sys.xs$acl where acl# > max_seeded_id;
46
47 /* Find the number of ACEs. */
48 select count(*) into ace_count from sys.xs$ace where acl# > max_seeded_id;
49
50 /* Find the number of users. */
51 select count(*) into user_count from sys.xs$prin p where p.type = 0 and prin# > max_seeded_id;
52
53 /* Find the number of roles. */
54 select count(*) into role_count from sys.xs$prin p where p.type <> 0 and prin# > max_seeded_id;
55
56 /* Find number of security classes. */
57 select count(*) into sc_count from sys.xs$seccls where sc# > max_seeded_id;
58
59 /* Find number of privileges. */
60 select count(*) into privilege_count from sys.xs$priv where priv# > max_seeded_id;
61
62 /* Find the number of sessions. */
63 select count(*) into session_count from sys.rxs$sessions;
64
65 /* Find the number of session created with external user. */
66 select count(*) into external_session_count from sys.rxs$sessions r
67 where BITAND(r.flag,4) = 4;
68
69 /* Find the number of session created with regular XS user. */
70 regular_session_count := session_count - external_session_count;
71
72 /* Find if dispatcher is being used. */
73 select count(*) into row_count1 from sys.dba_xs_role_grants where granted_role = 'XSSESSIONADMIN';
74 select count(*) into row_count2 from sys.dba_role_privs where granted_role = 'XS_SESSION_ADMIN' and grantee <> 'SYS';
75 if ((row_count1 > 0) OR (row_count2 > 0)) then
76 dispatcher_used := 'TRUE';
77 else
78 dispatcher_used := 'FALSE';
79 end if;
80
81 /* Find if midtier cache is used. */
82 select count(*) into row_count1 from sys.dba_xs_role_grants where granted_role = 'XSCACHEADMIN';
83 select count(*) into row_count2 from sys.dba_role_privs where granted_role = 'XS_CACHE_ADMIN' and grantee <> 'SYS';
84 if ((row_count2 > 0) OR (row_count2 > 0)) then
85 midtier_cache_used := 'TRUE';
86 else
87 midtier_cache_used := 'FALSE';
88 end if;
89
90 feature_info := to_clob('Number of policies: '||policy_count||
91 ' Number of policies applied: '||applied_policy_count||
92 ' Number of ACLs created: '||acl_count||
93 ' Number of ACEs: '||ace_count||
94 ' Number of users created: '||user_count||
95 ' Number of roles created: '||role_count||
96 ' Number of security classes created: '||sc_count||
97 ' Number of privileges created: '||privilege_count||
98 ' Number of sessions created: '||session_count||
99 ' Number of external sessions created: '||external_session_count||
100 ' Number of regular sessions created: '||regular_session_count||
101 ' Dispatcher used: '||dispatcher_used||
102 ' Mid-tier cache used: '||midtier_cache_used);
103 end if;
104 exception
105 when others then
106 null;
107 end;
108 END DBMS_FEATURE_RAS;