D90836GC10 Ag1 PDF
D90836GC10 Ag1 PDF
D90836GC10 Ag1 PDF
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
ht Oracle ns e
r ap a s li c e Database Security:
m ur P Preventive Controls
Fla
publish, license, post, transmit, or distribute this document in whole or in part without
the express authorization of Oracle.
Editors
The information contained in this document is subject to change without notice. If you
Aishwarya Menon find any problems in the document, please report them in writing to: Oracle University,
Smita Kommini 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
warranted to be error-free.
Vijayalakshmi Narasimhan
Restricted Rights Notice
Graphic Designer
Rajiv Chandrabhanu
If this documentation is delivered to the United States Government or anyone using
the documentation on behalf of the United States Government, the following notice is
a ble
applicable:
f e r
an s
Publishers U.S. GOVERNMENT RIGHTS
n - t r
The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or
o
an
Pavithran Adka disclose these training materials are restricted by the terms of the applicable Oracle
license agreement and/or the applicable U.S. Government contract.
Giri Venugopal
ha s
Trademark Notice )
m ideฺ
c o
ailฺ t Gu
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners.
m
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
P ra
u r
m
Fla
Table of Contents
a ble
Practice 2-5: Restricting Database Links With Views ................................................................................ 2-35
f e r
Practice 2-6: Configuring the External Secure Password Store ................................................................. 2-38
an s
Practice 2-7: Connecting to a CDB or a PDB............................................................................................ 2-46
n - t r
no
Practice 2-8: Preparation for Next Lesson ................................................................................................ 2-50
s a
Practices for Lesson 3: Using Enterprise User Security.......................................................................... 3-1
h a
Practices for Lesson 3: Overview............................................................................................................. 3-2
) eฺ
o m
Practice 3-1: Registering a Database with Enterprise Manager ................................................................. 3-3
ilฺc Guid
Practice 3-2: Starting and Configuring Oracle Unified Directory................................................................ 3-10
a
g m ent
Practice 3-3: Configuring and Registering the Database ........................................................................... 3-20
t i c a@ Stud
Practice 3-4: Configuring Global Users and Global Roles ......................................................................... 3-28
a s h this
Practice 3-5: Configuring Enterprise User Security by Using Enterprise Manager ...................................... 3-30
ap and
Practice 3-6: Cleaning Up........................................................................................................................ 3-43
Practices for Lesson 4: Usingp r u s e
Practices for Lesson 4:a
( f Privileges
to
Roles ................................................................................ 4-1
t i c s e
Overview.............................................................................................................
h ProxycAuthentication
4-2
Practicep a sExploring
Practice 4-1: Using
l i en ................................................................................................. 4-3
u r Practice
@ g d
Practices for Lesson 12: Overview ........................................................................................................... 12-2
a t u
tTrailc ...................................................................................
Practice 12-1: Key Vault Administration Videosi........................................................................................
S 12-3
Practice 12-2: Using and Managing the Audit
a s h t h i s 12-4
Practice 12-3: Backing Up the Key
r a usp
Vault e
.................................................................................................. 12-9
f p
Practice 12-4: Cleaning Up(......................................................................................................................
to 12-14
i c a e
a s ht 13: cUsing
Practices for Lesson
e s
nApplication Data Model .......................................................................... 13-1
Practices for
a i
p13-1: Adding lData
Lesson 13: Using an Application Data Model ....................................................................... 13-2
r
P 13-2: Registering a Database with Enterprise Manager ............................................................... 13-12
Practice to the orcl Instance ........................................................................................ 13-3
u r Practice
m
Fla Practice 13-3: Capturing the Application Data Model ................................................................................ 13-18
Practices for Lesson 14: Data Masking Formats...................................................................................... 14-1
Practices for Lesson 14: Overview ........................................................................................................... 14-2
Practice 14-1: Reviewing Data Masking Formats...................................................................................... 14-3
Practice 14-2: Check Your Knowledge ..................................................................................................... 14-11
Practices for Lesson 15: Implementing Data Masking ............................................................................. 15-1
Practices for Lesson 15: Overview ........................................................................................................... 15-2
Practice 15-1: Create a New Data Masking Definition............................................................................... 15-3
Practices for Lesson 16: Data Subsetting ................................................................................................ 16-1
Practices for Lesson 16: Overview ........................................................................................................... 16-2
Practice 16-1: Using a Data Subsetting Definition..................................................................................... 16-3
Practices for Lesson 17: Data Masking Administratoin ........................................................................... 17-1
Practices for Lesson 17: Data Masking Administration.............................................................................. 17-2
Practice 17-1: Performing Data Masking and Subsetting Exports .............................................................. 17-3
Practice 17-2: Clean up the Environment ................................................................................................. 17-7
a no
Practices for Lesson 21: Database Vault Administrators ........................................................................ 21-1
a s
Practices for Lesson 21: Database Vault Administrators ........................................................................... 21-2
h
) eฺ
Practice 21-1: Configuring Database Vault for the Container DB ............................................................... 21-4
m
o
ilฺc Guid
Practice 21-2: Configuring Database Vault for the PDB ............................................................................ 21-7
m ent a
Practice 21-3: Setting Up Practice Accounts ............................................................................................ 21-12
g
Practice 21-4: Configuring Database Vault User in Cloud Control 13c ....................................................... 21-16
t i c a@ Stud
Practices for Lesson 22: Privilege Analysis............................................................................................. 22-1
s h th i s
a by AnyeUser..............................................................................
Practices for Lesson 22: Overview ........................................................................................................... 22-2
r a
Practice 22-1: Analyzing Privileges p
Used
s 22-3
f p u
( PrivilegetoUse in Context ............................................................................ 22-10
Practice 22-2: Analyzing ANY
i c a
t ense Privileges ....................................................................................... 22-13
Practice 22-3: Analyzing Role-Based
Practices fora s h
r a pforLesson licUsing Realms ................................................................................................... 23-1
23:
m
Fla Practice 23-2: Using Realms to Protect Roles .......................................................................................... 23-12
Practice 23-3: Using Regular and Mandatory Realms............................................................................... 23-20
Practices for Lesson 24: Managing Rule Sets.......................................................................................... 24-1
Practices for Lesson 24: Overview ........................................................................................................... 24-2
Practice 24-1: Managing Rule Sets .......................................................................................................... 24-3
Practices for Lesson 25: Command Rules ............................................................................................... 25-1
Practices for Lesson 25: Overview ........................................................................................................... 25-2
Practice 25-1: Using Command Rules ..................................................................................................... 25-3
Practice 25-2: Protecting Application Data ............................................................................................... 25-7
Practices for Lesson 26: Factors and Identities....................................................................................... 26-1
Practices for Lesson 26: Overview ........................................................................................................... 26-2
Practice 26-1: Restricting Access by Using the Client_IP and Domain Factors .......................................... 26-3
Practice 26-2: Creating a Factor to Determine Job Role ........................................................................... 26-14
Practice 26-3: Using Assignment Rule Sets with Factors .......................................................................... 26-18
Practice 26-4: Using Rule Sets to Restrict Connection Sources ................................................................ 26-22
Practice 26-5: Using a Factor to Identify a User........................................................................................ 26-26
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Username Password
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Linux
root oracle
oracle oracle
auditvault auditpass
fred oracle
*** wallet welcome1
a ble
f e r
ans
Oracle
n - t r
o
ann A_xxx12345667890_Yyy
s an
avdfuser avdfpass
) ha
c o m ideฺ
ailฺ t Gu
bi oracle_4U
c##sec oracle_4sec m
g den
@
dba_junior oracle_4U
h t ica is Stu
dbsnmp
p a
oracle_4U s th
r a
poracle_4U us e
dev ( f t o
hr h t ica noracle_4U
se
pa s e
lic oracle_4U
ix r a
u rP
jim oracle_4U
m
Fla oe oracle_4U
pfay oracle_4U
pm oracle_4U
scott oracle_4U
sec oracle_4sec
sys oracle_4U
system oracle_4U
tom oracle_4U
avadmin1_sa oracle_4U
avadmin2_a oracle_4U
avauditor oracle_4U
avaudit1_sa oracle_4U
avaudit2_a oracle_4U
Repository Encryption oracle_4U
a ble
f e r
root oracle_4U
ans
support oracle_4U
n - t r
o
s an
Oracle Database Firewall
) ha
c o m ideฺ
Installation Passphrase oracle_4U
a ilฺ Gu
fwadmin oracle_4U g m e n t
root oracle_4U
t i c a@ Stud
a s h this
support
f p r ap use
oracle_4U
sysman
a ( oracle_4U
to
i c
ht cens e
a s
p Oracle li Key Vault
r a
u r P Passphrase My passcode is No 1.
Installation
m
Fla Recovery Passphrase oracle_4U
OKV_SYS_SEAN oracle_4U
OKV_KEYS_KATE oracle_4U
OKV_AUD_AUDREY oracle_4U
Repository Encryption oracle_4U
root oracle_4U
support oracle_4U
a ble
f e r
ans
n - t r
a no
h a s
Practices for m ) Lesson
e ฺ 1:
o id
ilฺc GuFamiliarization
Environment
a
g m ent
c a @ tu1 d
Chapter
i
ht this S
a s
f p r ap use
a ( to
i c
ht cens e
a s li
rap
mur P
Fla
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
a
In these practices, you will familiarize s hyourselfthwith
is the computing environment used in this
course and perform setupp
f r ap use
tasks:
• Starting and a (
verifyingethetovirtual machines are started.
i c
htdowncethenvirtual
s machines.
p a s
• Shutting
li
a
Note:rThroughout these practices, Courier New bold is used to indicate command(s) that
u r Penter. For example, the following indicates that you are to enter the date command:
you
m
Fla $ date
Mon Jun 16 00:20:46 UTC 2014
$
Scripts specific to this lesson have been provided in directory /home/oracle/labs/.
Overview
In this practice, you familiarize yourself with the computing environment used in this course.
You make note of some important information that you will need when you perform the practices
for this course. Fill in the Course Overview table as you gather the information.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Assumptions
You have a course setup on Linux based Virtual Machines:
• cl1: a client machine
• db1: a database machine
• em13: an Oracle Enterprise Manager machine
• okv: an Oracle Key Vault machine
a ble
• oav: an Oracle Audit Vault machine f e r
ans
• odf: an Oracle Database Firewall machine
n - t r
The VMs contain the following:
a no
• Client software and the GlassFish application server are installedson cl1.
) hadatabase with two
• There are three databases installed on db1: dbsec (a container
o d e ฺ
m idatabase),
pluggable databases pdb1 and pdb2), orcl (a non-container c
ilฺDNS and ua network timeandprotocol
fix1 (a
non-container database). Also, db1 operates a
m ent
as a G
g
server.
• Enterprise Manager Cloud Control t i c a@ Stusing
is installed
ud a non-container database em13rep.
a sh Firewall
If Oracle Audit Vault and OraclepDatabase t h is labs are to be performed, oav and odf VMs
are installed. f p r a use
• The Oracleic a ( Vault appliance
to is installed on oav. You will configure this appliance
Audit
hoftthe course e
nspractices.
p a s
as part
li c e
• raThe Oracle Database Firewall appliance is installed on odf. You will configure this
u r P appliance as part of the course practices.
m
Fla If Oracle Key Vault labs are to be performed, the okv VM is available.
• The Oracle Key Vault appliance is installed on okv. You will configure this appliance as
part of the course practices.
Tasks
1. Log in to your assigned machine and open a terminal window: Right-click and select Open
in Terminal.
2. Check your system date and time. Note it, especially if it is different from your own time
zone.
$ date
Mon Jun 16 00:20:46 UTC 2014
$
3. Start the db1 virtual machine.
$ sudo xm list db1
Error: Domain 'db1' does not exist.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
p syou sure
l i c e you want to continue connecting (yes/no)? yes
db:1d:04:46:f0:c9:36:44:bf:39:0d:58:f1:9a:00:a4.
a
P ra Warning: Permanently added 'cl1,192.0.2.103' (RSA) to the list
Are
r
mu
Fla
of known hosts.
root@cl1's password:
Last login: Wed Dec 7 03:50:09 2016 from 192.0.2.1
b. Shut down the machine to return to the host.
[root@cl1 ~]# shutdown -P now
Broadcast message from [email protected]
(/dev/pts/0) at 18:00 ...
a ble
f e r
ans
n - t r
a no
h a s
Practices for m ) Lesson
e ฺ 2:
o id
a ilฺc GuBasic
Implementing and
m n t
g dAuthentication
Strong e
@ tu2
h t ica Chapter
s S
p a s
e t hi
( f pra to us
h t ica nse
p a s lice
ra
mur P
Fla
Practices Overview
In these practices, you implement basic password and OS authentication, secure passwords,
restrict database links, and manage authentication of common and local users in CDBs and
PDBs.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Assumptions
This lesson is performed on the db1 virtual machine using both the orcl instance and the
dbsec instance. Review the lesson titled “Introduction” if you need assistance in starting the
virtual machine.
Unless otherwise indicated, you log in as operating system user oracle.
a ble
Ensure the listener, non-CDB orcl instance, CDB dbsec instance, and pdbsec pluggable
f e r
database are started and available. You may use the courtesy scripts found in
ans
/home/oracle/bin, such as start_listener.sh, start_orcl.sh, and
n - t r
start_dbsec.sh to start the listener and instances.
a no
a s and
If you need to restart the lesson, you may reset using the preset_orcl.sql
h
preset_dbsec.sql scripts that are in the $HOME/labs/USERS )directory.
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
P ra
r
mu
Fla
Overview
In this practice, you create the security officer account that has privileges to create user
accounts, grant privileges, and administer fine-grained auditing and fine-grained access control
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a. Use the oraenv utility to set the ORACLE_SID environment variable to the orcl value.
The response message may not be identical. However if you are prompted for the
ORACLE_HOME, the requested system identifier is not known, and you should review
your step. The oraenv utility sets the ORACLE_SID, ORACLE_HOME and PATH in the
current terminal window and shell. If you close the terminal window, you should re-run
this step or use your own preferred method to set these environment variables. Also
reinitialize the database to introduce security deficiencies to be found.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base … /u01/app/oracle
$ labs/USERS/preset_orcl.sh >> /dev/null 2>&1
$
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
a ble
With the Partitioning, Oracle Label Security, OLAP, Advanced f e r
Analytics and Real Application Testing options ans
n - t r
o
SQL> DROP USER sec CASCADE;
s an
DROP USER sec CASCADE
) ha
*
c o m ideฺ
ERROR at line 1:
m ailฺ t Gu
ORA-01918: user 'SEC' does not exist
@ g den
h t ica is Stu
p a s th BY oracle_4sec
SQL> CREATE USER r a
pTABLESPACE
sec e
us USERS
IDENTIFIED
( f t o
t ica UNLIMITED
2 DEFAULT
3 hQUOTA n se ON USERS;
s e
rapa lic
mur P User created.
Fla SQL>
SQL> GRANT create session
2 TO sec
3 WITH ADMIN OPTION;
Grant succeeded.
SQL>
SQL> GRANT select_catalog_role, select any table,
2 create any context, drop any context,
3 create user, alter user, drop user,
4 create role, alter any role, drop any role,
5 create table, create procedure,
6 create any trigger, administer database trigger,
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Grant succeeded.
SQL>
SQL> GRANT execute on DBMS_SESSION to sec;
Grant succeeded.
a ble
f e r
SQL> GRANT execute on UTL_FILE to sec;
ans
n - t r
Grant succeeded.
a no
h a s
SQL>
m ) eฺ
o uid Edition Release
SQL> EXIT
a ilฺcEnterprise
G
Disconnected from Oracle Database
g m ent
12c
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
SQL> ALTER USER PM PASSWORD EXPIRE ACCOUNT LOCK;
User altered.
User altered.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
SQL>
3. Because it is dangerous to work with the UTL_FILE_DIR parameter set to *, you reset the
UTL_FILE_DIR parameter to NULL, so that no one can read from or write to any directory
using the UTL_FILE package. Then you configure the database so that users can write to
the /home/oracle/student directory:
a. Reset the UTL_FILE_DIR parameter to NULL.
a ble
SQL> ALTER SYSTEM SET utl_file_dir='' SCOPE=spfile;
f e r
ans
System altered.
n - t r
n o
s a
SQL> CONNECT / AS SYSDBA
) ha
Connected.
c o m ideฺ
SQL> SHUTDOWN IMMEDIATE
m ailฺ t Gu
Database closed.
@ g den
tica is Stu
Database dismounted.
ORACLE instance shutsh down.
a p a e th
pr started.
us
SQL> STARTUP
ORACLE instance ( f t o
h t ica nse
p a s System
Total l i c e Global Area 501059584 bytes
ra
ur P
Fixed Size 2290024 bytes
m
Fla
Variable Size 264244888 bytes
Database Buffers 226492416 bytes
Redo Buffers 8032256 bytes
Database mounted.
Database opened.
SQL>
b. Configure the database to allow writes using the DIRECTORY objects. Create the
/home/oracle/student directory on the OS. Create a directory object for the
/home/oracle/student directory. You can later grant READ or WRITE privileges
to the directory to certain users.
SQL> !mkdir /home/oracle/student
Directory created.
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
c. Test the configuration. The following PL/SQL block writes the current database time
to the db_time.lst file. The PL/SQL block accepts a single parameter: the
uppercase name of the directory object that you want to write to (STUDENT).
SQL> DECLARE
file_handle UTL_FILE.FILE_TYPE;
file_mode VARCHAR2(1) := 'w';
file_name VARCHAR2(15) := 'db_time.lst';
a ble
file_location VARCHAR2(80) := '&1';
f e r
file_data VARCHAR2(100);
ans
BEGIN
n - t r
o
an
file_handle := utl_file.fopen(file_location, file_name,
s
ha
file_mode);
IF utl_file.is_open(file_handle) THEN )
m ideฺ
c o
ailฺ t Gu
file_data := current_timestamp;
m
g den
utl_file.put(file_handle, file_data);
@
ica is Stu
utl_file.fclose(file_handle);
ELSE
s h t
a p a e th
dbms_output.put_line('The file was not opened.');
END IF;( f pr to us
t
END;
h ica nse
p a
/ s lice
ra
ur P
2 3 4 5 6 7 8 9 10 11 12 13 14
15 16 17 Enter value for 1: /home/oracle
m
Fla old 5: file_location VARCHAR2(80) := '&1';
new 5: file_location VARCHAR2(80) := '/home/oracle';
DECLARE
*
ERROR at line 1:
ORA-29280: invalid directory path
ORA-06512: at "SYS.UTL_FILE", line 41
ORA-06512: at "SYS.UTL_FILE", line 478
ORA-06512: at line 8
SQL>
ha s
dbms_output.put_line('The file was not opened.');
END IF; )
m ideฺ
c o
ailฺ t Gu
END;
/ m
g den
@
ica is Stu
Enter value for 1: STUDENT
old 5:
s h t
file_location VARCHAR2(80) := '&1';
new 5:
a p a e
file_locationth VARCHAR2(80) := 'STUDENT';
( f pr to us
ca nse successfully completed.
PL/SQLtiprocedure
h
p a s lice
ra
ur P
SQL>
m d. Verify that the db_time.lst file is written to the directory after executing the
Fla PL/SQL block.
SQL> HOST cat /home/oracle/student/db_time.lst
05-JUL-13 10.01.49.700632000 AM +00:00
SQL>
4. Do any users in your database have the DBA role, SYSOPER, SYSDBA, SYSKM, SYSDG, or
SYSBACKUP privilege that they do not need? Fix this problem.
a. Find users who are granted the DBA role by querying the DBA_ROLE_PRIVS
view.
SQL> COL grantee FORMAT a12
SQL> COL granted_role FORMAT a12
SQL> SELECT * FROM dba_role_privs WHERE granted_role='DBA';
been locked and the password expired. Revoke the DBA role from SCOTT. To
revoke a role, you must have been granted the role with ADMIN OPTION. You
can revoke any role if you have the GRANT ANY ROLE system privilege.
SQL> REVOKE DBA FROM scott;
Revoke succeeded.
a ble
SQL> SELECT * FROM dba_role_privs WHERE granted_role='DBA';
f e r
ans
GRANTEE GRANTED_ROLE ADM DEL DEF COM
n - t r
------------ ------------ --- --- ---
a no---
SYSTEM DBA NO NO
h a s
YES YES
SYS DBA YES NO
m ) eฺYES YES
o
a ilฺc Guid
SQL>
g m ent
c. Users with the SYSDBA or c
t i a@ Sprivilege
SYSOPER tud are listed in the oracle password
file. SCOTT and HR have
a s h no need
t h isfor these privileges. Only SYSDBA can GRANT
or REVOKE these
f p r ap use
privileges.
(
SQL> COL username
a toFORMAT a12
i c e
t e*nsFROM v$pwfile_users;
SQL> hSELECT
a s
rapUSERNAME lic SYSDB SYSOP SYSAS SYSBA SYSDG SYSKM
ur P
CON_ID
------------ ----- ----- ----- ----- ----- ----- ----------
m
Fla SYS TRUE TRUE FALSE FALSE FALSE FALSE 0
SYSDG FALSE FALSE FALSE FALSE TRUE FALSE 0
SYSBACKUP FALSE FALSE FALSE TRUE FALSE FALSE 0
SYSKM FALSE FALSE FALSE FALSE FALSE TRUE 0
SCOTT TRUE FALSE FALSE FALSE FALSE FALSE 0
HR FALSE TRUE FALSE FALSE FALSE FALSE 0
6 rows selected.
Revoke succeeded.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Revoke succeeded.
SQL>
SQL> SELECT * FROM v$pwfile_users;
a ble
f e r
USERNAME SYSDB SYSOP SYSAS SYSBA SYSDG SYSKM CON_ID
ans
------------ ----- ----- ----- ----- -----
n -
----- ---------t r
SYS TRUE TRUE FALSE FALSE
a no FALSE FALSE 0
SYSDG FALSE FALSE FALSE
h a s
FALSE TRUE FALSE 0
SYSBACKUP FALSE FALSE FALSE m ) eฺ TRUE FALSE FALSE 0
o
SYSKM FALSE FALSE
a ilฺc Guid
FALSE FALSE FALSE TRUE 0
g m ent
SQL>
t i c a@ Stud
s
5. Do any users in your database have
a h the tRESOURCE
h is role? If there are some users being
granted the RESOURCE role,
f p r apcheckuthat
s e the UNLIMITED TABLESPACE system privilege is
a (
not granted. In Oracle Database
t o 12c, the RESOURCE role is not granted the UNLIMITED
c nprivilege
TABLESPACEtisystem
h se anymore.
s
a. a As SEC,
p UNLIMITED e
liccheckTABLESPACE
which users have the combination of the RESOURCE role and the
P r a system privilege.
r
mu SQL> CONNECT sec
Fla Enter password: *******
Connected.
SQL> column grantee format a20
SQL> SELECT grantee, privilege, granted_role
FROM dba_sys_privs JOIN dba_role_privs USING (grantee)
WHERE granted_role='RESOURCE'
AND privilege = 'UNLIMITED TABLESPACE'
ORDER BY grantee;
SQL>
Revoke succeeded.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
SQL> EXIT
$
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Tasks
1. Determine what limits are applied with the DEFAULT profile. Then, set up password
management by performing the following steps:
a. Preset the default profile to a known set of limits and list the rows related to
password management from the current profiles in the system. Use the SEC account.
Save the command that you use.
$ sqlplus sec
a ble
Enter password: ****** f e r
ans
n - t r
Connected to: o
an
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
s
64bit Production
) ha
o m ideฺ
With the Partitioning, Oracle Label Security, OLAP, Advanced
c
ailฺ t Gu
Analytics and Real Application Testing options
m
SQL> ALTER PROFILE DEFAULT LIMIT
@ g den
PASSWORD_LIFE_TIME 180
h t ica is Stu
PASSWORD_GRACE_TIME 7
p a s th
a
pr to us
PASSWORD_REUSE_TIME UNLIMITED e
( f
PASSWORD_REUSE_MAX UNLIMITED
h t ica nse
FAILED_LOGIN_ATTEMPTS 10
p a s lice
PASSWORD_LOCK_TIME 1
ra
ur P
;
m
Fla
2 3 4 5 6 7 8
Profile altered.
DEFAULT PASSWORD_GRACE_TIME 7
7 rows selected.
ap use
onwards
Rem
( f p r
c a e o the minimum complexity checks like
tmakes
i
ht minimum
Rem This
ns length of the password, password not same as the
function
Remsthe e
a li
apRem username,c
r etc. The user may enhance this function according
ur P to
(username varchar2,
password varchar2,
old_password varchar2)
RETURN boolean IS
differ integer;
…
Rem Function: "verify_function_11G" - provided from 11G onwards.
Rem a ble
f e r
Rem This function makes the minimum complexity checks like
ans
Rem the minimum length of the password, password not same as the
n - t r
no
Rem username, etc. The user may enhance this function according
a
to
h a s
Rem the need.
m ) eฺ
o
a ilฺc Guid
m ent
CREATE OR REPLACE FUNCTION verify_function_11G
g
(username varchar2,
t i c a@ Stud
password varchar2,
a s h this
ap use
old_password varchar2)
… f p r
( alters
a
-- Thisicscript e to the default parameters for Password
s ht cens
Management
a
r li
ap-- This means that all the users on the system have Password
mur P Management
Fla
-- enabled and set to the following values unless another
profile is
-- created with parameter values set to different value or
UNLIMITED
-- is created and assigned to the user.
F lam $
c. Using SQL*Plus, connect to the database AS SYSDBA and verify that the three
password verification functions are not created yet.
$ sqlplus / AS SYSDBA
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced
Analytics and Real Application Testing options
SQL> SET ECHO ON
SQL> SELECT object_name, object_type
FROM dba_objects
WHERE object_name LIKE '%VERIFY_FUNCTION%';
2 3
ORA12C_STRONG_VERIFY_FUNCTION
FUNCTION
t i
h cen c
p a s li functions.
r a
d. Create the
u rP
m SQL> @$ORACLE_HOME/rdbms/admin/utlpwdmg.sql
Fla
Function created.
Function created.
Function created.
Grant succeeded.
Function created.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Function created.
Grant succeeded.
Function created.
a ble
f e r
ans
Grant succeeded.
n - t r
o
s an
) ha
Profile altered.
c o m ideฺ
ailฺ t Gu
The output has been modified to show only the results.
m
@ g den
t i a Saretucreated.
e. Verify that the password verifycfunctions
h
SQL> col OBJECT_NAMEs formathA38
a t is
SQL> col OBJECT_TYPE
f p r ap uformat
s e A20
SQL> SELECT a ( object_name,
to object_type
t i c s e
p a shFROM l i c n
eobject_name
dba_objects
SQL>
SQL>
g. View the changes applied. Repeat the command from step 2a as the SEC user and
note the differences.
SQL> CONNECT SEC
Enter password: ******
Connected.
a ble
SQL> COL profile format A7
f e r
SQL> COL resource_name format A32
ans
SQL> COL limit format A30 n - t r
SQL> SELECT profile, resource_name, limit a no
FROM dba_profiles
h a s
m ) eฺ
WHERE PROFILE = 'DEFAULT'
o
a
AND resource_type = 'PASSWORD'; ilฺc Guid
g m ent
PROFILE RESOURCE_NAME ca@ d
tuLIMIT
t i S
h this -----------------------
a s
------- ------------------------
f p r ap use
DEFAULT FAILED_LOGIN_ATTEMPTS 10
(
a se t o
DEFAULT PASSWORD_LIFE_TIME 180
t i
h cenc
a s
DEFAULT PASSWORD_REUSE_TIME
li
UNLIMITED
Fla
DEFAULT PASSWORD_LOCK_TIME 1
DEFAULT PASSWORD_GRACE_TIME 7
7 rows selected.
SQL>
h. Create a user and verify that the password is secure with the verify function applied
in the profile.
SQL> CREATE USER ann IDENTIFIED BY xxx12345;
CREATE USER ann IDENTIFIED BY xxx12345
*
ERROR at line 1:
ORA-28003: password verification for the specified password
failed
ORA-20001: Password length less than 9
Grant succeeded.
a ble
SQL> ALTER USER tom IDENTIFIED BY Strong_pass_65W;
f e r
ans
n - t r
no
User altered.
s a
h a
m) ifunction
SQL>
o
Notice that TOM falls under the rules of the passwordcchecking d e ฺ defined in the
DEFAULT profile even if being granted the SYSDBA
m ailฺprivilege.
t G u
@ g den
4. t ica toisNULL
Set the password verification function S tinu the DEFAULT profile. In a production
environment, the password a s h hfunction should be set to a password verification
tuse
verification
a p e
remembrance. (f
pr to us
function in the DEFAULT profile. You simple passwords in the course for ease of
t ica n/sAS
SQL> hCONNECT
e SYSDBA
a s
pConnected. lic e
r a
u r P SQL> ALTER PASSWORD_LIFE_TIME
PROFILE default LIMIT
m unlimited
Fla FAILED_LOGIN_ATTEMPTS unlimited
PASSWORD_VERIFY_FUNCTION null;
2 3 4
Profile altered.
SQL>
5. Reset the password of TOM to its initial value and revoke the SYSDBA.
SQL> ALTER USER tom IDENTIFIED BY oracle_4U;
User altered.
Revoke succeeded.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
− In pdb1: A lifetime period set to 1 minute (for the purpose of this practice) and no
password verify function
− In pdb2: Account locked after 2 failed login attempts only and the password verify
function set to ora12c_strong_verify_function
a. Set ORACLE_SID and ORACLE_HOME to point to the CDB instance.
$ . oraenv
ORACLE_SID = [orcl] ? dbsec
a ble
The Oracle base … /u01/app/oracle
f e r
$ sqlplus / as sysdba
ans
n - t r
Connected to:
a no
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
h a s
64bit Production
m ) eฺ
o
ilฺc Guid
With the Partitioning, OLAP, Advanced Analytics and Real
a
Application Testing options
g m ent
SQL>
t i c a@ Stud
b. Check whether the PDBs
a s h aretopened.
h isall each
If one, or both, are not opened
(MOUNTED), you
r a p one
can open
s e them time the instance is restarted. The
( f p to u
following demonstrates PDB open and one mounted.
t ica name,
SQL> select
h n s e open_mode from v$pdbs;
p a s lice
ra NAME
ur P
OPEN_MODE
------------------------------ ----------
m
Fla PDB$SEED READ ONLY
PDB1 READ WRITE
PDB2 MOUNTED
You can open all PDBs by using the alter command, or create a trigger to open all
when the instance is started. Do this only if needed.
Discuss the security advantages and disadvantages of using a trigger.
SQL> alter pluggable database all open;
Trigger created.
SQL>
7. Alter the DEFAULT profile in the PDBs and verify the profile in the root container.
a. Connect to pdb1 as SYSTEM to alter the DEFAULT profile.
SQL> CONNECT system@pdb1
Enter password: ******
a ble
Connected.
f e r
ans
SQL> ALTER PROFILE default LIMIT
PASSWORD_LIFE_TIME 1/1440 n - t r
PASSWORD_VERIFY_FUNCTION null; a no
2 3
h a s
m ) eฺ
Profile altered.
o
a ilฺc Guid
SQL> COL profile format A7 g m ent
SQL> COL resource_name format
t i c a@ A32
S tud
SQL> COL limit format
a s hA30 this
r ap use
SQL> @$HOME/labs/default_profile.sql
f p
a ( t o
i c
ht RESOURCE_NAME
PROFILE
ns e LIMIT
a s li c e
rap
------- ----------------------------- -----------------------
ur P
DEFAULT FAILED_LOGIN_ATTEMPTS UNLIMITED
m DEFAULT PASSWORD_LIFE_TIME .0006
Fla DEFAULT PASSWORD_REUSE_TIME UNLIMITED
DEFAULT PASSWORD_REUSE_MAX UNLIMITED
DEFAULT PASSWORD_VERIFY_FUNCTION NULL
DEFAULT PASSWORD_LOCK_TIME 1
DEFAULT PASSWORD_GRACE_TIME 7
7 rows selected.
SQL>
PASSWORD_VERIFY_FUNCTION ora12c_strong_verify_function;
a ble
SQL> CONNECT sys@pdb2 AS SYSDBA
f e r
Enter password: ******
ans
Connected.
n - t r
o
SQL> @$ORACLE_HOME/rdbms/admin/utlpwdmg.sql
s an
) ha
Function created.
c o m ideฺ
m ailฺ t Gu
@ g den
Function created.
h t ica is Stu
p a s th
a
pr to us e
( f
ica nse
Function created.
h t
s lice
a p a
r
ur P
Grant succeeded.
m
Fla
Function created.
Grant succeeded.
Function created.
Grant succeeded.
Function created.
Profile altered.
p a sh PASSWORD_LOCK_TIME
DEFAULT
l i c en 1
ra DEFAULT PASSWORD_GRACE_TIME 7
mur P
Fla 7 rows selected.
SQL>
CON_NAME
------------------------------
CDB$ROOT
SQL> @$HOME/labs/default_profile.sql
h t ica is Stu
7 rows selected. as th
a p e
( f pr to us
icthea rootncontainer
SQL>
h t
Notice that
s e se has its own DEFAULT profile.
rapa lic
mur P
Fla
PASSWORD_VERIFY_FUNCTION null;
2 3 4
Profile altered.
c a se t
PASSWORD_LIFE_TIME o unlimited
t i
p a sh PASSWORD_VERIFY_FUNCTION
l i c e n null;
ra 2 3 4
ur P Profile altered.
F lam
SQL> EXIT
$
Overview
In this practice, in a first step, you explore basic authentication techniques for implementing a
no-password login and the weaknesses of this method.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Assumptions
In your company, there are several situations that require exceptions to the standard password
policies. Batch jobs should not have passwords embedded in the script or command line. This
practice uses the orcl instance. Code may be found in the $HOME/labs/USERS directory.
Tasks
1. A batch job that runs as the fred operating system user should be able to connect to the
database as the FRED database user without having to embed the database password in
a ble
the batch file. f e r
ans
Configure OS_AUTHENT_PREFIX to allow the OS user and database user to have the
n - t r
a no
same string. What is the default value of OS_AUTHENT_PREFIX? Is it a static parameter?
Connect to the database as the SYS user. Set the OS_AUTHENT_PREFIX parameter to ''.”
h a s
$ . oraenv
m ) eฺ
o
ORACLE_SID = [orcl] ? orcl
a ilฺc Guid
The Oracle base for
g m ent
a @ t u d
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is
/u01/app/oracle
s h tic is S
$ sqlplus / as sysdba
a p a e th
Connectedato: (fpr to us
h c nse12c Enterprise Edition Release 12.1.0.2.0
tiDatabase
p a s
Oracle
l i c e -
ra 64bit Production
ur P
With the Partitioning, Oracle Label Security, OLAP, Advanced
m Analytics and Real Application Testing options
Fla
SQL> show parameter OS_AUTHENT_PREFIX
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
System altered.
a ble
SQL> SHUTDOWN IMMEDIATE
f e r
Database closed.
ans
Database dismounted.
n - t r
o
ORACLE instance shut down.
s an
SQL>
) ha
SQL> STARTUP
c o m ideฺ
ORACLE instance started.
m ailฺ t Gu
@ g dbytes e n
Total System Global Area a501059584
t ic2289400
S u
tbytes
Fixed Size h s
thi bytes
s 264241416
Variable Size apa e
(
Database Buffers f pr to us226492416 bytes
h t ica nse
Redo Buffers 8036352 bytes
a s c e
limounted.
rapDatabase
ur P
Database opened.
m SQL>
Fla 2. Create the database user FRED, using the IDENTIFIED EXTERNALLY clause. Allow
FRED to connect to the database.
As the SEC user, create the FRED user and grant the CREATE SESSION privilege.
SQL> CONNECT SEC
Enter password: *****
Connected.
SQL>
SQL> CREATE USER FRED IDENTIFIED EXTERNALLY;
User created.
SQL>
SQL> GRANT CREATE SESSION TO FRED;
2 3
User altered.
SQL> EXIT
$
3. Test the connection as the fred user. Log in to the OS as the fred user. (If the OS
user fred does not exist, run the $HOME/labs/USERS/create_osuser_fred.sh
script.) The OS password for fred is oracle. Set the environment variables, and note
a ble
that the oraenv command may provide extra information as the user is not part of the f e r
DBA group. Connect to the database with the “/” connect string. ans
n - t r
o
an
$ su - fred
Password: *****
ha s
$ . oraenv )
m ideฺ
c o
ailฺ t Gu
ORACLE_SID = [fred] ? orcl
m
ORACLE_BASE environment variable is not being set since this
g den
@
information is not available for the current user ID fred.
h t ica is Stu
You can set ORACLE_BASE manually if it is required.
p a s th
Resetting ORACLE_BASE to its previous value or ORACLE_HOME
a
pr to us e
( f
The Oracle base has been set to
h t ica nse
/u01/app/oracle/product/12.1.0/dbhome_1
p a s lice
$ sqlplus /
ra
ur P Connected to:
Overview
In this practice, you explore the protection of passwords for database links in Oracle Database
12c. Switch your environment, using oraenv, to point to the dbsec instance.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Create and test a database link in the PDB1 pluggable database. Log in as the oracle
OS user. As the SYSTEM database user, create a database link for the HR user to the
ORCL database. (Hint: Verify that both instances are up, and that PDB1 is open.)
CREATE PUBLIC DATABASE LINK test_hr
CONNECT TO hr IDENTIFIED BY oracle_4U
USING 'ORCL';
a ble
f e r
Note: Only users with the CREATE PUBLIC DATABASE LINK privilege can execute this ans
command. n - t r
$ echo $ORACLE_SID a no
dbsec h a s
m ) eฺ
$ sqlplus system@pdb1
o
Enter password: ****** a ilฺc Guid
g m ent
Connected to:
t i c a@ Stud
Oracle Database 12c a s h this Edition Release 12.1.0.2.0
Enterprise -
64bit Production
f p r ap use
a (
With the Partitioning, to options
OLAP, Advanced Analytics and Real
i c
ht cens
Application e
Testing
a s li
ap
SQL>
r
ur P
SQL> CREATE PUBLIC DATABASE LINK test_hr
m CONNECT TO hr IDENTIFIED BY oracle_4U
Fla USING 'ORCL';
2 3
Database link created.
SQL>
2. Test the database connection as the SCOTT database user by selecting from the
EMPLOYEES table through the database link.
Any database user can use this database link because it is declared PUBLIC.
Connected as SYSTEM, open the SCOTT account, and then test the database link.
SQL> ALTER USER scott IDENTIFIED BY oracle_4U ACCOUNT UNLOCK;
User altered.
MAX(SALARY)
-----------
24000
SQL>
3. View the data dictionary information about the database link. Note the Database Link
may include the EXAMPLE.COM domain. Find the username and password as they are
stored in the database.
a ble
a. Connect as SYSTEM and query the DBA_DB_LINKS view for database link f e r
ans
information.
n - t r
o
an
SQL> CONNECT system@pdb1
Enter password: ******
ha s
Connected. )
m ideฺ
c o
ailฺ t Gu
SQL> COL username FORMAT A16
SQL> COL owner FORMAT A16
m
g den
SQL> COL db_link FORMAT A16 @
h t ica is Stu
SQL> SELECT owner, db_link, username FROM DBA_DB_LINKS;
p a s th
a
pr DB_LINK
us e
OWNER
( f t o USERNAME
2 FROM LINK$
*
ERROR at line 2:
ORA-01031: insufficient privileges
SQL>
The SYSTEM user is granted the SELECT ANY DICTIONARY privilege but cannot view
the SYS.LINK$ table.
m ur P SQL>
Fla Note that you are connected to the root container. You created the database link in the
PDB1 container. Use either the ALTER SESSION or CONNECT to switch containers.
Note that the passwordx and authpwdx columns are represented as hex numbers and
may be different in your environment.
SQL> ALTER SESSION SET CONTAINER=PDB1;
Session altered.
SQL> # Use the above ALTER SESSION *OR* the following CONNECT
SQL> CONNECT sys@pdb1 as sysdba
Enter password: ******
Connected.
NAME
--------------------------------------------------------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
AUTHUSR
--------------------------------------------------------
AUTHPWD
--------------------------------------------------------
PASSWORDX
--------------------------------------------------------
AUTHPWDX
a ble
--------------------------------------------------------
f e r
TEST_HR
ans
n - t r
a no
a
07C3AA3161B61534381479C836FC0B4681E68548F32D28845EC40B1A
h s
m ) eฺ
o
7A4A5421A6D84FE46C53B1E374BF928D0ED35AE8B1E4D9CC5E08A1F7
a ilฺc Guid
13471B9CB6C61ED3345FC4D8C75504AA127AD3EB564FA583EE3117BB
g m ent
37209801CA3F0156C5360F0C2A14A261D6380A100F1ED93257D72C4D
ED56E34907B613BCC96C0AB90F1D9E6
t i c a@ Stud
a s h this
f p r ap use
SQL> a ( to
i c
ht cens e
a s li
rap
mur P
Fla
Overview
In this practice, you restrict the access to tables in the HR schema authorized by the
hrviewlink database link.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. While you are still connected to pdb1, create the MIKE user and grant him the HR_MGR
role. This may be done as SYS, SYSTEM, or an account such as SEC which was created
in the orcl instance. Discuss the implications of using each one.
SQL> SET ECHO ON
SQL> DROP ROLE HR_MGR;
DROP ROLE HR_MGR
a ble
* f e r
ans
ERROR at line 1:
n - t r
ORA-01919: role 'HR_MGR' does not exist o
s an
SQL> CREATE ROLE HR_MGR;
) ha
c o m ideฺ
Role created.
m ailฺ t Gu
@ g den
SQL> DROP USER mike CASCADE;
h t ica is Stu
DROP USER mike CASCADE
p a s th
* pr a us e
( f t o
ERROR at
h t ica user
line
n se'MIKE' does not exist
1:
s
ORA-01918: e
rapa lic
ur P SQL> CREATE USER mike identified by oracle_4U;
F lam
User created.
Grant succeeded.
Grant succeeded.
SQL>
a ble
User altered.
f e r
ans
SQL> CONNECT hr@pdb1 n - t r
Enter password: ****** a no
Connected. h a s
m ) eฺ
SQL> DROP DATABASE LINK hrviewlink;
o
DROP DATABASE LINK hrviewlink a ilฺc Guid
* g m ent
ERROR at line 1:
t i c a@ Stud
a s h this
ORA-02024: database link not found
f p r ap use
SQL> CREATE a ( DATABASE
to LINK hrviewlink CONNECT TO hr IDENTIFIED BY
i c
ht cUSING
oracle_4U e
ns 'orcl';
a s li e
rap
ur P
Database link created.
m
Fla SQL>
3. Create the employees_vw view and check that it allows you to retrieve
HR.EMPLOYEES@hrviewlink rows.
SQL> CREATE VIEW employees_vw as
SELECT * FROM HR.EMPLOYEES@hrviewlink;
2
View created.
Grant succeeded.
2 3
EMPLOYEE_ID SALARY
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
----------- ----------
206 8300
SQL>
4. Connect as MIKE and test the view.
SQL> CONNECT mike@pdb1
Enter password: ******
a ble
Connected.
f e r
SQL> UPDATE hr.EMPLOYEES_VW SET SALARY = 10000 ans
n - t r
WHERE employee_id = 206;
o
2
s an
1 row updated.
) ha
c o m ideฺ
SQL> SELECT employee_id, salary FROM
m ailฺ hr.employees_vw
t G u
WHERE employee_id = 206; g
@ d e n
2
h t ica is Stu
EMPLOYEE_ID a
SALARY
p s th
a
pr 10000
----------- ----------
us e
( f t o
h t ica nse
206
p a s ROLLBACK;
l i c e
ra SQL>
mur P
Fla
Rollback complete.
SQL>
5. Attempt to view some other table HR.DEPARTMENTS of the HR schema.
SQL> SELECT * FROM hr.departments@hrviewlink;
SELECT * FROM hr.departments@hrviewlink
*
ERROR at line 1:
ORA-02019: connection description for remote database not found
SQL> EXIT
$
Overview
In this practice, you configure the External Secure Password Store to hide passwords in batch
job scripts.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Assumptions
You successfully completed Practice 2-1 Task 1.
Tasks
The batch processes have been moved to a client machine. The batch processes will continue
using the /@netservice_name login for database connections. However, you must follow
security best practices: hence remote OS authentication (REMOTE_OS_AUTHENT) is not
allowed. Configure the external secure password store for the fred user to connect as the HR a ble
f e r
database user.
ans
1. Log in to the operating system as fred.
n - t r
$ su - fred
a no
Password: ******
h a s
$
m ) eฺ
o uid
a ilฺc /home/fred/oracle/wallet
2. Create the following directories required for this practice:
G
and /home/fred/oracle/network.
g m ent
a@ toSbe
Set the permissions on the wallet directory
c d
tuaccessible only to fred.
t i
h this
$ mkdir /home/fred/oracle
a s
r ap use
$ mkdir /home/fred/oracle/wallet
f p
a ( to
$ mkdir /home/fred/oracle/network
i c e
t /home/fred/oracle
$ ls h-l ns
a s
ptotal 8 li c e
r a
u r P drwxr-xr-x 2 fred users 4096 Jan 20 16:35 network
m
Fla
drwxr-xr-x 2 fred users 4096 Jan 20 16:35 wallet
$ chmod 700 /home/fred/oracle/wallet
$ ls -l /home/fred/oracle
total 8
drwxr-xr-x 2 fred users 4096 Jan 20 16:35 network
drwx------ 2 fred users 4096 Jan 20 16:35 wallet
$
wallet, only the operating system user who created it can manage it.
a. Use the mkstore utility. Set the wallet password to welcome1.
$ . oraenv
ORACLE_SID = [fred] ? orcl
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is
/u01/app/oracle
a ble
$ mkstore -wrl /home/fred/oracle/wallet -create
f e r
Oracle Secret Store Tool : Version 11.2.0.1.0 - Production
ans
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All n - t r
rights reserved.
a no
Enter password: ******
h a s
Enter password again: *******
m ) eฺ
o
$
a ilฺc Guid
m en-wrl
b. Add credentials to the wallet by usinggmkstore t <wallet_location> -
a@
createCredential <db_connect_string>
c d <username> [<password>]
tualias
where <db_connect_string> t i
h this is a S
TNS or any service name used to
a s
p to The
connect to the database. service name specified in the mkstore command and
the service name r a
p to u
used s e
connect to the database (in connect
( f
a se must be identical. Add credentials to the wallet so that
t i c
/@<db_connect_string>)
p a sh cancconnect
fred
enthe username
hr_sec,liwith
to the HR schema without a password. Set the service name to
hr and the password oracle_4U.
ra
ur P $ mkstore -wrl /home/fred/oracle/wallet -createCredential hr_sec
F lam hr
Oracle Secret Store Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All
rights reserved.
Your secret/Password is missing in the command line
Enter your secret/Password: (oracle_4U)
Re-enter your secret/Password: (oracle_4U)
Enter wallet password: (welcome1)
Create credential oracle.security.client.connect_string1
$
# .bashrc
SQLNET.WALLET_OVERRIDE = TRUE
The sqlnet.ora file has three parameters for configuring the secure external password
store: WALLET_LOCATION, SQLNET.WALLET_OVERRIDE, and
SQLNET.AUTHENTICATION.SERVICES.
• WALLET_LOCATION points to the directory where the wallet resides; this parameter
exists in earlier versions.
• Ensure the SQLNET.WALLET_OVERRIDE parameter is set to TRUE. This setting
causes all CONNECT /@db_connect_string statements to use the information in
the wallet at the specified location to authenticate to databases.
WALLET_LOCATION =
(SOURCE =
a ble
(METHOD = FILE)
f e r
(METHOD_DATA =
ans
(DIRECTORY = n - t r
/home/fred/oracle/wallet))) a no
h a s
m ) eฺ
SQLNET.WALLET_OVERRIDE = TRUE
o
a ilฺc Guid
The NAMES.DIRECTORY_PATH line may be g m ent
ignored.
i c a@ Stud file to
7. Copy the $ORACLE_HOME/network/admin/tnsnames.ora
t
s
/home/fred/oracle/network/tnsnames.
a h this
p r ap use
$ cp $ORACLE_HOME/network/admin/tnsnames.ora
f tnsnames.ora
(
a se t o
h t i c
8. Edit the /home/fred/oracle/network/tnsnames.ora
n
file. Replace the ORCL alias by
p a s lice
the HR_SEC alias at the beginning of the file:
P ra HR_SEC =
r
mu (DESCRIPTION =
Fla (ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = db1.example.com)(PORT =
1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl.example.com)
)
)
9. Test the configuration by attempting to connect to the database instance with the connect
string /@hr_sec.
$ sqlplus /@hr_sec
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> exit
$
10. List the contents of the wallet. Use the mkstore command with the listCredential
option. Use the following command:
mkstore –wrl /home/fred/oracle/wallet –listCredential
$ mkstore -wrl /home/fred/oracle/wallet -listCredential
Oracle Secret Store Tool : Version 11.2.0.1.0 - Production
a ble
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All
f e r
rights reserved.
ans
n - t r
Enter wallet password:
a no
h a s
List credential (index: connect_string username)
m ) eฺ
o
1: hr_sec hr
a ilฺc Guid
$ exit
g m ent
logout
t i c a@ Stud
$
a s h this
11. As the oracle user, attempt
f p r ap to use
u s ethe wallet belonging to fred to connect with the
a (
connect string /@hr_sec.
to
a. Set TNS_ADMIN
h i c nto e
t/home/fred/oracle/wallet.
s /home/oracle/labs/admin. The sqlnet.ora file is set up to use the
s
wallet at c e
p$ aexport liTNS_ADMIN=/home/oracle/labs/admin
r a
u r P $ cd $TNS_ADMIN
m
Fla $
b. Open the tnsnames.ora file from /home/oracle/labs/admin and edit the same
way as in step 8.
HR_SEC =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl.example.com)
)
)
apa
SQL> exitic
r l
ur P
$
m
Fla
System altered.
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Overview
In this practice, you create a common user in the CDB and observe that the common user
connects with the same password in all PDBs in the CDB. In a second step, you create a local
user in each of the two PDBs of the CDB and observe how the local users connect to the PDBs.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Create the common user C##U1 in dbsec.
$ . oraenv
ORACLE_SID = [orcl] ? dbsec
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is
a ble
/u01/app/oracle
f e r
$ sqlplus system
ans
Enter password: ****** n - t r
a no
Last Successful login time: Mon Jun 17 2013 02:46:48 +00:00
h a s
m ) eฺ
Connected to:
o uid 12.1.0.2.0 -
Oracle Database 12c Enterprise Edition
a ilฺc Release
G
64bit Production
g m ent
With the Partitioning, OLAP,
t i c S tud Analytics and Real
a@Advanced
a s h this
Application Testing options
p se
pra c##u1
SQL> CREATE(fUSER
t o u IDENTIFIED BY oracle_4U CONTAINER=ALL;
a
tic ense
s h
apa lic
User created.
r
m ur P SQL> GRANT create session TO c##u1 CONTAINER=ALL;
Fla Grant succeeded.
SQL>
2. Connect as C##U1 in root.
SQL> CONNECT c##u1
Enter password: ******
Connected.
SQL> SHOW CON_NAME
CON_NAME
------------------------------
CDB$ROOT
SQL>
CON_NAME
------------------------------
PDB1
SQL>
4. Connect as C##U1 in pdb2.
SQL> CONNECT c##u1@pdb2
Enter password: ****** a ble
f e r
Connected.
ans
SQL> SHOW CON_NAME
n - t r
a no
CON_NAME
h a s
------------------------------
m ) eฺ
o
ilฺc Guid
PDB2
SQL> a
m ent
g
SQL> t i c a@ Stud
Notice that the same password a s hused ttohconnect
is is to any container of dbsec.
r p se
aLOCAL_EMPLOYEE
( f
5. Create the local userp t o u in pdb1.
a. Connecttias a
c SYSTEM sein pdb1.
s h
a CONNECT e n
r a pSQL> lic system@pdb1
m ur P Enter password: ******
Fla Last Successful login time: Mon Jun 17 2013 03:13:35 +00:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
SQL>
b. Create the local user LOCAL_EMPLOYEE.
SQL> CREATE USER local_employee IDENTIFIED BY pass_pdb1;
User created.
Grant succeeded.
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a s t h is
p se
a******
SQL> CONNECT system@pdb2
r
(
Enter password:f p t o u
a
tic ense
Connected.
a s h
r a pSQL> lic
u r Pb. Create the local user LOCAL_EMPLOYEE.
l a m SQL> CREATE USER local_employee IDENTIFIED BY pass_pdb2;
F
User created.
Grant succeeded.
SQL>
c. Connect as LOCAL_EMPLOYEE in pdb2.
SQL> CONNECT local_employee@pdb2
Enter password: ******
Connected.
SQL>
Overview
In this practice, you prepare the EM13 and CL1 virtual machines for the next lesson. Starting
the virtual machine automatically starts Enterprise Manager Cloud Control. Because this
requires no supervision, other activities such as the lecture for the next lesson may occur at the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
same time.
Assumptions
You are at the virtual machine host desktop, logged in as user oracle.
Tasks
1. Determine which virtual machines have been started. In this example, cl1 is started and
em13 is not started.
a ble
f e r
$ sudo xm list
ans
Name ID Mem VCPUs State
n - t r
Time(s)
Domain-0 0 1024
a no
2 r----- 207735.6
cl1 3
a
1024
h s 1 -b---- 5582.5
db1 1
m ) eฺ
3072 1 -b---- 18375.4
o
a ilฺc Guid
2. If necessary, start the em13 virtual machine. g m thatethe
Verify n t virtual machine is started by
observing the entry in the list, in either a
c @runningtuordblocked state as indicated in the State
the
column. The content of the ID column t i
h thiTime
and
s Scolumn may be different on your machine.
$ sudo xm create p a s
em13 e
f r a us
pfile t"/etc/xen/em13".
Using config (
a sem13 o
Started
h t icdomainn e (id=6)
s
a sudo xm
p$Name e
lic list
r a
u r P Time(s) ID Mem VCPUs State
m
Fla Domain-0 0 1024 2 r----- 207820.3
cl1 3 1024 1 -b---- 5584.2
db1 1 3072 1 ------ 18409.3
em13 6 9216 1 r----- 4.3
3. If necessary, start the cl1 virtual machine using the same process, substituting cl1 for
em13. In this example, it is not necessary.
The em13 virtual machine automatically starts the Enterprise Manager repository database,
followed by the Enterprise Manager WebLogic Server–based Management Server (OMS). This
can take a significant amount of time.
a ble
f e r
ans
n - t r
a no
h a s
Practices for m ) Lesson
e ฺ 3: Using
o uidSecurity
a ilฺc User
Enterprise G
g m ent
c a @ tu3 d
Chapter
i
ht this S
a s
f p r ap use
a ( to
i c
ht cens e
a s li
rap
mur P
Fla
Practices Overview
In this lesson, you use Enterprise User Security to connect to a database with unknown
database users, but with directory entry users. The Oracle Unified Directory has been installed
on the cl1 virtual machine, and you start that product for use with the orcl instance. You also
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
register the instance with Enterprise Manager Cloud Control running on the em13 virtual
machine. This practice explains how to:
• Configure and register a database with an LDAP directory.
• Create and map global private schemas and global shared schemas with directory
entries.
• Test the connections as unknown database users.
• Create global roles and enterprise roles, and map them together to assign enterprise
a ble
roles to directory entry users.
f e r
• Test the connections of unknown database users being granted enterprise roles. ans
n - t r
a no
Assumptions
h a s
m
This practice uses the orcl database instance on virtual machine )db1, Oracle
e ฺ Unified Directory
(OUD) and Oracle Directory Services Manager (ODSM) ion c o i d
lฺ Gu cl1, and Enterprise
virtual machine
Manager Cloud Control on virtual machine em13. m a t
g e n
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
ht cens e
p a s li
r a
u rP
m
Fla
Overview
In this practice, you verify that Oracle Enterprise Manager Cloud Control is operational and
register the orcl instance with Enterprise Manager Cloud Control.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Enterprise Manager Cloud Control is automatically started when the em13 VM boots,
and typically requires 20 to 30 minutes to start on these virtual machines. To verify it is
operating, log on to the em13 machine as the oracle user and run the following
command:
$ /u01/app/oracle/product/fmw/bin/emctl status oms
Oracle Enterprise Manager Cloud Control 13c Release 1
a ble
Copyright (c) 1996, 2015 Oracle Corporation. All rights
f e r
reserved.
ans
WebTier is Up
n - t r
Oracle Management Server is Up
a no
JVMD Engine is Up
h a s
BI Publisher Server is Down
m ) eฺ
o
ilฺc Guid
BI Publisher is disabled, to enable BI Publisher on this host,
a
m ent
use the 'emctl config oms -enable_bip' command
g
Note that BI Publisher has been disabled
c d required in this course.
a@ asSittisunot
2. If sufficient time has passed andt i
h the tWebTier,
isstartOracle Management Server, or JVMD
Engine are still down, you a s
p se
may attempthto them using the following command:
r a
a (fp to u
$ /u01/app/oracle/product/fmw/install/unix/scripts/omsstup start
s h tic ense
sudo exist
a a Enterprise
pOracle lic Manager Cloud Control 13c Release 1
r
u r P Copyright
reserved.
(c) 1996, 2015 Oracle Corporation. All rights
m
Fla Starting Oracle Management Server...
WebTier Successfully Started
Oracle Management Server Already Started
Oracle Management Server is Up
JVMD Engine is Up
$
Note that the keyword start is on the command line, not on a separate line.
Courtesy scripts status_oms.sh, start_oms.sh and stop_oms.sh that run these
long strings have been placed in /home/oracle/bin, which is available in your PATH
for your convenience.
3. If Enterprise Manager Cloud Control is running, exit the em13 machine and return to the
VM host.
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o id
f. Verify that the orcl instance has not been a ilฺc G
registered byu
switching the view to the
Search List. g m ent
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
ht cens e
a s li
rap
mur P
Fla g. The orcl.example.com database Instance should not be in the list, although other
instances may be listed. As an example, the following shows only the
fix1_db1.example.com database instance to be registered.
a (fp to u
Connected
h c to:nse
tiDatabase
a s
Oracle
p l i c e 12c Enterprise Edition Release 12.1.0.2.0 -
ra 64bit Production
ur P With the Partitioning, OLAP, Advanced Analytics and Real
F lam Application Testing options
SQL>
c. Unlock the DBSNMP user and assign a password. Note this password because it will
be required in task 6.
SQL> alter user dbsnmp account unlock identified by oracle_4U;
User altered.
SQL>
d. Exit from the database and the db1 machine.
If the terminal appears to hang when you exit a VM, you may use Control + C to
complete the exit.
a ble
f e r
ans
b. Click the Add Using Guided Process button.
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
a ble
f e r
ans
n - t r
a no
h a s
d. On the Database Discovery: Search Criteria page, click)the Search
ฺ icon ,
o m e
page. a ilฺc Guid
highlight the db1.example.com row, and click Select to return to the Search Criteria
g m ent
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
ht cens e
a s li
rap
mur P
Fla
e. Click Next.
f. Select the orcl.example.com target, enter the DBSNMP password that you set
previously, and click Test Connection.
j. Click Save in the upper-right area to proceed. If a Confirmation pop-up appears, click
Close to return to the Add Targets Manually page.
k. Return to the Database target page and select the new orcl.example.com link to
access the database home page.
a ble
f e r
ans
n - t r
a no
h a s
l. Note the menu selections on the database home page,
m )and ineparticular
ฺ note the
o
selections in the Security menu.
a ilฺc Guid
g m ent
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
ht cens e
a s li
rap
m ur P m. You do not require Enterprise Manager Cloud Control for the next few tasks. Note,
Fla however, how you started the browser for future reference.
Overview
Oracle Enterprise User Security uses LDAP to provide a central storage of usernames, roles
and passwords. The LDAP schema is available for Oracle Internet Directory (OID) and Oracle
Unified Directory (OUD), both of which can be configured to synchronize with other directories
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
a s h this
f p r ap use
i c a ( to shttp://cl1.example.com:7001/odsm
6. Point the tbrowser e to to start the Directory Services
s h
Manager. e n
The following page is displayed:
r a pa lic
u r P
l a m
F
a ble
f e r
ans
n - t r
a no
h a s
a. The first time you access the system, you may be challenged
m ) eฺ to accept the
certificate. If this page or pop-up is displayed, o
i l ฺ u idTrust Always”
c click “Yes,
g ma ent G
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
ht cens e
a s li
r ap
mur P
Fla
a ble
f e r
ans
8. The OUD default is to store passwords only in Salted SHA-1. According to My Oracle
Support document 2093460.1, Enterprise Manager Cloud Control 13c connects to EUS n - t r
o
an
using SASL Digest-MD5 and uses AES storage. The database uses SHA-1. Therefore,
s
) ha
you need to add the AES, MD5, and SHA-1 storage formats to OUD. That also requires
updating existing passwords to generate the required storage.
c o m ideฺ
ailฺ t Gu
a. Open the Security tab and expand the Password Policy group and select the
Default Password Policy m
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
a ble
f e r
ans
n - t r
a no
s
haclick
c. Click the next field to activate the Apply button, and)then Apply.
m ฺ
i l ฺ co uide
g ma ent G
t i c a@ Stud
d. Repeat the precedingsstep
a h forththeisRoot Password Policy and the Global
selected. Iffp r
you
adop notuperform
Administrator Password Policy,
s ensuring at least Salted SHA-512 and AES are
e this step, the login to Enterprise Manager in
( t o
h t ica ncl1
Practice 3-4 will fail.
seas oracle and update the Directory Manager password to
9. Log on
pa s to machinee
c the changeDirectoryManagerpwd.sh script found in
liUse
r a
oracle_4U.
/u01/app/oracle/Middleware/asinst_1/OUD/bin/ldapsearch -h
cl1.example.com -p 4444 -D "cn=Directory Manager" --useSSL -j
pwd-file -b "cn=Directory Manager,cn=Root DNS,cn=config" -s base
objectclass=* userpassword
The server is using the following certificate:
Subject DN: CN=cl1.example.com, O=Administration Connector
Self-Signed Certificate
Issuer DN: CN=cl1.example.com, O=Administration Connector
a ble
Self-Signed Certificate
f e r
ans
Validity: Fri Dec 09 05:06:56 EST 2016 through Sun Dec 09
05:06:56 EST 2018 n - t r
o
an
Do you wish to trust this certificate and continue connecting to
s
the server?
) ha
Please enter "yes" or "no":yes
c o m ideฺ
ailฺ t Gu
dn: cn=Directory Manager,cn=Root DNs,cn=config
userpassword: m
g den
@
ica is Stu
{AES}AfGbnMScAUlxjYoz0ZlM2jGga1FNK11I+A1nIvBDIkup/vOOQE0cxCd9
userpassword:
s h t
p a th
{SSHA512}cagKt+RRG4Kb50+lX3JWslLZqc5LPvxghCNOtxA7ui/wGdHpj256QRB
a e
G0
( f pr to us
h t i ca nse
80bgG2JtUyoZpWr4aDY3+ZqoB96Zg6LTgqyXSFR
11. Verifysthat you can e log in to ODSM using the new password.
p a l i c
P ra
u r
m
Fla
a. In ODSM, open the Data Browser tab, expand the dc=example,dc=com node,
expand the cn=OracleContext node, expand the cn=Products node, and click the
cn=Common node.
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
b. In the data panel, expand the Optional Attributes (scroll down if necessary to see
the Optional Attributes and click the arrow in front of the name).
13. Using the Data Browser tab in ODSM, access the information for users that is found in
the node previously identified and update the password for one of the existing users.
a. Select the node for uid=user.0.
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
t ithat tu
causers inSthe
b. Note the data entered
a s h
for
t h i data panel.
f p r ap use
a ( to
i c
ht cens e
a s li
rap
mur P
Fla
a ble
f e r
e. Update the password to oracle_4U and click Apply in the upper-right area to ans
update the password to use all the storage formats selected. n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Overview
Oracle Database can communicate with the LDAP server based on the configuration in the
sqlnet.ora file. This is usually done by using the Networking Configuration Assistant. After
the communication has been established, the database may be registered with LDAP using the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Log on to the db1 machine as user oracle with GUI capability.
[Host Desktop]$ ssh -X -l oracle db1
oracle@db1's password:
a ble
Last login: Fri Dec 9 02:59:12 2016 from 192.0.2.1
f e r
ans
[oracle@db1 ~]$
n - t r
2. Set the environment to use the orcl instance.
a no
[oracle@db1 ~]$ . oraenv
h a s
ORACLE_SID = [oracle] ? orcl
m ) eฺ
o
The Oracle base has been set to /u01/app/oracle
a ilฺc Guid
[oracle@db1 ~]$
g m ent
3. Start the Network Configuration Assistant.
t i c a@ Stud
[oracle@db1 ~]$ netcah is
a s t h
f p r ap use
Oracle Net (Serviceso Configuration:
i c e t
astarts,sselect
4. When the
s t
h cen
GUI Directory Usage Configuration and click Next.
a p a li
P r
u r
l a m
F
a ble
f e r
ans
6. Enter the host name where the LDAP server is running (cl1.example.com), the ports
that are needed to access LDAP, 1389 for the regular port and 1636 for the SSL port, n - t r
o
an
and click Next. Note that on Linux, ports 1 to 1024 require super user privileges, and
s
ha
Oracle Unified Directory is started and run as the oracle user. Therefore the ports are
)
outside the privileged range.
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s thNext.
a
pr to us
8. Note the resulting information and eclick
( f
h t ica nse
p a s lice
P ra
u r
m
Fla
b. Ensure Directory Naming is in the Selected Naming Methods list and click Next
until the Welcome page is displayed.
a ble
f e r
ans
10. Click Finish to return to the command line. n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla 11. Review the resulting ldap.ora file, and sqlnet.ora if you performed the optional
step.
DIRECTORY_SERVERS= (cl1.example.com:1389:1636)
DEFAULT_ADMIN_CONTEXT = "dc=example,dc=com"
DIRECTORY_SERVER_TYPE = OID
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
h t ica nse
p a s lice
ra
mur P
Fla
a ble
f e r
ans
n - t r
a no
h a s
e. Click Next through the Database Components page.
m ) eฺ
o uidmay need to deselect
ilฺc GYou
f. Do not configure Database Vault or Label Security.
a
the options. Click Next.
g m ent
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
ht cens e
a s li
rap
mur P
Fla
i. The Progress page may be displayed, but will quickly move to the final page
confirming completion. Click Close.
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
a s h this
f p r ap use
a (
b. Optionally, view theodata stored in the various attributes.
t
t
c. Exiti c
ODSM. se
a shhowlaicPDB
14. Discuss
p en may be registered with LDAP. If a CDB instance is available with
P raopened pluggable databases, you may wish to explore the Manage Pluggable
u r Databases option of the Database Configuration Assistant.
m
Fla
Overview
Enterprise User Security management is performed using Enterprise Manager. You add groups
to be recognized by the database, add users to the groups without corresponding database user
IDs, and verify that you can log in to the database with the new user IDs.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Log in to the db1 machine, and access the orcl database as a user with DBA privileges.
The following assumes you have previously logged out of the db1 machine. Start at the
point appropriate for your current state.
[Host Desktop]$ ssh -l oracle db1
a ble
oracle@db1's password:
f e r
Last login: Tue Dec 13 08:33:48 2016 from 192.0.2.1
ans
[oracle@db1 ~]$ . oraenv
n - t r
ORACLE_SID = [oracle] ? orcl
a no
The Oracle base has been set to /u01/app/oracle
h a s
[oracle@db1 ~]$ sqlplus system m ) eฺ
o
a ilฺc Guid
g m enton Tue Dec 13 08:35:37
SQL*Plus: Release 12.1.0.2.0 Production
2016
t i c a@ Stud
a s h this
Copyright (c) 1982,
r a p se Oracle. All rights reserved.
2014,
a (fp to u
ic nse
Enter tpassword:
h
p a
Lasts l i c
Successfule login time: Tue Dec 13 2016 08:34:08 -05:00
ra
m ur P Connected to:
Fla Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
2. Create a global user and grant it the ability to create sessions.
SQL>
SQL> DROP USER GUEST CASCADE;
User dropped.
User created.
SQL>
3. Create or replace two new global roles and grant them the ability to select from
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
OE.PRODUCTS.
SQL> DROP ROLE emprole;
Role dropped.
a ble
Role created.
f e r
ans
SQL> DROP ROLE custrole; n - t r
a no
Role dropped.
h a s
m ) eฺ
o uid
SQL> CREATE ROLE custrole IDENTIFIED
a ilฺcGLOBALLY;
G
g m ent
Role created.
t i c a@ Stud
a s h this
SQL> GRANT select
f p r apON uoe.products
s e TO custrole, emprole;
a ( to
i c
Granthtsucceeded. ns e
a s li c e
rap
mur P SQL>
Fla
Grant succeeded.
SQL>
4. You may optionally exit the orcl database.
Overview
Enterprise User Security management is performed using Enterprise Manager. You add groups
to be recognized by the database, add users to the groups without corresponding database user
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
IDs, and verify that you can log in to the database with the new user IDs.
Tasks
1. Using the browser, log on to the Enterprise Manager console as user SYSMAN, and open
the orcl.example.com database page. If necessary, review the earlier instructions to access
the database home page. The resulting page should look similar the following:
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla 2. Expand the Security menu.
3. Select Enterprise User Security from the bottom of that menu. You may need to scroll
the page to display the required entry.
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
P r a
r
u 5. Click Login.
m
Fla If the system responds with an Invalid Credentials message and you are sure you have
entered the password correctly, you may not have successfully added AES as a storage
mechanism in the earlier step.
a ble
f e r
ans
b. Ensure the OracleDefaultDomain is selected and click Configure.
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
r a
mur P
Fla
c. Note that the orcl database should have been added automatically. If it is not, click
Add, Click Go to bring up the list of databases, select orcl as shown in the following
snippet, and click Select to return to the Configure Domain screen.
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
Pd.r
aSelect the orcl database, enter the database User Name as system and its
u r password, and click Go to display a list of the database global roles.
m
Fla
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
t ens e
g. p a shthe
Select lic view, click Go to search for all known users in the directory, select
USER
r a user.0, and click Select.
mur P
Fla
a ble
f e r
ans
i. Click OK to return to the Manage Enterprise Domains page. n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
a s h this
8. Enable password access for the database.
r a p Domains
a. From the Manage Enterprise
s e page, select the orcl database, click
fp thetoConfiguration
Configure, and(select
a
u view.
s h tic ense
r a pa lic
mur P
Fla
Enter password:
Last Successful login time: Tue Dec 13 2016 11:42:36 -05:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
a ble
f e r
With the Partitioning, OLAP, Advanced Analytics and Real
ans
Application Testing options
n - t r
SQL> select count(*) from oe.products; a no
h a s
m ) eฺ
o
ilฺc Guid
COUNT(*)
---------- a
m ent
g
a@ Stud
288
t i c
h this
SQL> exit a s
Disconnected p
f r apOracle
from u s eDatabase 12c Enterprise Edition Release
12.1.0.2.0 a (- 64bittoProduction
i c se
t Partitioning,
With hthe n
a s c e
li Testing options
OLAP, Advanced Analytics and Real
rapApplication
mur P
10. Verify that user.0 does not exist in the database.
Fla
[oracle@db1 ~]$ sqlplus system
Enter password:
Last Successful login time: Tue Dec 13 2016 11:41:45 -05:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
no rows selected
SQL> exit
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
c. In the Entry Picker window, expand the tree to display the distinguished name
n - t r
cn=Root, then dc=example,dc=com, and select ou=People. o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
r a
mur P
Fla
e. Enter the information about an individual. Include data in the Common Name, User Id, a ble
User Name, First Name, and Last Name fields. f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
a s
f. Scroll down to the Organization
h Information
t h is data group and enter a User Password.
f p r ap use
a ( to
i c
ht cens e
p a s li
r a
mur P
Fla g. Click Create in the upper-right area. Review any messages and fix any data issues that
might be reported.
a ble
f e r
ans
n - t r
a no
h a s
i. Click the Manage Enterprise Users link and find the user m )you created.
e ฺ You may enter
c o i d
m ailฺ t Gu
the username into the User field and click Go, or scroll down.
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
P ra
u r
m
Fla
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ created Product
k. Click Continue, click the Enterprise Roles tab, and grant the previously
role to your user.
i l ฺ co uid
g ma ent G
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
ht cens e
p a s li
r a
mur P
Fla
l. Click OK and exit Enterprise Manager.
m. On the db1 machine, connect to the orcl database using the newly created username
and the password you entered. Check your capabilities and log out of the database.
Overview
In this practice, you:
• Registered the orcl database with Enterprise Manager Cloud Control
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
• Started the Oracle Unified Directory server and the Oracle Directory Services Manager
administration tool
• Configured the LDAP server
• Configured Oracle Networking to communicate with LDAP using ldap.ora
• Registered the orcl database with LDAP by using the Database Configuration
Assistant
• Created a global user and global groups
a ble
• Configured Enterprise User Security by using Enterprise Manager Cloud Control
f e r
ans
To clean up, you: n - t r
• Remove the database from Enterprise Manager Cloud Control a no
• h a s
De-register the database from the directory service, using DBCA
• Stop the ODSM and OUD servers m ) eฺ
o
a ilฺc Guid
Tasks
g m ent
t i c @ tCloud
1. Using the browser, log on to EnterpriseaManager
S ud Control and remove the orcl
database.
a. Access the Enterprise p a sh Cloud t h s
iControl
r a Manager
s e Databases target page.
a (fp to u
s h tic ense
r a pa lic
u rP
m
Fla
c. Click Remove.
d. Confirm that you wish to remove the target. a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
a s h this
e. When complete, the r p setarget page will be displayed. Verify that the removal
aDatabases
f p
was successful(and the tdatabase
o u is not in the list of databases.
a
toficEnterprise
seManager Cloud Control, and optionally shut down the em13
f. Log out
s h
a machine. e n
r a pvirtual lic When the machine is down, the xm list em13 command returns without
ur P
a response.
m [Host Desktop]$ ssh -l oracle em13
Fla oracle@em13's password:
Last login: Tue Dec 13 14:22:26 2016 from 192.0.2.1
[oracle@em13 ~]$ sudo shutdown -P now
[Host Desktop]$
2. From the db1 machine, de-register the database from the directory server.
a. Log on to the db1 machine as the oracle user, set the environment using oraenv to
point to orcl, and invoke dbca.
b. Select Configure Database and click Next.
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
c. Select the orcl database, enter SYS asg musername,
the
e n t provide the password for SYS,
and click Next.
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
ht cens e
p a s li
r a
mur P
Fla
a ble
f e r
ans
n - t r
o
e.
an
Click Next on the Database Components and Sample Schemas page.
s
f.
ha
Ensure the Configure Database Vault and Configure Label Security selections are NOT
selected, and click Next. )
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
r a
mur P
Fla
a ble
f e r
ans
n - t r
j. no
Log out of the db1 machine. Do not stop the machine because it will be used in the
a
next lesson.
h a s
m ) eฺ
o id and the Oracle
a ilฺcDirectory
3. Log in to the cl1 machine and stop the Oracle Unified
G uServer
Directory Services Manager.
g m ent
c a @ tud and stop_ds.sh.
a. Use the provided courtesy scripts, stop_wls.sh
i
htoracle i s S
[Host Desktop]$ ssh -l
a s
p se t h
cl1
r a
oracle@cl1's password:
p Decto 13u 11:14:20 2016 from 192.0.2.1
Last login:(fTue
a
tic e~]$
[oracle@cl1 sestop_wls.sh
a s h n
r a pGraceful lic
u r P This command shutdown command issued to the server "AdminServer".
might take time since the server waits for inflight
m
Fla work to finish before shutdown. If you wish to ignore inflight
work please use FORCESHUTDOWN command to override inflight work
and shutdown the server ...
pra to us
b---- 4789.2
(
[Host Desktop]$f
h t ica nse
p a s lice
r a
mur P
Fla
a ble
f e r
ans
n - t r
a no
h a s
Practices for m ) Lesson
e ฺ 4: Using
o d
ilฺc and
Privileges
a G uiRoles
g m ent
c a @ tu4 d
Chapter
i
ht this S
a s
f p r ap use
a ( to
i c
ht cens e
a s li
rap
mur P
Fla
Practices Overview
Real Application Security (RAS) uses an established trust relationship between the database
and the middle tier where the application is to run. With this trust relationship a user is
connected and authenticated in the middle tier. After connection from the middle tier to the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
database, the middle tier tells the database which application role to use. The RAS connection
is based on proxy authentication, and the application roles are mapped to database roles.
Real Application Security is discussed in detail in the Oracle Database Security: Preventative
Controls for Developers course. That course assumes familiarity with proxy authentication and
database roles and privileges, which are discussed in this lesson.
In these practices, the security officer will implement privileges and roles and grant them to
users according to their respective job in the company.
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Overview
In this practice, you use the OCI programs that simulate an in-house developed application
server: proxy_user and proxy_role. For both, the program starts by connecting to the orcl
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
database as the HRAPP user and creating a connection pool with 10 connections, and then it
attempts to create sessions for the PFAY user. The conditions vary and sometimes the sessions
fail to be created.
Assumptions
• This set of practices is performed on the db1 virtual machine by using the orcl instance
and the dbsec CDB instance.
• The instances and listener are assumed to be running. a ble
f e r
ans
Task
n - t r
no
1. If you did not create the SEC user in Practice 2, set your Oracle environment to the orcl
a
h a s
database instance and run the /home/oracle/labs/USERS/create_sec.sh script to
) eฺ
create this user. As the SEC user, create a user to simulate a middle-tier user.
m
o
a. Create a user with the following properties:
a ilฺc Guid
Username: HRAPP
Password: HRAPP g m ent
privilege: CREATE SESSION
t i c a@ Stud
a s h this
Note: This password is case-sensitive; it must be in uppercase.
$ . oraenv fpra
p se
(= [dbsec]
t o u
i
ORACLE_SID
t a
c nse ? orcl
a h
ThesOracle e
c base for
a p l i
r ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is
mur P /u01/app/oracle
Fla
$ sqlplus sec
Enter password: ******
Last Successful login time: Mon Jun 17 2013 03:07:45 +00:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced
Analytics and Real Application Testing options
User created.
SQL>
SQL> GRANT create session TO hrapp;
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL>
b. Verify that HRAPP can connect. (Be aware of the uppercase password).
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
ur P
With the Partitioning, Oracle Label Security, OLAP, Advanced
m Analytics and Real Application Testing options
Fla SQL>
SQL> DROP USER pfay CASCADE;
DROP USER pfay CASCADE
*
ERROR at line 1:
ORA-01918: user 'PFAY' does not exist
User created.
Grant succeeded.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
User altered.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
SQL> EXIT
$
4. The proxy_user program tests connections through the middle tier.
This program has the following arguments:
• Connection (TNS) name is required.
• Username is required.
• Password is optional.
The program performs the following steps: a ble
f e r
• Connects as the HRAPP user
ans
• Creates a connection pool of 10 connections n - t r
o
• an
Creates 10 threads that connect to the database by using one of the
s
) ha
connections from the pool. The proxy_user program makes these
connections by using the username and password parameters.
c o m ideฺ
ailฺ t Gu
• Waits for a return character from the standard input
m
• Disconnects the 10 threads, destroys the connection pool, and ends
g den
@
ica is Stu
a Start a separate terminal window to act as a client. Set the environment variables
h t
by using the oraenv utility to set the instance name to orcl. Change to the
s
p a th
/home/oracle/labs/ROLES directory.
a e
b. f pr to us
Recompile the proxy programs. Ignore the error messages.
(
t ica nse
$ cd /home/oracle/labs/ROLES
h
p a s lice
$ ./mk_proxy_user
ra
ur P
proxy_user.c: In function 'main':
m proxy_user.c:56: warning: incompatible implicit declaration of
Fla built-in function 'strlen'
proxy_user.c: In function 'threadFunction':
proxy_user.c:109: warning: incompatible implicit declaration of
built-in function 'strlen'
$ ./mk_proxy_role
proxy_role.c: In function 'main':
proxy_role.c:60: warning: incompatible implicit declaration of
built-in function 'strlen'
proxy_role.c: In function 'threadFunction':
proxy_role.c:116: warning: incompatible implicit declaration of
built-in function 'strlen'
$ mv proxy_user? proxy_user
$ mv proxy_role? proxy_role
The proxy_user command connects PFAY without a password. Should this work?
Why?
The program should work because you set up PFAY so that the user can connect
without a password. When the program is complete, press the Enter key.
The Hit enter to end connections: line may appear out of sequence.
$ ./proxy_user orcl pfay
Database: orcl
a ble
Username: pfay
f e r
Password:
ans
Successful connection: Username: HRAPP
n - t r
o
Successful connection: Username:
s an pfay
Successful connection: Username:
) ha pfay
Successful connection: Username:
c o m ideฺ pfay
Successful connection: Username:
m ailฺ t Gu pfay
Successful connection: Username:
@ g den pfay
h t ica is Stu
Successful connection: Username: pfay
p a s
Successful connection: Username:
th
pfay
a
pr to us e
Successful connection: Username: pfay
( f
Successful connection: Username: pfay
h t ica nse
Successful connection: Username: pfay
p a s lice
Hit enter to end connections:
ra
ur P
$
m d. Examine the source code for the proxy_user program (see the appendix titled
Fla “Source Code”).
5. Using the terminal window, select the information from the data dictionary that shows the
users for whom HRAPP can proxy. Save this query; you will execute it again.
$ sqlplus sec
Enter password: *******
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced
Analytics and Real Application Testing options
SQL>
SQL> COL proxy FORMAT A6
SQL> COL client FORMAT A6
SQL> COL authentication FORMAT A12 WORD
FROM dba_proxies
WHERE proxy = 'HRAPP';
2 3 4 5 6
PROXY CLIENT AUTHENTICATI AUTHORIZATION_CONSTRAINT
------ ------ ------------ -----------------------------------
HRAPP PFAY NO PROXY MAY ACTIVATE ALL CLIENT ROLES
a ble
SQL>
f e r
6. Modify the PFAY user so that a password is required when connecting through a middle
ans
tier.
n - t r
SQL> ALTER USER pfay
a no
GRANT CONNECT THROUGH hrapp AUTHENTICATION REQUIRED;
h a s
2
m ) eฺ
o
User altered.
a ilฺc Guid
SQL> exit g m ent
$
t i c a@ Stud
a s h thwith
7. In the terminal window, run proxy_user is the following command:
r p se
aorcl
$ ./proxy_user
( f p t o u
pfay
This command a
tic connectsse PFAY without a password. Should this work? Why?
s h e
a Theliprogram
Answer: c n should not work because the PFAY user now requires a password
r a p
u r P to$connect.
m ./proxy_user orcl pfay
Fla Database: orcl
Username: pfay
Password:
Successful connection: Username: HRAPP
Error - ORA-28183: proper authentication not provided by proxy
Error - OCI_INVALID_HANDLE
Error - ORA-28183: proper authentication not provided by proxy
Error - OCI_INVALID_HANDLE
Error - ORA-28183: proper authentication not provided by proxy
Error - OCI_INVALID_HANDLE
Error - ORA-28183: proper authentication not provided by proxy
Error - OCI_INVALID_HANDLE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Error - OCI_INVALID_HANDLE
Error - ORA-28183: proper authentication not provided by proxy
Error - OCI_INVALID_HANDLE
Error - ORA-28183: proper authentication not provided by proxy
a ble
f e r
Error - OCI_INVALID_HANDLE
ans
Error - ORA-28183: proper authentication not provided by proxy
n - t r
a no
Error - OCI_INVALID_HANDLE
h a s
Error - ORA-28183: proper authenticationm ) provided
not
e ฺ by proxy
o
a ilฺc Guid
Error - OCI_INVALID_HANDLE
g m ent
Hit enter to end connections:
t i c a@ Stud
$
a s h this
8. Run proxy_user with rthe
f p apfollowing
u s ecommand line:
a
$ ./proxy_user( orclto pfay oracle_4U
h i c
t connectsn se PFAY with a password. Should this work? Why?
s
This command
pa Theliprogram
c e
P r a
Answer: should work because the PFAY user now connects with a
r password.
mu
Fla $ ./proxy_user orcl pfay oracle_4U
Database: orcl
Username: pfay
Password: oracle_4U
Successful connection: Username: HRAPP
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
a ble
f e r
With the Partitioning, Oracle Label Security, OLAP, Advanced
ans
Analytics and Real Application Testing options
n - t r
o
SQL>
s an
SQL>COL proxy FORMAT A6
) ha
SQL>COL client FORMAT A6
c o m ideฺ
SQL>COL authentication FORMAT A12aiWORD lฺ Gu
SQL> g m e n t
SQL>SELECT proxy,
t i c a@ Stud
client,a s h this
f p r ap use
authentication,
a ( authorization_constraint
to
i c
t dba_proxies
hFROM ns e
a s c e
li proxy = 'HRAPP';
rap WHERE
ur P 2 3 4 5 6
SQL>
10. Change the PFAY user so that he or she can no longer connect through the middle tier.
SQL> ALTER USER pfay REVOKE CONNECT THROUGH hrapp;
User altered.
SQL> exit
$
Database: orcl
Username: pfay
Password: oracle_4U
Successful connection: Username: HRAPP
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
a ble
f e r
Successful connection: Username: pfay
ans
Successful connection: Username: pfay
n - t r
Successful connection: Username: pfay
a no
Successful connection: Username: pfay
h a s
Successful connection: Username: pfay
m ) eฺ
o
Successful connection: Username: pfay
a ilฺc Guid
Successful connection: Username: pfay
g m ent
Hit enter to end connections:
t i c a@ Stud
sh command is line: ./proxy_user orcl pfay
$
12. Run proxy_user with thep a
following t h
f p r a use
a (
This command connects o
without
t a password. Should this work? Why?
s h tic should
The program
e n snote work because the PFAY user requires a password to connect.
r a pathat thelierror
Note c message is different from the message in step 7. Users do not
require the CONNECT THROUGH privilege if they connect with a username and password.
u r P $ ./proxy_user orcl pfay
m
Fla Database: orcl
Username: pfay
Password:
Successful connection: Username: HRAPP
Error - ORA-01017: invalid username/password; logon denied
Error - OCI_INVALID_HANDLE
Error - ORA-01017: invalid username/password; logon denied
Error - OCI_INVALID_HANDLE
Error - ORA-01017: invalid username/password; logon denied
Error - OCI_INVALID_HANDLE
Error - ORA-01017: invalid username/password; logon denied
Error - OCI_INVALID_HANDLE
Error - ORA-01017: invalid username/password; logon denied
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Error - OCI_INVALID_HANDLE
Error - ORA-01017: invalid username/password; logon denied
Error - OCI_INVALID_HANDLE
Error - ORA-01017: invalid username/password; logon denied
a ble
Error - OCI_INVALID_HANDLE
f e r
Error - ORA-01017: invalid username/password; logon denied
ans
n - t r
Error - OCI_INVALID_HANDLE
a no
Error - ORA-01017: invalid username/password; logon denied
h a s
m ) eฺ
o
Error - OCI_INVALID_HANDLE
a ilฺc Guid
Hit enter to end connections: m
g e n t
$
t i c a@ Stud
a h the proxy
13. Display the audited connectionssas
t h is user. The HOST and PORT information will
vary, however the outputa
r p bessimilar.
should e
f p
$ sqlplus /( AS SYSDBAto u
i c a e
a s ht cens
r a pConnectedli to:
u r P Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
m 64bit Production
Fla With the Partitioning, Oracle Label Security, OLAP, Advanced
Analytics and Real Application Testing options
SQL> COL dbusername FORMAT A10
SQL> COL dbproxy_username FORMAT A10
SQL> COL return_code FORMAT 999999
SQL> SELECT DISTINCT dbusername, dbproxy_username, return_code,
authentication_type
FROM unified_audit_trail
WHERE dbproxy_username='HRAPP';
2 3 4
DBUSERNAME DBPROXY_US RETURN_CODE
---------- ---------- -----------
AUTHENTICATION_TYPE
----------------------------------------------------------------
-
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
ur P
ADDRESS=((ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=
m 43157))));
Fla
… rows deleted
SQL> EXIT
$
Overview
In this practice, the security officer manages the DBA role privileges in the non-CDB and in the
PDBs of the CDB.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Investigate the number of privileges of the DBA in the non-CDB.
a. Use the oraenv utility to set the ORACLE_SID environment variable to the orcl value.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is
a ble
/u01/app/oracle
f e r
$
ans
n - t r
b.
no
Connect as SYSTEM in the orcl instance. Note the number of rows may vary based on
the database version and patches applied. a
h a s
$ sqlplus system
m ) eฺ
o
Enter password: ****** a ilฺc Guid
g m ent
Connected to:
t i c a@ Stud
Oracle Database 12c a s h this Edition Release 12.1.0.2.0 -
Enterprise
64bit Production
f p r ap use
With the a ( to Oracle Label Security, OLAP, Advanced
Partitioning,
i c
ht cand
Analytics e
nsReal Application Testing options
a s li e
r ap
ur P
SQL> SELECT * FROM session_roles ORDER BY 1;
m
Fla ROLE
----------------------------------------------------------------
-
AQ_ADMINISTRATOR_ROLE
CAPTURE_ADMIN
DATAPUMP_EXP_FULL_DATABASE
DATAPUMP_IMP_FULL_DATABASE
DBA
DELETE_CATALOG_ROLE
EM_EXPRESS_ALL
EM_EXPRESS_BASIC
EXECUTE_CATALOG_ROLE
EXP_FULL_DATABASE
GATHER_SYSTEM_STATISTICS
OLAP_DBA
OLAP_XS_ADMIN
OPTIMIZER_PROCESSING_RATE
SCHEDULER_ADMIN
SELECT_CATALOG_ROLE
WM_ADMIN_ROLE
XDBADMIN
a ble
XDB_SET_INVOKER
f e r
XS_RESOURCE
ans
n - t r
o
25 rows selected.
s an
SQL> SELECT * FROM session_privs ORDER BY )
ha
c o m ideฺ
1;
m ailฺ t Gu
PRIVILEGE
@ g den
h t icaSETis Stu
----------------------------------------
ADMINISTER ANY SQL TUNING
p a sTRIGGERth
ADMINISTER DATABASE
f p r a use
ADMINISTER (RESOURCEo MANAGER
i c e t
a SQLsMANAGEMENT
h t
ADMINISTER
s e n OBJECT
a
apADMINISTER lic SQL TUNING SET
r
ur P
ADVISOR
m … rows deleted
Fla UNLIMITED TABLESPACE
UPDATE ANY CUBE
UPDATE ANY CUBE BUILD PROCESS
UPDATE ANY CUBE DIMENSION
UPDATE ANY TABLE
USE ANY SQL TRANSLATION PROFILE
SQL>
Notice that the SYSTEM user is not granted the SYSDBA privilege.
no rows selected
PRIVILEGE
----------------------------------------
ADMINISTER ANY SQL TUNING SET
a ble
ADMINISTER DATABASE TRIGGER
f e r
… rows deleted
ans
SYSDBA
n - t r
o
SYSOPER
s an
TRANSLATE ANY SQL
) ha
UNDER ANY TABLE
c o m ideฺ
UNDER ANY TYPE
m ailฺ t Gu
UNDER ANY VIEW
@ g den
UNLIMITED TABLESPACE
h t ica is Stu
UPDATE ANY CUBE
p a s th
a
pr to us
UPDATE ANY CUBE BUILD PROCESS e
( f
ica nse
UPDATE ANY CUBE DIMENSION
h t
UPDATE ANY TABLE
s lice
a p a
USE ANY SQL TRANSLATION PROFILE
r
m ur P
Fla
234 rows selected.
SQL> EXIT
$
2. Now investigate if there are distinct DBAs for the root container and in the pdb1 and pdb2
containers in the dbsec instance.
a. Use the oraenv utility to set the ORACLE_SID environment variable to the dbsec
value.
$ . oraenv
ORACLE_SID = [orcl] ? dbsec
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is
/u01/app/oracle
$
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
a ble
SQL> col role format a30
f e r
SQL> SELECT role, common, con_id FROM cdb_roles
ans
WHERE role like '%DBA%' ORDER BY 1, 3;
n - t r
n o
CON_ID s a
ha
ROLE COM
)
m 1ideฺ
------------------------------ --- ----------
YES lฺco
CDB_DBA
YESa
i G u3
CDB_DBA m t
gYES den 4
@ tu
ica is S
CDB_DBA
DBA
s h t YES 1
a
p se t YES h
DBA
r a 3
DBA
a (fp to u YES 4
s h tic ense
LBAC_DBA YES 1
apa
LBAC_DBA lic YES 3
r
ur P
LBAC_DBA YES 4
m OLAP_DBA YES 1
Fla OLAP_DBA YES 3
18 rows selected.
a ble
USERNAME CON_ID
f e r
-------------- ----------
ans
n - t r
no
SYSTEM 1
SYSTEM 3
s a
SYSTEM 4 h
) eฺa
o m
3 rows selected. a ilฺc Guid
SQL> g m ent
There are as many DBAs as containers:t i c a@ S
one for tudroot container and one DBA for each
the
PDB, except PDB$SEED. ash h is
p to create
aDBA t
e a junior DBA to whom you grant the local
c. Connect as the pdb1
( f p r u s
PDB_DBA role.
i c a e to
s
SQL> t ensystem@pdb1
hCONNECT s
a a li c
pEnter password:
P r ******
u r Connected.
l a m SQL> COL grantee FORMAT A16
F SQL> COL privilege FORMAT A26
SQL> SELECT * FROM dba_sys_privs WHERE grantee='PDB_DBA'
ORDER BY 1,2;
3 rows selected.
2 3
Grant succeeded.
Grant succeeded.
a ble
SQL> CONNECT dba_junior@pdb1
f e r
Enter password: ******
ans
Connected.
n - t r
o
SQL> SELECT * FROM session_privs ORDER BY 1;
s an
) ha
PRIVILEGE
c o m ideฺ
--------------------------
m ailฺ t Gu
CREATE ANY TABLE
CREATE PLUGGABLE DATABASE a@
g den
h t ic is Stu
CREATE ROLE
CREATE SESSION apa
s th
pr to us e
( f
CREATE TABLESPACE
ca nse
CREATEtiUSER
h
p a
SET sCONTAINER
l i c e
r a
m ur P 7 rows selected.
Fla
SQL>
d. Connect as the pdb2 DBA to create a junior DBA to whom you grant the local
PDB_DBA role with different privileges.
SQL> CONNECT system@pdb2
Enter password: ******
Connected.
SQL> CREATE USER dba_junior IDENTIFIED BY oracle_4U;
User created.
Grant succeeded.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
PRIVILEGE
a ble
--------------------------
f e r
CREATE PLUGGABLE DATABASE
ans
CREATE ROLE
n - t r
o
CREATE SESSION
s an
CREATE TABLESPACE
) ha
CREATE USER
c o m ideฺ
SET CONTAINER
m ailฺ t Gu
@ g den
6 rows selected.
h t ica is Stu
p a s th
SQL> EXIT a
pr to us e
$ ( f
h t ica nse
p a s lice
ra
mur P
Fla
Overview
In this practice, you manage the password file with the new 12 format dedicated to new
administrative privileges like SYSBACKUP.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Make sure you are in the ~/labs/PRIV directory and your environment points to the orcl
instance.
$ cd ~/labs/PRIV
$ . oraenv
ORACLE_SID = [dbsec] ? orcl
The Oracle base for
a ble
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is f e r
ans
/u01/app/oracle
n - t r
no
$
2. Run the SYSBACKUP_setup.sh script to recreate the password file.
s a
$ ./SYSBACKUP_setup.sh h
) eฺa
o m
$
a i lฺc Guid
g m and
3. Connect with OS authentication with AS SYSBACKUP
e n tcheck the user connected.
$ sqlplus / as sysbackup a@
t i c S tud
a s h this
Connected to: ap e
f p r u s
i c a ( se12cto Enterprise Edition Release 12.1.0.2.0 -
Oracle Database
64bit tProduction
p a
Withshthe liPartitioning,
c en Oracle Label Security, OLAP, Advanced
r a Analytics and Real Application Testing options
u rP
m
Fla SQL> show user
USER is "SYSBACKUP"
SQL>
4. List the privileges granted to the SYSBACKUP user. Only a few privileges are granted to the
SYSBACKUP user. The SYSBACKUP privilege is granted to the SYSBACKUP user.
SQL> set pages 22
SQL> select * from session_privs order by 1;
PRIVILEGE
----------------------------------------
ALTER DATABASE
ALTER SESSION
ALTER SYSTEM
ALTER TABLESPACE
RESUMABLE
SELECT ANY DICTIONARY
SELECT ANY TRANSACTION
SYSBACKUP
UNLIMITED TABLESPACE
14 rows selected.
a ble
f e r
SQL>
a n s
r
-t more
5. Connect AS SYSDBA and list the privileges granted to the SYS user. There arenmuch
privileges granted to the SYS user. n o
s a
SQL> connect / as sysdba
) ha
Connected.
c o m1; ideฺ
ailฺ t Gu
SQL> select * from session_privs ORDER BY
m
g den
@
ica is Stu
PRIVILEGE
s h t
----------------------------------------
ADMINISTER ANY a p
SQLaTUNING e h
tSET
f pr to TRIGGER
ADMINISTER (DATABASE us
h t ica KEY
ADMINISTER
n e
sMANAGEMENT
a s
pADMINISTER e
lic RESOURCE MANAGER
r a
ur P
ADMINISTER SQL MANAGEMENT OBJECT
m rows deleted …
Fla UPDATE ANY CUBE BUILD PROCESS
UPDATE ANY CUBE DIMENSION
UPDATE ANY TABLE
USE ANY SQL TRANSLATION PROFILE
SQL>
SQL>
7. Create a new user JOHN that will be granted the SYSBACKUP privilege in order to perform
a ble
backup, restore, and recover operations, and hence act as the SYSBACKUP user.
f e r
SQL> CREATE USER john IDENTIFIED BY oracle_4U;
ans
n - t r
User created. a no
h a s
SQL> GRANT create session, sysbackup TO m ) eฺ
GRANT create session, sysbackup TO ijohn
o john;
lฺc Guid
a
m ent
* g
ERROR at line 1:
t i c a@ Stud
ORA-28017: The password
a s h file t h isis in the legacy format.
f p r ap use
a ( to
i c
t ens
SQL> hEXIT e
a s lic
P r ap$
u r8.Because the password file had been created in legacy format, not compatible with the
m SYSBACKUP entry, it does not accept any SYSBACKUP entry.
Fla a. Recreate the file in 12 format, compatible with the SYSBACKUP entry.
$ cd $ORACLE_HOME/dbs
$ rm orapworcl
$ orapwd file=orapworcl password=oracle_4U entries=10 format=12
$
b. Finally register JOHN in the password file.
$ sqlplus / as sysdba
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced
Analytics and Real Application Testing options
Grant succeeded.
SQL>
c. Attempt a remote connection in SQL*Plus. a ble
f e r
SQL> connect john@orcl as SYSBACKUP
ans
Enter password: ******
n - t r
Connected.
a no
SQL> SHOW USER
h a s
USER is "SYSBACKUP" m ) eฺ
o
SQL> EXIT
a ilฺc Guid
$ g m ent
d. Test the remote connection in RMAN.
t i c a@ Stud
a s h this
$ rman target john/oracle_4U@orcl
f p r ap use
Recovery a ( o
tRelease
t i c Manager:
s e 12.1.0.2.0 - Production on Mon Nov 26
p a sh licen
06:28:43 2012
SYSBACKUP
RMAN> exit
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Overview
This practice depends on Practice 4-1 for users and roles. It assumes that the SEC user has
been created and granted certain privileges, and that the PFAY and HRAPP users have also
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. As the SEC user, create the HR_EMP_CLERK and HR_EMP_MGR roles. If you need to create
the SEC user, use the /home/oracle/labs/USERS/create_sec.sh shell script.
$ sqlplus sec
Enter password: ******
a ble
Connected to:
f e r
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
ans
64bit Production
n - t r
o
an
With the Partitioning, Oracle Label Security, OLAP, Advanced
s
ha
Analytics and Real Application Testing options
)
m ideฺ
c o
ailฺ t Gu
SQL> CREATE ROLE hr_emp_clerk;
m
g den
Role created.
@
h t ica is Stu
a s
SQL> CREATE ROLE hr_emp_mgr;
p th
a
pr to us e
( f
ica nse
Role created.
h t
s lice
a p a
SQL>
r
mur P
Fla SQL> GRANT hr_emp_clerk, hr_emp_mgr TO pfay;
Grant succeeded.
SQL>
2. Give PFAY the ability to enable the HR_EMP_CLERK role through the HRAPP middle tier.
SQL> ALTER USER pfay
GRANT CONNECT THROUGH hrapp
WITH ROLE hr_emp_clerk;
2 3
User altered.
SQL> EXIT
$
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Pra
Username:
r
mu
Password:
Fla
Successful connection: Username: HRAPP
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Successful connection: Username: pfay
Role successfully enabled: hr_emp_clerk
Successful connection: Username: pfay
Role successfully enabled: hr_emp_clerk
Successful connection: Username: pfay
Successful connection: Username: pfay
Role successfully enabled: hr_emp_clerk
Role successfully enabled: hr_emp_clerk
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
p a s
Successful connection: Username: pfay
th
a
pr to us e
Successful connection: Username: pfay
( f
ica nse
Successful connection: Username: pfay
h t
Successful connection: Username: pfay
s lice
a p a
Successful connection: Username: pfay
r
ur P
Error - ORA-01924: role 'HR_EMP_MGR' not granted or does not
m exist
Fla
Successful connection: Username: pfay
Successful connection: Username: pfay
Error - ORA-01924: role 'HR_EMP_MGR' not granted or does not
exist
r a pSQL> li
u r P SQL> COL proxy FORMAT A6
m
Fla
SQL> COL client FORMAT A6
SQL> COL authentication FORMAT A12 WORD
SQL>
SQL> SELECT proxy,
client,
authentication,
authorization_constraint
FROM dba_proxies
WHERE proxy = 'HRAPP';
SQL>
Enter the name of your database in the form of orcl. Remember that the password for SEC
is oracle_4sec.
SQL> @/home/oracle/labs/PRIV/tab_app_roles.sql
SQL> CONNECT sec@orcl
Enter password: ******
Connected.
SQL>
a ble
SQL> ALTER USER sec DEFAULT TABLESPACE example QUOTA UNLIMITED
f e r
ON example;
ans
n - t r
User altered.
a no
h a s
SQL>
m ) eฺ
o
lฺc Guid
SQL> DROP TABLE app_roles;
a i
DROP TABLE app_roles
g m ent
*
t i c a@ Stud
ERROR at line 1:
a h this
sview
ORA-00942: table p e
r a or
s does not exist
a (fp to u
h ticKEY,eTABLE
SQL> CREATE
s n se app_roles (id NUMBER CONSTRAINT app_roles_pk
apausernamelic VARCHAR2(30)NOT NULL, role VARCHAR2(30), ip_address
PRIMARY
r
ur P VARCHAR2(15),
Table created.
1 row created.
SQL> COMMIT;
Commit complete.
7. As the SEC user, drop the HR_EMP_MGR role.
SQL>
Role dropped.
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Role created.
a ble
SQL> f e r
ans
9. Review the application code. How does it verify that the role can be enabled? Execute the
application code. n - t r
o
set echo on
s an
DROP PACKAGE app_roles_pkg;
) ha
c o m ideฺ
CREATE OR REPLACE PACKAGE app_roles_pkg
m ailฺ t Gu
AUTHID CURRENT_USER
@ g den
IS
h t ica is Stu
PROCEDURE set_role
p a s ( th
p_role_name
p r aVARCHAR2
u s e);
a ( f to
END;
/ sht
i c ns e
a li c e
rap
ur P CREATE OR REPLACE PACKAGE BODY app_roles_pkg IS
SQL>
a ble
f e r
SQL> CREATE OR REPLACE PACKAGE app_roles_pkg
ans
AUTHID CURRENT_USER
n - t r
o
an
IS
PROCEDURE set_role (
ha s
p_role_name VARCHAR2 ); )
m ideฺ
c o
ailฺ t Gu
END;
/ m
g den
@
ica is Stu
2 3 4 5 6 7
s h t
Package created. pa
a e th
( f pr to us
SQL> tica se
a s h c e n
a
SQL>
p l i
CREATE OR REPLACE PACKAGE BODY app_roles_pkg IS
r
ur P
PROCEDURE set_role (
m p_role_name VARCHAR2 )
Fla AS
v_id app_roles.id%TYPE;
BEGIN
SELECT id
INTO v_id
FROM sec.app_roles
WHERE username =
sys_context('userenv','current_user')
AND role = p_role_name
AND ip_address = sys_context('userenv','ip_address');
dbms_session.set_role(p_role_name);
END;
END;
/
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
10. As the SEC user, allow anyone to execute the SEC.APP_ROLES_PKG package and select
from the SEC.APP_ROLES table. The user needs read access to the table because the
package runs by using the privileges of the current user. What security problems does this
create, and how can they be resolved?
SQL> GRANT execute ON app_roles_pkg TO public;
Grant succeeded.
a ble
f e r
SQL> GRANT select ON app_roles TO public;
ans
n - t r
Grant succeeded.
a no
h a s
SQL>
m ) eฺ
11. Allowing anyone to execute the SEC.APP_ROLES_PKG o
ฺcpackage id not create any
uthedoes
security problems because the appropriate rowm ailappear
must t G
in APP_ROLES table
before a role can be enabled. Giving read@ g
access to d e n
SEC.APP_ROLES allows any user to
i
see which users can enable which trolesc afrom aS tu If this is determined to be a security
client.
a h only
risk, you can create a view thatsshows
t h isthose rows that are related to the current user.
The view would includerthe
f p apfollowing
u s epredicate:
a
WHERE username ( = sys_context('userenv','current_user')
to
i c e
ht cethenfollowing
Test by performing s steps:
a. p a s
Connect asliPFAY through the listener (you must use a service name orcl). Be sure to
r a
u rP use your instance name instead of orcl.
m b. Query SESSION_ROLES to see which roles are enabled.
Fla c. Use the SEC.APP_ROLES_PKG package to enable the role.
d. Query SESSION_ROLES to see which roles are enabled.
Note: The HR_EMP_CLERK role that is enabled after the initial connection is from a
previous step.
SQL> CONNECT pfay@orcl
Enter password: ******
Connected.
SQL>
SQL> SELECT * FROM session_roles;
ROLE
------------------------------
HR_EMP_CLERK
SQL>
SQL> SELECT * FROM session_roles;
ROLE
------------------------------
HR_EMP_MGR
a ble
SQL>
f e r
12. What do you expect will happen if, as the PFAY user, you try to enable the HR_EMP_MGR
ans
role by using the SET ROLE command? Try it.
n - t r
no
Answer: It should return an error because it is a secure application role.
a
SQL> SET ROLE hr_emp_mgr;
h a s
SET ROLE hr_emp_mgr m ) eฺ
o
*
a ilฺc Guid
ERROR at line 1: g m ent
ORA-28201: Not enough privileges
t i c udenable application role
a@ Stto
'HR_EMP_MGR'
a s h this
f p r ap use
SQL>
a ( to
i c
ht cens e
a s li
rap
mur P
Fla
Overview
In this practice, you will learn how to enable database roles at run time, enabling the procedure
unit to execute with the required privileges in the calling user's environment. This is called Code
Based Access Control (CBAC).
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Before testing the CBAC feature, execute the CBAC_priv.sql script. This script creates
the end user U1, the schema APP, and the APP.T1 table.
SQL> CONNECT / as sysdba
Connected.
SQL> @/home/oracle/labs/ROLES/CBAC_priv.sql
a ble
SQL> drop user u1 cascade;
f e r
drop user u1 cascade
ans
n - t r
no
*
ERROR at line 1:
s a
ORA-01918: user 'U1' does not exist h a
) eฺ
o m
SQL> drop user app cascade; a ilฺc Guid
drop user app cascade g m ent
*
t i c a@ Stud
ERROR at line 1:
a s h this
r p does
a'APP' s e not exist
ORA-01918: user
( f p to u
i c a e
SQL> ht ns
a s c e
li user u1 identified by oracle_4U default tablespace
rapSQL> create
ur P
users;
m
Fla User created.
Grant succeeded.
User created.
Grant succeeded.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Table created.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
1 row created.
SQL>
SQL> commit;
a ble
Commit complete.
f e r
ans
SQL>
n - t r
SQL>
a no
a s IVPROC and a
2. The APP schema creates two procedures: an invoker’s right procedure,
h
definer’s right procedure, DFPROC. m ) eฺ
o
ilฺc Guid
a. Create the two procedures using the following codes:
a
CREATE OR REPLACE PROCEDURE app.ivproc g m en(CODEt in varchar2)
@ d
AUTHID CURRENT_USER AS
h t ica is Stu
v_code number;
p a s th
BEGIN a
pr v_code e
us FROM app.t1;
SELECT code(fINTO t o
h t ica nse
dbms_output.put_line('Code is: '||v_code);
a s
pEND ivproc; li c e
r a
u rP /
m
Fla
SQL> CONNECT app
Enter password: ******
Connected.
v_code number;
BEGIN
SELECT code INTO v_code FROM app.t1;
dbms_output.put_line('Code is from Definer right procedure:
'||v_code);
END dfproc;
/
a ble
SQL> CREATE OR REPLACE PROCEDURE app.dfproc (CODE in varchar2)
f e r
AS
ans
v_code number;
n - t r
BEGIN
a no
SELECT code INTO v_code FROM app.t1;
h a s
m ) eฺ
dbms_output.put_line('Code is from Definer right procedure:
o
'||v_code);
a ilฺc Guid
END dfproc;
g m ent
/
t i c a@ Stud
2 3 4 5 6
a s h this
7 8
Procedure created.
f p r ap use
( to
SQL> tica e
a s h cens
3. You p
r a li role. Grant SELECT on APP.T1 to the role. Create ROLE2. Grant
create the ROLE1
ur P
SELECT on SH.SALES to the role and grant the role directly to the end user U1.
m
Fla
SQL> CONNECT / as sysdba
Connected.
Role created.
Grant succeeded.
Role created.
Grant succeeded.
Grant succeeded.
SQL>
4. Grant the ROLE1 role to the invoker’s right procedure IVPROC and to the definer’s right
procedure, DFPROC.
SQL> CONNECT app
a ble
Enter password: ******
f e r
Connected.
ans
SQL> GRANT role1 TO PROCEDURE app.ivproc; n - t r
GRANT role1 TO PROCEDURE app.ivproc a no
*
h a s
m ) eฺ
ERROR at line 1:
o
a ilฺc Guid
ORA-01924: role 'ROLE1' not granted or does not exist
g m ent
SQL>
t i c a@ Stud
5. Because the CBAC roles canabe s hgrantedthonly
is to a program unit when the role is directly
r
granted to the procedures’
f p apowner,ugrant
s e the ROLE1 role to the APP procedures’ owner.
a ( / as tsysdba
o
c
SQL> CONNECT
i
ht cens e
a s
Connected.
pSQL> GRANTli role1 TO app WITH ADMIN OPTION;
r a
mur P
Fla Grant succeeded.
SQL>
6. Now grant the role to the procedural units.
SQL> CONNECT app
Enter password: ******
Connected.
SQL> GRANT role1 TO PROCEDURE app.ivproc, PROCEDURE app.dfproc ;
Grant succeeded.
SQL>
Grant succeeded.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Grant succeeded.
SQL>
8. Connect as U1 and test how the CBAC enables roles at run time.
a. Test the app.ivproc procedure.
a ble
f e r
SQL> CONNECT u1
ans
Enter password: ******
n - t r
Connected.
a no
SQL> SELECT * FROM session_roles;
h a s
m ) eฺ
o
ROLE
a ilฺc Guid
m ent
----------------------------------------------------------------
g
a@ Stud
-
ROLE2 t i c
h this
a s
f
SQL> SET SERVEROUTPUT p r ap uON s e
a ( to
SQL> EXEC
i c
hist from e
app.ivproc(1)
s
nInvoker
Code
p a s l i c e right procedure: 1
ra
ur P PL/SQL procedure successfully completed.
F lam
SQL> SELECT * FROM session_roles;
ROLE
----------------------------------------------------------------
-
ROLE2
SQL>
Notice that the active role at login time is ROLE2 only.
ROLE
----------------------------------------------------------------
ROLE2
SQL>
a ble
f e r
Notice that the execution completes as in 8.a.
ans
c. Drop ROLE1 and retest.
n - t r
o
SQL> CONNECT system
s an
Enter password: ******
) ha
Connected.
c o m ideฺ
ailฺ t Gu
SQL> DROP ROLE role1;
m
g den
@
Role dropped.
h t ica is Stu
SQL> CONNECT u1apa
s th
pr ******us e
Enter password: ( f t o
h t ica nse
Connected.
p a
SQL>s SELECT
l i c e* FROM session_roles;
r a
m ur P ROLE
Fla ----------------------------------------------------------------
-
ROLE2
*
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at "APP.IVPROC", line 5
ORA-06512: at line 1
SQL>
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Overview
In this practice, you use the new INHERIT PRIVILEGES privilege when creating invoker’s
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
rights procedures. This practice assumes you have completed Practice 4-5. Related scripts
are in /home/oracle/labs/PRIV.
Tasks
1. Connected as SYSTEM, execute the inherit_priv.sql script to create the U1, U2, and
KATE users and the U2.T1 table.
SQL> CONNECT system
Enter password: ******
a ble
Connected. f e r
SQL> @/home/oracle/labs/PRIV/inherit_priv.sql ans
n - t r
SQL> drop user u1 cascade;
o
s an
User dropped.
) ha
c o m ideฺ
SQL> drop user u2 cascade;
m ailฺ t Gu
drop user u2 cascade
@ g den
*
h t ica is Stu
ERROR at line 1: as h
a p e tnot
ORA-01918: user
( f pr to us
'U2' does exist
h t ica nse
p a s lice
ra SQL> drop user kate;
F lam *
ERROR at line 1:
ORA-01918: user 'KATE' does not exist
User created.
Grant succeeded.
User created.
Grant succeeded.
F lam
SQL> commit;
Commit complete.
Grant succeeded.
Grant succeeded.
SQL>
SQL>
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Fla SQL>
c. Execute the procedure to test that it works successfully.
SQL> set serveroutput on
SQL> exec U1.PROC2('Code')
Code is: 1
SQL>
Grant succeeded.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
SQL>
3. KATE wants to test the procedure.
a. KATE has no privilege on the U2.T1 table. KATE connects and executes the
procedure.
SQL> CONNECT kate
Enter password: ******
Connected.
a ble
SQL> set serveroutput on
f e r
SQL> exec U1.PROC2('Code')
ans
n - t r
no
BEGIN U1.PROC2('Code'); END;
s a
* h
) eฺ a
ERROR at line 1:
o m
ORA-06598: insufficient INHERIT PRIVILEGES a uid
ilฺc Gprivilege
ORA-06512: at "U1.PROC2", linegm 1 e n t
ORA-06512: at line 1
t i c a@ Stud
a s h this
SQL>
f p r ap use
b. KATE grants a (
the INHERIT to PRIVILEGES on user KATE to procedure owner U1 thus
i c
htU1 tocinherit e
ns her privileges during the execution of the procedure
a s
allowing
pSQL> grant e
li INHERIT PRIVILEGES ON USER kate TO U1;
r a
mur P
Fla Grant succeeded.
SQL>
c. KATE re-executes the procedure.
SQL> exec U1.PROC2('Code')
Code is: 1
SQL>
a s ht cens
r a li
pUser created.
u r P SQL>
m
Fla b. Check the privileges granted to NEWUSER.
SQL> select PRIVILEGE, TYPE, TABLE_NAME, GRANTEE
from DBA_TAB_PRIVS
where grantor='NEWUSER';
2 3 4
SQL> EXIT
$
Overview
In this practice, you examine the different types of BEQUEATH views: the CURRENT_USER and
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
DEFINER views.
Assumption
The bequeath_setup.sql script is successfully completed.
Tasks
1. Make sure you are at the ~/labs/PRIV directory and your environment points to the orcl
instance. Connect under the SYSTEM user.
a ble
$ cd ~/labs/PRIV f e r
ans
$ . oraenv
n - t r
ORACLE_SID = [orcl] ? orcl
a no
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is h a s
/u01/app/oracle m ) eฺ
o
$
a ilฺc Guid
2. Execute the bequeath_setup.sql script. The g n t users and grants
mscriptecreates
appropriate privileges to the developer c d user KATE.
aU1@andSthetuend
t i
$ sqlplus SYSTEM ash h is
ap use t
f p r
( ******
c a
Enter password:
i e to
Lasts t ens login time: Mon Jun 17 2013 09:51:24 +00:00
hSuccessful
a p a lic
r
u r P Connected to:
m
Fla Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced
Analytics and Real Application Testing options
SQL>
SQL> @bequeath_setup.sql
Connected.
REVOKE select any table from OE
*
ERROR at line 1:
ORA-01952: system privileges not granted to 'OE'
User dropped.
User dropped.
User created.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Grant succeeded.
Revoke succeeded.
User created.
Grant succeeded.
a ble
f e r
SQL>
a n s
- t r
current user connected. n on the
3. The developer U1 creates a BEQUEATH CURRENT_USER view. The view displays
s a
a. The U1 user connects and creates the V_WHOAMI view. a
) h eฺ
SQL> CONNECT u1 m
co uid
i l ฺ
ma ent G
Enter password: ******
Connected. g
SQL> CREATE OR REPLACE VIEW
t i c S tud
[email protected]_whoami
a s h this
BEQUEATH CURRENT_USER
AS SELECTra p se
ORA_INVOKING_USER "WHOAMI" FROM DUAL;
3a ( f p o u
ic nse t
2
t
View hcreated.
s lice
p a
P ra SQL>
u r
m
Fla b. The developer checks that the V_WHOAMI view works successfully.
SQL> select * from U1.V_WHOAMI;
WHOAMI
---------------------------------------------------------
U1
SQL>
SQL>
b. The developer checks that the V_WHOAMI_DEF view works successfully.
SQL> select * from U1.V_WHOAMI_DEF;
a ble
f e r
WHOAMI ans
n - t r
---------------------------------------------------------
o
U1
s an
) ha
SQL>
c o m ideฺ
ailฺ ontboth
5. The developer U1 grants the SELECT privilege to KATE
m G uviews.
SQL> grant SELECT on U1.V_WHOAMI @ n
g todeKATE;
h t ica is Stu
Grant succeeded. pas th
a
pr to us e
( f
t ica SELECT
SQL> grant
h n s e on U1.V_WHOAMI_DEF to KATE;
p a s lice
P ra Grant succeeded.
u r
m
Fla SQL>
6. KATE connects and selects data from the BEQUEATH DEFINER view.
SQL> CONNECT kate
Enter password: ******
Connected.
SQL> select * from U1.V_WHOAMI_DEF;
WHOAMI
--------------------------------------------------------
KATE
SQL>
SQL>
8. KATE grants the INHERIT PRIVILEGES ON USER KATE to the view owner U1, allowing
U1 to use her privileges during the view execution.
SQL> grant INHERIT PRIVILEGES ON USER kate TO U1;
a ble
Grant succeeded. f e r
ans
n - t r
no
SQL>
9. a
KATE attempts the statement on the BEQUEATH CURRENT_USER view.
s
SQL> select * from U1.V_WHOAMI; h a
) eฺ
o m
a ilฺc Guid
WHOAMI
g m ent
t i c a@ Stud
----------------------------------------------------------
KATE
a s h this
SQL> EXIT f p r ap use
a ( to
$ i c
ht cens e
a s li
rap
mur P
Fla
Overview
In this practice, you will grant local and common privileges, create and grant local and common
roles in dbsec and in PDBs.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Create the common C##U1 user in the root container and the local LOCAL_EMPLOYEES
users in PDB1 and PDB2.
$ . oraenv
ORACLE_SID = [orcl] ? dbsec
a ble
The Oracle base for
f e r
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is
ans
/u01/app/oracle
n - t r
$ sqlplus / as sysdba
a no
h a s
Connected to:
m ) e12.1.0.2.0
Oracle Database 12c Enterprise Edition oRelease ฺ
c i d -
64bit Production
m ailฺ t Gu
g denAnalytics and Real
With the Partitioning, OLAP, Advanced
@
Application Testing options
h t ica is Stu
SQL> DROP USER a p as CASCADE;
e th
pr to us
C##U1
( f
t ica nse
User hdropped.
p a s lice
ra
ur P
SQL> CREATE USER C##U1 IDENTIFIED BY oracle_4U;
m
Fla User created.
Grant succeeded.
Session altered.
User dropped.
User created.
Grant succeeded.
Session altered.
a ble
SQL> DROP USER LOCAL_EMPLOYEE CASCADE;
f e r
ans
User dropped.
n - t r
a no
s
SQL> CREATE USER LOCAL_EMPLOYEE IDENTIFIED BY apass_pdb2;
h
m ) eฺ
o
User created.
a ilฺc Guid
g m ent
SQL> GRANT CREATE SESSION aTO
t i c S tud
@LOCAL_EMPLOYEE;
a s h this
Grant succeeded.
f p r ap use
SQL> tic
a ( se to
p a sh licen
P r a
u r2.List all predefined roles in the CDB root container.
m
Fla SQL> COL role FORMAT A30
SQL> SELECT role, common, con_id
FROM cdb_roles
ORDER BY role, con_id;
2 3
ROLE COM CON_ID
------------------------------ --- ----------
ADM_PARALLEL_EXECUTE_TASK YES 1
ADM_PARALLEL_EXECUTE_TASK YES 3
ADM_PARALLEL_EXECUTE_TASK YES 4
APEX_ADMINISTRATOR_ROLE YES 1
APEX_ADMINISTRATOR_ROLE YES 3
APEX_ADMINISTRATOR_ROLE YES 4
APEX_GRANTS_FOR_NEW_USERS_ROLE YES 1
CAPTURE_ADMIN YES 4
CDB_DBA YES 1
CDB_DBA YES 3
CDB_DBA YES 4
CONNECT YES 1
…
DBA YES 1
a ble
DBA YES 3
f e r
DBA YES 4
ans
…
n - t r
o
XS_RESOURCE
s an YES 1
XS_RESOURCE
) ha YES 3
XS_RESOURCE
c o m ideฺ YES 4
XS_SESSION_ADMIN
m ailฺ t Gu YES 1
XS_SESSION_ADMIN
@ g den YES 3
XS_SESSION_ADMIN
h t ica is Stu YES 4
p a s th
253 rows selected. a
pr to us e
( f
h t ica con_id,
SQL> select
n se name from v$pdbs;
s e
rapa lic
ur P
CON_ID NAME
m ---------- ------------------------------
Fla 2 PDB$SEED
3 PDB1
4 PDB2
The common role is replicated in each container. The container ID 1 is the root. It is not
listed in the V$PDBS view. The container ID 2 is the seed. The container ID 3 is the pdb1.
The container ID 4 is the pdb2.
2 3 4
ROLE COM
------------------------------ ---
ADM_PARALLEL_EXECUTE_TASK YES
APEX_ADMINISTRATOR_ROLE YES
APEX_GRANTS_FOR_NEW_USERS_ROLE YES
AQ_ADMINISTRATOR_ROLE YES
a ble
AQ_USER_ROLE YES
f e r
AUDIT_ADMIN YES
ans
AUDIT_VIEWER YES
n - t r
n o
…
s a
CDB_DBA YES
) ha
CONNECT YES
c o m ideฺ
…
m ailฺ t Gu
DBA
@ g den
YES
…
t tu
ica is SYES
XS_RESOURCE
a s h th YES
a p e
pr to us
XS_SESSION_ADMIN
(
a se f
h t icselected.
p a s licen
84 rows
ra
ur P
SQL>
m
Fla
Notice that all roles of the root are common: there cannot be any local roles in the root.
4. List all local roles in PDBs.
SQL> SELECT role, con_id
FROM cdb_roles
WHERE common = 'NO' ;
2
ROLE CON_ID
------------------------------------------------ ----------
HR_MGR 3
SQL>
Role created.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
SQL>
6. Attempt to create a LOCAL_ROLE local role in root.
SQL> CREATE ROLE local_role CONTAINER=CURRENT;
CREATE ROLE local_role CONTAINER=CURRENT
*
ERROR at line 1:
ORA-65049: creation of local user or role is not allowed in
a ble
CDB$ROOT
f e r
ans
SQL> n - t r
o
an
You get an error message because no local role is authorized in root.
s
7. Create a common role in pdb2.
) ha
c o m ideฺ
ailฺ t Gu
SQL> CONNECT system@pdb2
Enter password: ******
m
g den
Connected. @ tu
SQL> CREATE ROLE c##_role_PDB2
h t ica is S container=ALL;
p a
create role c##_role_PDB2 s h
tcontainer=ALL
a
pr to us e
*
( f
t
ERROR at
h icalinens1:e
a s liceCommon DDLs only allowed in CDB$ROOT
ORA-65050:
p
P ra
r
mu SQL>
Fla You get an error message because no common role can be created from a PDB.
8. Create a local role in pdb2.
SQL> CREATE ROLE local_role_PDB2 container=CURRENT;
Role created.
ROLE COM
------------------------------ ---
ADM_PARALLEL_EXECUTE_TASK YES
APEX_ADMINISTRATOR_ROLE YES
…
C##_ROLE YES
LBAC_DBA YES
LOCAL_ROLE_PDB2 NO
…
PDB_DBA YES
…
XS_RESOURCE YES
XS_SESSION_ADMIN YES
a ble
f e r
86 rows selected.
ans
n - t r
SQL> n o
s a
9. Grant common or local roles as common or local.
ha
a. Grant a common role to a common user from root. m) e ฺ
c o i d
SQL> CONNECT / AS SYSDBA
m ailฺ t Gu
Connected.
@ g den
SQL> GRANT c##_role TO c##u1;
h t ica is Stu
p a s th
Grant succeeded. a
pr to us e
( f
h t icagrantee
n se FORMAT A16
s
SQL>
pSQL>
COL
e
a COL ligranted_role
c
P r a FORMAT A18
Fla
FROM cdb_role_privs
WHERE grantee='C##U1';
2 3
GRANTEE GRANTED_ROLE COM CON_ID
---------------- ------------------ --- ----------
C##U1 C##_ROLE NO 1
SQL>
Note that the common role is granted locally to the common user. The granted role is only
applicable in root.
SQL> connect c##u1
Enter password: ******
Connected.
SQL> select * from session_roles;
ROLE
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Connected.
SQL> select * from session_roles;
no rows selected
SQL>
b. Now grant the common role to a common user from the root as common, to be
applicable in all containers. a ble
f e r
SQL> connect / as sysdba
ans
Connected.
n - t r
o
SQL> grant c##_role to c##u1 container=all;
s an
) ha
Grant succeeded.
c o m ideฺ
m ailฺ t Gu
SQL>
@ g den
h t i ca s Stu
SQL> col grantee format
p a s A16thi
SQL> col GRANTED_ROLE
p r a uformat
s e A18
SQL> select a f
( GRANTEE,to GRANTED_ROLE, COMMON, CON_ID
i c
t cdb_role_privs
hfrom ns e
a s li c e where grantee='C##U1';
r ap 2
mur P GRANTEE GRANTED_ROLE COM CON_ID
Fla
---------------- ---------------- --- ----------
C##U1 C##_ROLE NO 1
C##U1 C##_ROLE YES 1
C##U1 C##_ROLE YES 4
C##U1 C##_ROLE YES 3
ROLE
------------------------------
C##_ROLE
ROLE
------------------------------
C##_ROLE
SQL>
10. Revoke the common role from the common user so that the role cannot be used in any
container.
a ble
SQL> connect / as sysdba
f e r
Connected.
ans
SQL> revoke c##_role from c##u1 container=all;
n - t r
o
s an
ha
Revoke succeeded.
)
m ideฺ
c o
ailฺ t Gu
SQL> connect c##u1
Enter password: ****** m
g den
@
ica is Stu
Connected.
h t
SQL> select * from session_roles;
s
ROLE
a p a e th
( f pr to us
------------------------------
t
C##_ROLE
h ica nse
p a s lice
ra SQL> connect c##u1@PDB2
m ur P Enter password: ******
Fla Connected.
SQL> select * from session_roles;
no rows selected
SQL>
11. Grant a common role to a local user from the root.
SQL> connect / as sysdba
Connected.
SQL> grant c##_role to local_employee;
grant c##_role to local_employee
*
ERROR at line 1:
ORA-01917: user or role 'LOCAL_EMPLOYEE' does not exist
Grant succeeded.
SQL>
14. Grant a common role to a local user from pdb2 applicable in all containers.
SQL> connect system@PDB2
Enter password: ******
Connected.
SQL> grant c##_role to local_employee container=all;
grant c##_role to local_user_pdb2 container=all
*
ERROR at line 1:
ORA-65030: one may not grant a Common Privilege to a Local User
or Role
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Grant succeeded.
a ble
f e r
ans
n - t r
a no
h a s
Practices for m ) Lesson
e ฺ 5:
o uid
a ilฺc G
Encryption Concepts
g m ent
c a @ tu5 d
Chapter
i
ht this S
a s
f p r ap use
a ( to
i c
ht cens e
a s li
rap
mur P
Fla
Lesson Overview
There are no practices for this lesson.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
a ble
f e r
ans
n - t r
a no
h a s
Practices for m ) Lesson
e ฺ 6: Using
o
ilฺc Guid
Application-Based
a
g m ent
Encryption
t i c a@ Stud
a s h thChapter
is 6
f p r ap use
a ( to
i c
ht cens e
a s li
rap
mur P
Fla
Overview
In this practice, you create functions to encrypt and decrypt data, and create a KEYS table.
Then, by using the functions, you encrypt and decrypt column data. You also apply an SHA-1
message digest to the column to verify integrity.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Review and execute the crypto_random.sql script in the /home/oracle/labs/ENC
directory, which performs the following actions:
• Adds a credit card column to the CUSTOMERS table
• Creates the ENCRYPT function for AES encryption
• Creates the DECRYPT function for AES decryption a ble
f e r
• Creates a KEYS table to hold a 128-bit key value (KEY RAW (16))
ans
• Inserts a key value generated by DBMS_CRYTPO.RANDOM_BYTES
n - t r
• no
Shows the key value that has been generated. Yours may be different that the one
a
shown.
h a s
$ cd ~/labs/ENC m ) eฺ
o
$ . oraenv
a ilฺc Guid
ORACLE_SID = [orcl] ? orcl
g m ent
The Oracle base for
t i c a@ Stud
a s h this
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is
ap use
/u01/app/oracle
f p r
$ rm –f @$HOME/labs/ENC/show_creditcard.sql >> /dev/null 2>&1
(
i c a e to
$ sqlplus /nolog @$HOME/labs/ENC/crypto_random.sql
a s ht cens
rapSQL*Plus:li Release 12.1.0.2.0 Production on Tue May 28 08:10:00
ur P 2013
F lam
Copyright (c) 1982, 2013, Oracle. All rights reserved.
SQL>
SQL> --- Grant Execute on DBMS_CRYPTO TO OE ---
SQL>
SQL> CONNECT / AS SYSDBA
Connected.
SQL>
SQL> GRANT EXECUTE ON DBMS_CRYPTO TO OE;
Grant succeeded.
SQL>
SQL>
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL>
SQL> ALTER TABLE customers DROP column credit_card_num;
ALTER TABLE customers DROP column credit_card_num
*
ERROR at line 1:
ORA-00904: "CREDIT_CARD_NUM": invalid identifier
a ble
f e r
SQL>
ans
SQL> ALTER TABLE customers ADD credit_card_num RAW(2000);
n - t r
o
s an
Table altered.
) ha
c o m ideฺ
ailฺ t Gu
SQL>
SQL> m
g and e n
@ d
ica is Stu
SQL> --- Create the encrypt_value
SQL> -- decrypt_value
s h tfunctions
SQL> a p a e th
SQL> create(for prreplace
t o usfunction encrypt_value
2
h t ica( nse
p 3s
a l i c e p_in in varchar2,
ra
ur P
4 p_key in raw
m 5 )
Fla 6 return raw is
7 l_enc_val raw (2000);
8 l_mod number := dbms_crypto.ENCRYPT_AES128
9 + dbms_crypto.CHAIN_CBC
10 + dbms_crypto.PAD_PKCS5;
11 begin
12 l_enc_val := dbms_crypto.encrypt
13 (
14 UTL_I18N.STRING_TO_RAW
15 (p_in, 'AL32UTF8'),
16 l_mod,
17 p_key
18 );
19 return l_enc_val;
Function created.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
SQL>
SQL>
SQL> create or replace function decrypt_value
2 (
3 p_in in raw,
4 p_key in raw
5 )
a ble
6 return varchar2
f e r
7 is
ans
8 l_ret varchar2 (2000);
n - t r
o
9 l_dec_val raw (2000);
s an
10 l_mod
ha
number := dbms_crypto.ENCRYPT_AES128
)
11
m ideฺ
+ dbms_crypto.CHAIN_CBC
c o
ailฺ t Gu
12 + dbms_crypto.PAD_PKCS5;
13 begin m
g den
@
ica is Stu
14 l_dec_val := dbms_crypto.decrypt
15 (
s h t
16 a p
p_in, a e th
17 ( f pr to us
l_mod,
18
h t ica nsep_key
p a
19s lice );
ra
ur P
20 l_ret:= UTL_I18N.RAW_TO_CHAR
m 21 (l_dec_val, 'AL32UTF8');
Fla 22 return l_ret;
23 end;
24 /
Function created.
SQL>
SQL>
SQL> -- Create KEYS table
SQL> DROP TABLE KEYS;
DROP TABLE KEYS
*
ERROR at line 1:
ORA-00942: table or view does not exist
Table created.
SQL>
SQL> -- get a KEY and store it in KEYS
SQL>
SQL> INSERT INTO KEYS
a ble
2 SELECT DBMS_CRYPTO.RANDOMBYTES(16) FROM DUAL;
f e r
ans
1 row created.
n - t r
o
s an
SQL>
) ha
SQL>
c o m ideฺ
ailฺ t Gu
SQL> COMMIT;
m
g den
@
ica is Stu
Commit complete.
s h t
SQL> a p a e th
SQL> SELECT ( f p*rFROMto KEYS;
us
h t ica nse
p a s lice
KEY_VALUE
ra
ur P
--------------------------------
m AD4C95D0E9D1F31DE5106463F3C103AB
Fla
SQL>
2. As user oe, update one of the customer’s rows with a credit card number.
SQL> CONNECT oe/******
Connected.
SQL> UPDATE customers
SET credit_card_num = '123456789012345678901234'
WHERE customer_id = 101;
2 3
1 row updated.
SQL> COMMIT;
Commit complete.
CREDIT_CARD_NUM
----------------------------------------------------------
123456789012345678901234
a ble
f e r
SQL> save show_creditcard.sql
ans
Created file show_creditcard.sql
n - t r
o
an
SQL>
4. Encrypt the credit card number by using the function created in step
ha s
1.
SQL> DECLARE )
m ideฺ
c o
l_key RAW(16);
m ailฺ t Gu
BEGIN
@ g FROM d e n
SELECT key_value INTO
t i c a Stu KEYS;
l_key
a s h this
r ap use
UPDATE customers
f p
SET ( credit_card_num
i c a e to
s h t ens = encrypt_value(credit_card_num, l_key)
SQL>
5. Verify the encryption by selecting the credit card number of the row just updated. The
output is expected to be different than the sample. In some cases, the output may clear the
screen.
SQL> SELECT UTL_I18N.RAW_TO_CHAR(credit_card_num, 'AL32UTF8')
FROM customers
WHERE customer_id = 101;
UTL_I18N.RAW_TO_CHAR(CREDIT_CARD_NUM,'AL32UTF8')
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
DECRYPT_VALUE(CREDIT_CARD_NUM,(SELECTKEY_VALUEFROMKEYS))
---------------------------------------------------------
a ble
123456789012345678901234
f e r
ans
SQL>
n - t r
7. Update the CUSTOMERS table with the decrypted credit card number.
a no
SQL> UPDATE customers
h a s
m ) eฺ
SET credit_card_num=decrypt_value(credit_card_num,
o uid keys))
ilฺc GFROM
(SELECT key_value
a
WHERE customer_id = 101;gm
e n t
2 3 4
t i c a@ Stud
1 row updated.
a s h this
f p r ap use
a
SQL> commit; ( to
i c
ht cens e
a s li
rapCommit complete.
mur P
Fla
SQL>
8. Verify that the update worked by selecting the credit card number.
SQL> SELECT credit_card_num
FROM customers
WHERE customer_id = 101;
CREDIT_CARD_NUM
---------------------------------------------------------
123456789012345678901234
SQL>
Overview
In this practice, you checksum a credit card number value by using the HASH function of
DBMS_CRYPTO package.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. What happens when you try to produce an SHA-1 checksum on the CREDIT_CARD_NUM
column? Why?
Because the procedures and functions in DBMS_CRYPTO are overloaded, the Oracle
instance cannot determine the correct version of the function to call. To correct this, wrap
the call in a PL/SQL function (as was done with encryption and decryption in the first step of
this practice).
a ble
SQL> SELECT DBMS_CRYPTO.HASH(credit_card_num,
f e r
DBMS_CRYPTO.HASH_SH1)
ans
n - t r
no
FROM customers
WHERE customer_id = 101;
s a
h a
DBMS_CRYPTO.HASH_SH1)
) eฺ
* o m
ERROR at line 2: a ilฺc Guid
g m ent
ORA-06553: PLS-221: 'HASH_SH1' is not a procedure or is
undefined
t i c a@ Stud
a s h this
f p r ap use
SQL> a ( to
i c
ht script e
s a function called CHECKSUM that produces an SHA-1 hash of
ncreates
a s
2. The hash.sql
c e
p Reviewli and execute hash.sql.
theainput.
r
mur P SQL> @$HOME/labs/ENC/hash.sql
Fla SQL> SET ECHO OFF
SQL>
SQL> CONNECT oe
Enter password: *****
Connected.
SQL>
SQL> CREATE OR REPLACE FUNCTION checksum (
2 p_raw_input RAW)
3 RETURN RAW
4 IS
5 v_checksum RAW(20);
6 BEGIN
7 v_checksum :=
8 DBMS_CRYPTO.HASH(
9 src => p_raw_input,
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Function created.
SQL>
3. Use the function created in the previous step to produce a checksum for the credit card
number.
SQL> SELECT checksum (credit_card_num)
FROM customers
a ble
WHERE customer_id = 101;
f e r
ans
CHECKSUM(CREDIT_CARD_NUM)
n - t r
---------------------------------------------------------
a no
196FB5FB06A63A73D0F1D31D6E985C996C3AEFE9
h a s
m ) eฺ
SQL> o
lฺc Guid
a i
4. Change the credit card number in the table. m
g e n t
SQL> UPDATE customers
t i c a@ Stud
SET
s h th=is'123456789A12345678901234'
credit_card_num
a
r ap use= 101;
WHERE customer_id
f p
2
i
3
c a ( se to
1 row tupdated.
p a sh licen
P ra SQL> COMMIT;
u r
m
Fla Commit complete.
SQL>
5. Verify that the checksum has changed by using the function created in step 2. Compare the
checksum to the value produced in step 3.
SQL> SELECT checksum (credit_card_num)
FROM customers
WHERE customer_id = 101;
CHECKSUM(CREDIT_CARD_NUM)
---------------------------------------------------------
C2578E5407A57A042B24EC0CFBDF418DB62F526F
SQL>
CHECKSUM('123456789A12345678901234')
---------------------------------------------------------
C2578E5407A57A042B24EC0CFBDF418DB62F526F
SQL>
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Overview
In this practice, you will start the Enterprise Manager machine to permit time for the Enterprise
Manager Cloud Control to start. Cloud Control is used for bulk segment movement to encrypted
tablespaces.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Exit SQL*Plus and the host machine.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release
12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
a ble
Application Testing options
f e r
[oracle@db1 ~]$ exit
ans
logout n - t r
Connection to db1 closed.
a no
[Host Desktop]$
h a s
2. Start the em13 machine. m ) eฺ
o
[Host Desktop]$ sudo xm create em13 a ilฺc Guid
g m ent
a@ Stud
Using config file "/etc/xen/em13".
Started domain em13 (id=12) t i c
hxm list
a s t h is
ap use ID Mem VCPUs
[Host Desktop]$ sudo
Name
( f p r State Time(s)
t o
db1sh
tica ense
Domain-0 0 1024
1 3072
2
1
r----- 311839.2
-b---- 101346.4
p a l i c
P ra em13 12 9216 1 ------ 4.8
r
mu
[Host Desktop]$
Fla
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
a ble
f e r
ans
n - t r
a no
h a s
Practices for m ) Lesson
e ฺ 7:
o uid
Applying
a ilฺc Transparent
G Data
m
g den
Encryption t
@ tu7
h t ica Chapter
s S
p a s
e t hi
( f pra to us
h t ica nse
p a s lice
ra
mur P
Fla
Overview
In this practice, you configure a password-based keystore for a non-CDB and a password-
based keystore for a CDB. Then you set the master key for the non-CDB and the master key for
each PDB of the CDB.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
pa s lic
r a
u rP
Task
m
Fla 1. Prepare the orcl database for encryption.
a. Create a directory for the unique Oracle password-based keystore for the database in
$ORACLE_BASE/admin/orcl/wallet if it does not exist. The directory and wallet
may have already been created as part of the Enterprise User Security database
registration process. If it exists, as shown in this example, move it out of the way.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is
/u01/app/oracle
$ ls -d $ORACLE_BASE/admin/orcl/wallet
/u01/app/oracle/admin/orcl/wallet
$ mv $ORACLE_BASE/admin/orcl/wallet
$ORACLE_BASE/admin/orcl/wallet.old
$ ls –d $ORACLE_BASE/admin/orcl/wallet
$ sqlplus / as syskm
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 -
64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced
Analytics and Real Application Testing options
a ble
f e r
ans
SQL> ADMINISTER KEY MANAGEMENT CREATE KEYSTORE
n - t r
'/u01/app/oracle/admin/orcl/wallet'
a no
IDENTIFIED BY secret;
h a s
2 3
m ) eฺ
o
ilฺc Guid
keystore altered.
a
m ent
g
a@ Stud
SQL> EXIT
$ t i c
h this
a s
p insthe
c. Verify that the file is created appropriate directory.
r a e
(fp to u
$ ls -l /u01/app/oracle/admin/orcl/wallet
a
total t4ic se
a s h e n
a p-rw-r--r--l ic 1 oracle oinstall 2408 Jun 18 06:46 ewallet.p12
r
ur P
$
m d. Open the keystore.
Fla $ sqlplus / as syskm
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 -
64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced
Analytics and Real Application Testing options
SQL>
USING 'for_12c';
2 3 4
keystore altered.
SQL>
f. Verify that the keystore has been backed up before master key generation. Note that
the backup file name includes the date and time of backup.
a ble
f e r
SQL> !ls -l /u01/app/oracle/admin/orcl/wallet
ans
-rw-r--r-- 1 oracle oinstall 2408 Dec 14 07:18
n - t r
ewallet_2016121412180617_for_12c.p12
a no
-rw-r--r-- 1 oracle oinstall 4112 Dec 14 07:18 ewallet.p12
h a s
m ) eฺ
SQL> o
lฺc All uid master keys are
a
Notice that if you regenerate the master key, the fileigrows. Gprevious
g
kept for data that could have used the previous n t
mmasterekeys.
SQL> ADMINISTER KEY MANAGEMENT t i c a@ S tudKEY
SET
a s h this IDENTIFIED BY secret;
r p MANAGEMENT
aKEY s e
2 ADMINISTER
( f p t o u SET KEY
*
h t i ca nse
a
ERROR
p s at lilinec e 1:
P ra ORA-46631: keystore needs to be backed up
mur
Fla SQL> ADMINISTER KEY MANAGEMENT SET KEY
IDENTIFIED BY secret
WITH BACKUP;
2 3
keystore altered.
ewallet_2016121412180617_for_12c.p12
ewallet_2016121412204022.p12
ewallet.p12
SQL>
g. Back up the keystore that contains the current master key.
SQL> ADMINISTER KEY MANAGEMENT BACKUP KEYSTORE
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
total 24
-rw-r--r--. 1 oracle oinstall 2408 Dec 14 07:18
ewallet_2016121412180617_for_12c.p12
-rw-r--r--. 1 oracle oinstall 3848 Dec 14 07:20
ewallet_2016121412201448.p12
-rw-r--r--. 1 oracle oinstall 6048 Dec 14 07:20
ewallet_2016121412204022.p12
a ble
-rw-r--r--. 1 oracle oinstall 6048 Dec 14 07:20 ewallet.p12 f e r
ans
Notice that both the current and the backup files have the same size.
n - t r
h. View the keystore file location from the view.
a no
SQL> SELECT WRL_PARAMETER, STATUS, WALLET_TYPE, CON_ID
h a s
FROM V$ENCRYPTION_WALLET;
m ) eฺ
o
2
a ilฺc Guid
WRL_PARAMETER
g m ent
STATUS WALLET_TYPE CON_ID
t i c a@ Stud
--------------------------------- ------ -------------- ------
a s h this
/u01/app/oracle/admin/orcl/wallet OPEN PASSWORD 0
f p r ap use
SQL> EXIT
a ( to
$ i c
ht cemultitenant
ns e
2. Prepare
p a s li
the dbsec container database for encryption.
r a
ur P
a. Create a directory for the unique Oracle password-based keystore for the CDB in
$ORACLE_BASE/admin/dbsec/wallet if it does not exist.
m
Fla $ . oraenv
ORACLE_SID = [orcl] ? dbsec
The Oracle base remains unchanged with value /u01/app/oracle
$ mkdir $ORACLE_BASE/admin/dbsec/wallet
$
b. Connect to the dbsec instance as a user who has been granted the SYSKM privilege to
create the password-based keystore.
$ sqlplus / as syskm
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 -
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
f p r ap use
a ( 1 oracle
to oinstall 2408 Dec 14 07:34 ewallet.p12
i c
-rw-r--r--.
ht cens e
a s li WRL_PARAMETER, STATUS, WALLET_TYPE, CON_ID
r apSQL> SELECT
ur P FROM V$ENCRYPTION_WALLET;
F lam 2
WRL_PARAMETER STATUS WALLET_TYPE
---------------------------------- -------------- ------------
CON_ID
----------
/u01/app/oracle/admin/dbsec/wallet CLOSED UNKNOWN
0
SQL>
e. Open the keystore for all PDBS.
SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN
IDENTIFIED BY secret_dbsec
CONTAINER = ALL;
2 3
keystore altered.
User altered.
User created.
Grant succeeded.
SQL>
3) Generate the master key.
SQL> ADMINISTER KEY MANAGEMENT SET KEY
IDENTIFIED BY secret_dbsec
WITH BACKUP
CONTAINER=CURRENT;
2 3 4 ADMINISTER KEY MANAGEMENT SET KEY
a ble
f e r
*
ans
ERROR at line 1:
n - t r
ORA-46671: master key not set in root container
a no
h a s
SQL> CONNECT / AS SYSKM
m ) eฺ
Connected. o
lฺc Guid
SQL> ADMINISTER KEY MANAGEMENT SETaiKEY
g m e n t BY secret_dbsec
a@ S tudBACKUP;
IDENTIFIED
t i c
hKEY MANAGEMENT WITH
a s t h is
2 3 ADMINISTER
a p e SET KEY
*
( f pr to us
ERROR at
h t icalinens1:e
a s licepassword-based keystore is not open
ORA-28417:
p
ra
m ur P SQL>
Fla Notice that the keystore was automatically closed.
SQL> SELECT WRL_PARAMETER, STATUS, WALLET_TYPE, CON_ID
FROM V$ENCRYPTION_WALLET;
2
WRL_PARAMETER STATUS WALLET_TYPE
---------------------------------- -------------- ------------
CON_ID
----------
/u01/app/oracle/admin/dbsec/wallet CLOSED PASSWORD
0
SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN
IDENTIFIED BY secret_dbsec
CONTAINER = ALL;
SQL>
4) Generate the master key in the root container.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
SQL> SELECT WRL_PARAMETER, STATUS, WALLET_TYPE, CON_ID
f e r
FROM V$ENCRYPTION_WALLET;
ans
2 n - t r
o
WRL_PARAMETER STATUS an
WALLET_TYPE
s
ha
---------------------------------- -------------- ------------
)
CON_ID
c o m ideฺ
----------
m ailฺ t Gu
@ g den
/u01/app/oracle/admin/dbsec/wallet OPEN PASSWORD
0
h t ica is Stu
SQL>
p a s th
a
pr to us e
SQL> SELECT KEY_ID, KEYSTORE_TYPE, KEY_USE,
( f
ACTIVATING_DBNAME, ACTIVATING_PDBNAME
h t ica nse
FROM V$ENCRYPTION_KEYS;
p a2s lice
3
ra
m ur P KEY_ID
Fla ----------------------------------------------------------------
--
KEYSTORE_TYPE KEY_USE ACTIVATING_DBNAME
----------------- ---------- ------------------------------
ACTIVATING_PDBNAME
------------------------------
AS8uMARZuE/mvzLJ7ZZ71j8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
SOFTWARE KEYSTORE TDE IN PDB dbsec
CDB$ROOT
AUGgBkmeY0/WvzuSCzsIuQ8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
SOFTWARE KEYSTORE TDE IN PDB dbsec
CDB$ROOT
ATkamfAyOE8EvxdeCYrruKkAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Afuj/VB5Gk/Ov252HczmgdQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
SOFTWARE KEYSTORE TDE IN PDB dbsec
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
PDB2
SQL>
Notice that the command generated one master key for each container including the root
container.
5) Generate a master key for pdb1.
SQL> CONNECT c##km@pdb1 AS SYSKM
a ble
Enter password: ******
f e r
Connected.
ans
SQL> n - t r
o
SQL> ADMINISTER KEY MANAGEMENT SET KEY
s an
ha
IDENTIFIED BY secret_dbsec
)
WITH BACKUP
c o m ideฺ
ailฺ t Gu
CONTAINER = CURRENT;
m
2 3 4
@ g den
keystore altered.
h t ica is Stu
p a s th
SQL> SELECT KEY_ID,a
pr to us e
KEYSTORE_TYPE, KEY_USE,
( f
icaV$ENCRYPTION_KEYS;
ACTIVATING_DBNAME, ACTIVATING_PDBNAME
s h t
FROM
e n se
rapa2 3 lic
mur P KEY_ID
Fla
----------------------------------------------------------------
--
KEYSTORE_TYPE KEY_USE ACTIVATING_DBNAME
----------------- ---------- ------------------------------
ACTIVATING_PDBNAME
------------------------------
AWZwoj/XQU9yv+6NKEmoHc4AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
SOFTWARE KEYSTORE TDE IN PDB dbsec
PDB1
ATkamfAyOE8EvxdeCYrruKkAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
SOFTWARE KEYSTORE TDE IN PDB dbsec
PDB1
SQL>
a ble
SQL> SELECT KEY_ID, KEYSTORE_TYPE, KEY_USE,
f e r
ACTIVATING_DBNAME, ACTIVATING_PDBNAME
ans
FROM V$ENCRYPTION_KEYS; n - t r
o
2 3
s an
KEY_ID
) ha
c o m ideฺ
----------------------------------------------------------------
ailฺ t Gu
--
KEYSTORE_TYPE KEY_USE m
g den
ACTIVATING_DBNAME
@
ica is Stu
----------------- ---------- ------------------------------
ACTIVATING_PDBNAME
s h t
a p a
------------------------------e th
( f pr to us
AdjYW0wSi0+Qv7Tjc9E7nlcAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
h t ica nse
SOFTWARE KEYSTORE TDE IN PDB dbsec
p a s lice
PDB2
ra
m ur P Afuj/VB5Gk/Ov252HczmgdQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Fla SOFTWARE KEYSTORE TDE IN PDB dbsec
PDB2
SQL> EXIT
$
Notice that the command generated another master key for the pdb2 container.
Overview
In this practice, you create a table that contains an encrypted column. You view the data in the
format that is stored on disk before and after encryption. You create an index on the encrypted
column. You demonstrate that range scans are possible. You grant access to the column for a
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
particular user, and you demonstrate that any user with proper privileges can view the
unencrypted data.
Tasks
1. When transparent data encryption (TDE) is applied to columns in the database, what does
the application developer do to be sure that the application can handle the encrypted
columns?
a. Increase the size of the fields and the variables holding the values from the encrypted
a ble
columns.
f e r
b. Add error handling for column overruns. ans
c. Add error handling for missing keys. n - t r
d. Nothing a no
Answer: d. Nothing h a s
m ) eฺ
2. o
Create a table in the OE schema that holds sensitive customer payment information. Use
ilฺc Guid
the create_tables.sql script in the /home/oracle/labs/ENC directory to create and
a
g m ent
populate a table named OE.CUST_PAYMENT_INFO.
$ cd ~/labs/ENC
t i c a@ Stud
$ . oraenv a s h this
p r
ORACLE_SID = [dbsec]
f ap u? sorcle
The Oracle a (base remains
to unchanged with value /u01/app/oracle
i c
ht c/nolog e
ns @create_tables.sql
s
$ sqlplus
a e
li oe/oracle_4U@localhost:1521/orcl
rapSQL> connect
ur P Connected.
F lam
SQL> drop table cust_payment_info;
drop table cust_payment_info
*
ERROR at line 1:
ORA-00942: table or view does not exist
Table created.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
1 row created.
1 row created.
a ble
SQL> insert into cust_payment_info values
f e r
2 ('Alan', 'Squire', 10003, 378282246310005,'YES');
ans
n - t r
1 row created.
a no
h a s
SQL> insert into cust_payment_info values )
c o m ideฺ
ailฺ t Gu
2 ('Mike', 'Anderson', 10004, 6011000000000004,'YES');
m
g den
@
ica is Stu
1 row created.
s h t
SQL> insert into a p a e th
cust_payment_info values
( f p r u s
2 ('Annie',
i c a e to
'Schmidt', 10005, 4111111111111111,'YES');
a s htcreated.
c e ns
rap
1 row li
m ur P SQL> insert into cust_payment_info values
Fla 2 ('Elliott', 'Meyer', 10006, 4222222222222,'YES');
1 row created.
1 row created.
1 row created.
1 row created.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
SQL>
SQL> create index cust_payment_info_idx on
2 cust_payment_info (credit_card_number);
Index created.
SQL>
a ble
3. Select the data from the OE.CUST_PAYMENT_INFO table.
f e r
SQL> COLUMN first_name FORMAT A8 HEAD 'First'
ans
SQL> COLUMN order_number FORMAT 999999 hEAD "Order#" n - t r
o
SQL> SELECT *
s an
FROM oe.cust_payment_info
) ha
ORDER BY order_number;
c o m ideฺ
2 3
m ailฺ t Gu
@ g den
First LAST_NAME
i
Order#
t S tu
ca CREDIT_CARD_NUMBER ACT
-------- ---------- s
a h i s
-------h--------------------
t ---
Jon Oldfield p
ra u10001 e
s 5105105105105100 YES
( f p o
t 10002 6011111111111117
Chris
caWhite
Alan hti Squiren s e YES
Fla
Elliott Meyer 10006 4222222222222 YES
Celine Smith 10007 343434343434343 YES
Steve Haslam 10008 6011000990139424 YES
Albert Einstein 10009 5111111111111118 YES
9 rows selected.
SQL>
4. Dump the data blocks to see the data as it is stored in the file. Do this as the SYS user.
a. Find the database address of the OE.CUST_PAYMENT_INFO table. The
$HOME/labs/ENC/dump_blocks.sql script executes the following:
SELECT file_id FROM dba_data_files
WHERE RELATIVE_FNO =
(SELECT distinct dbms_rowid.ROWID_RELATIVE_FNO(rowid) FILE#
FROM oe.cust_payment_info);
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
a ( to
i c
ht cens
BLOCK# e
a s
----------
li
r ap 106756
m ur P SQL>
Fla b. Set the TRACEFILE_IDENTIFIER initialization parameter so that the trace file can be
found more easily by executing the following command:
ALTER SESSION SET TRACEFILE_IDENTIFIER=dp_block;
SQL> ALTER SESSION SET TRACEFILE_IDENTIFIER=dp_block;
Session altered.
SQL>
c. Dump the data block to a trace file. Substituting the file# and block# that you
recorded with the previous command, execute the following command:
ALTER SYSTEM DUMP DATAFILE <file#> BLOCK <block#>;
SQL> ALTER SYSTEM DUMP DATAFILE 6 BLOCK 106756;
System altered.
SQL> EXIT
$ find $ORACLE_BASE -name \*DP_BLOCK\*
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_14362_DP_BLO
CK.trc
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_14513_DP_BLO
CK.trm
$
e. View the dump file. The less utility enables you to scroll up and down the file to find
a ble
data of interest. Note that the credit card numbers are clearly visible. f e r
ans
$ less
n - t r
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_14362_DP_BLO
o
CK.trc
s an
) ha
/* Rows deleted */
c o m ideฺ
…
a ilฺ Gu
7FFB07A0EC80 2C31C102 41060501g7265626C m e n t69450874
[..1,...Albert.Ei]
t i c a@ Stud
7FFB07A0EC90 6574736EhC3046E69 is 100A0102 31313135
a s t h
[nstein......5111]
f p r ap u31313131
s e
7FFB07A0ECA0
a ( 31313131
t o 38313131 53455903
tic en0505012C
[111111111118.YES]
s h se
a p a
7FFB07A0ECB0
l i c 76657453 61480665 6D616C73
r [,...Steve.Haslam]
ur P 7FFB07A0ECC0 0102C304 30361009 30303131 30393930
F lam [......6011000990]
7FFB07A0ECD0 34393331 59033432 012C5345 65430605
[139424.YES,...Ce]
7FFB07A0ECE0 656E696C 696D5305 C3046874 0F080102
[line.Smith......]
7FFB07A0ECF0 34333433 34333433 34333433 03333433
[343434343434343.]
7FFB07A0ED00 2C534559 45070501 6F696C6C 4D057474
[YES,...Elliott.M]
7FFB07A0ED10 72657965 0102C304 32340D07 32323232
[eyer......422222]
7FFB07A0ED20 32323232 03323232 2C534559 41050501
[2222222.YES,...A]
/* Rows deleted */
…
$
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
5. Alter the table to encrypt the credit card numbers with NO SALT.
$ sqlplus oe
a ( to
i c
t eTABLE
hMODIFY
SQL> ALTER e
ns cust_payment_info
a s li c
rap (CREDIT_CARD_NUMBER encrypt no salt);
ur P
2
m
Fla
Table altered.
SQL>
6. Dump the data block and find the trace file. Change TRACEFILE_IDENTIFIER to DUMP2.
Use the $HOME/labs/ENC/dump_blocks.sql script to find the data block address.
SQL> @$HOME/labs/ENC/dump_blocks.sql
SQL> connect / as sysdba
Connected.
SQL>
SQL> SELECT file_id FROM dba_data_files
2 WHERE RELATIVE_FNO =
3 (SELECT distinct dbms_rowid.ROWID_RELATIVE_FNO(rowid)
FILE#
4 FROM oe.cust_payment_info);
SQL>
SQL> SELECT distinct dbms_rowid.rowid_block_number(rowid) BLOCK#
2 FROM oe.cust_payment_info;
BLOCK#
----------
41389
a ble
SQL> connect sys/oracle_4U@localhost:1521/orcl.example.com as
f e r
sysdba
ans
Connected.
n - t r
o
an
SQL>
SQL> SELECT file_id FROM dba_data_files
ha s
2 WHERE RELATIVE_FNO = )
m ideฺ
c o
ailฺ t Gu
3 (SELECT distinct dbms_rowid.ROWID_RELATIVE_FNO(rowid)
FILE#
m
g den
4 FROM
@
oe.cust_payment_info);
h t ica is Stu
FILE_ID
p a s th
---------- fpr a us e
( t o
h t ica6 nse
p a s lice
ra SQL>
ur P SQL> SELECT distinct dbms_rowid.rowid_block_number(rowid) BLOCK#
F lam 2 FROM oe.cust_payment_info;
BLOCK#
----------
106756
SQL>
7. Set the TRACEFILE_IDENTIFIER initialization parameter so that the trace file can be
found more easily.
a. Use ALTER SESSION SET TRACEFILE_IDENTIFIER=DUMP2;
SQL> ALTER SESSION SET TRACEFILE_IDENTIFIER=DUMP2;
Session altered.
System altered.
SQL> EXIT
$
c. Find the trace file.
a ble
$ find $ORACLE_BASE -name \*DUMP2\*
f e r
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_15151_DUMP2.
ans
trc
n - t r
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_15151_DUMP2.
a no
trm
h a s
$
m ) eฺ
d. View the trace file. Note that the unencrypted data o uid
lฺcremains.
a i G
$ less
g m ent
trc t i a@ Stud
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_15151_DUMP2.
c
a s h this
…
f p r ap use
a ( 0301002Cto
h t i c
7AA470 39141603
n s e 053202C1 6E780700 [...9,.....2...xn]
p a s 05160302
7AA480
l i c e 0605012C 65626C41 45087472 [....,...Albert.E]
P ra 7AA490 74736E69 046E6965 0A0102C3 3031330F [instein...... 511]
u r 7AA4A0 33343536 31343530 39383332 53455903 [1111111111118.YES]
m
Fla 7AA4B0
7AA4C0
0505012C
0102C304
76657453
34330F09
61480665
35373930
6D616C73
33303039
[,...Steve.Haslam]
[......60110009901]
7AA4D0 35383637 45590338 05012C53 6C654306 [39424.YES,...Cel]
7AA4E0 05656E69 74696D53 02C30468 340D0801 [ine.Smith......34]
7AA4F0 38363137 33353839 36333033 53455903 [3434343434343.YES]
7AA500 0705012C 696C6C45 0574746F 6579654D [,...Elliott.Meye]
7AA510 02C30472 330F0701 36333437 39393536 [r...... 4222222]
7AA520 38313137 59033032 012C5345 6E410505 [222222.YES,...An]
7AA530 0765696E 6D686353 04746469 060102C3 [nie.Schmidt.....]
7AA540 35353410 38383936 32383037 30393633 [.411111111111111]
7AA550 45590332 05012C53 6B694D04 6E410865 [1.YES,...Mike.An]
7AA560 73726564 C3046E6F 10050102 39323934 [derson...... 6011]
7AA570 35393838 35333637 30303437 53455903 [000000000004.YES]
7AA580 0405012C 6E616C41 75715306 04657269 [,...Alan.Squire.]
7AA590 040102C3 39353510 38363935 37333439 [.....3782822463]
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
h t ica table_name
where
n s e ='CUST_PAYMENT_INFO';
2 as 3 c e
p
a INDEX_NAMEl i
r
ur P
TABLE_NAME STATUS
---------------------- ----------------------- --------
m
Fla CUST_PAYMENT_INFO_IDX CUST_PAYMENT_INFO UNUSABLE
Index altered.
SQL>
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL>
SQL> SELECT file_id FROM dba_data_files
2 WHERE RELATIVE_FNO =
3 (SELECT distinct dbms_rowid.ROWID_RELATIVE_FNO(rowid)
FILE#
4 FROM oe.cust_payment_info);
a ble
FILE_ID
f e r
ans
----------
n - t r
no
6
s a
SQL> h a
) eฺ
o m
uid
SQL> SELECT distinct dbms_rowid.rowid_block_number(rowid) BLOCK#
oe.cust_payment_info; ailฺ
c
2 FROM
m ent G
g
BLOCK#
t i c a@ Stud
---------- a s h this
106771
f p r ap use
a ( to
i c
t eSESSION
hALTER e
ns SET TRACEFILE_IDENTIFIER=DUMP3;
SQL>
a s li c
rap
ur P Session altered.
F lam
SQL> ALTER SYSTEM DUMP DATAFILE 6 BLOCK 106771;
System altered.
SQL> EXIT
$
$ less /u01/app/oracle/diag/rdbms/orcl/orcl/trace/*_DUMP3.trc
…
7F22A1979B60 00000000 00000000 002C0000 6C410605
[..........,...Al]
7F22A1979B70 74726562 6E694508 69657473 02C3046E
[bert.Einstein...]
7F22A1979B80 D2340A01 7C4E41DD A2201C77 A3686758
[..4..AN|w. .Xgh.]
( f pr to us
t ica nssystem/oracle_4U@localhost:1521/orcl
SQL> connect
h e
a s
Connected.
lic e
rapSQL>
m ur P SQL> grant create session to JKING identified by oracle_4U;
Fla
Grant succeeded.
Grant succeeded.
Grant succeeded.
SQL>
Connected.
SQL>
SQL> grant select on oe.CUST_PAYMENT_INFO to LDORAN;
Grant succeeded.
r a s e
The lab script uses
a (fp the WHERE
t o u clause, where
h
scansof
ic indexnissperformed.
tthe e
CREDIT_CARD_NUMBER='6011111111111117' to select the row to update. A range
p
in a
both the l i c
column
e and the index; the literal value is encrypted
The credit card number is stored as an encrypted value
before it is compared.
r a
u r P The value is found in the index by using a range scan. The range scan is possible only
m when an equality predicate is used.
Fla SQL> @$HOME/labs/ENC/scan.sql
SQL> SET ECHO ON
SQL> conn LSMITH/oracle_4U@localhost:1521/orcl
Connected.
SQL> update oe.CUST_PAYMENT_INFO set ACTIVE_CARD='NO'
2 where CREDIT_CARD_NUMBER='6011111111111117';
1 row updated.
SQL>
SQL> PAUSE 'HIT Return to show execution plan'
'HIT Return to show execution plan'
PLAN_TABLE_OUTPUT
----------------------------------------------------------------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
-
SQL_ID 19g90uxc66plt, child number 0
-------------------------------------
update oe.CUST_PAYMENT_INFO set ACTIVE_CARD='NO' where
CREDIT_CARD_NUMBER='6011111111111117'
Fla 2 - access("CREDIT_CARD_NUMBER"='6011111111111117')
Note
-----
- dynamic statistics used: dynamic sampling (level=2)
24 rows selected.
SQL> EXIT;
$
13. Transparent data encryption is not visible to the end user. No changes are required to the
application or SQL syntax. Any user that has been granted privileges to access the table or
column can view the data in its unencrypted form. As the LDORAN user, select the
F lam 14. What should you do when the keystore is not available? Close the keystore.
SQL> CONNECT / as syskm
Connected.
SQL>
15. Connect as the LSMITH user with the password oracle_4U. Attempt to select all columns
from the OE.CUST_PAYMENT_INFO table. Then, attempt to select only the LAST_NAME
column.
SQL> connect lsmith@orcl
Enter password: ******
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
LAST_NAME
----------
Oldfield
a ble
White
f e r
Squire
ans
Anderson
n - t r
o
Schmidt
s an
Meyer
) ha
Smith
c o m ideฺ
ailฺ t Gu
Haslam
Einstein m
g den
@
h t ica is Stu
9 rows selected.
p a s th
a
pr to us e
SQL> ( f
16. As the userh t
whoicahas been
n segranted the SYSKM privilege, open the keystore.
s
a connect
pSQL> e
lic / as syskm
r a
mur P Connected.
Fla
SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN
IDENTIFIED BY secret;
2
keystore altered.
SQL>
17. Connect again as the LSMITH user with the password oracle_4U. Attempt to select all the
columns from the OE.CUST_PAYMENT_INFO table.
SQL> connect lsmith@orcl
Enter password: ******
Connected.
SQL> select * from oe.cust_payment_info;
SQL>
a ble
18. Drop the OE.CUST_PAYMENT_INFO table and re-create it with SALT. Then, create an index
f e r
on the encrypted column CREDIT_CARD_NUMBER. Use the salt.sql script. What
ans
happens when the create index command is issued?
n - t r
n
Execute the salt.sql script. An index cannot be created on a column with SALT. o
s a
SQL> @$HOME/labs/ENC/salt.sql
) ha
SQL> connect oe/oracle_4U@localhost:1521/orcl
c o m ideฺ
Connected.
m ailฺ t Gu
g den
SQL> SQL> drop table cust_payment_info;
@
h t ica is Stu
Table dropped.
p a s th
a e
pr tcust_payment_info
us
SQL> create(ftable o
ca nse varchar2(11),
2 hti(first_name
p a
3
s last_name
l i c e varchar2(10),
ra
ur P
4 order_number number(5),
m
Fla
5 credit_card_number varchar2(20) encrypt SALT,
6 active_card varchar2(3));
Table created.
SQL>
SQL> insert into cust_payment_info values
2 ('Jon', 'Oldfield', 10001, 5446959708812985,'YES');
1 row created.
1 row created.
1 row created.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
1 row created.
1 row created.
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Overview
In this practice, you create an encrypted tablespace and move several tables and the
associated indexes to the encrypted tablespace.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Ensure you have logged in to the db1 machine using the ssh X forwarding capability to
allow the browser to appear properly. If you have not done so, exit the db1 machine and
access it using Secure Shell with the –X option.
[oracle@db1 ~]$ exit
logout
Connection to db1 closed.
a ble
[Host Desktop]$ ssh -X -l oracle db1
f e r
ans
oracle@db1's password:
n - t r
no
Last login: Wed Dec 14 08:39:50 2016 from 192.0.2.1
[oracle@db1 ~]$
s a
2. Create an encrypted tablespace named ENCTBS, with a file enctbs01.dbf,h
) eฺ a in the same
directory with the rest of the data files: m
coUse theuitablespace.sql
d
/u01/app/oracle/oradata/orcl/enctbs01.dbf.
a i l ฺ G script
to create the encrypted tablespace. m
g den t
c @
a Stu
$ . oraenv
h t i
? orcl is
ORACLE_SID = [oracle]
p a s th to /u01/app/oracle
The Oracle base a
pr to us
has been e set
$ sqlplus /(fas sysdba
h t ica nse
p a s licto: e
P ra Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
Connected
r
mu 64bit Production
Fla With the Partitioning, Oracle Label Security, OLAP, Advanced
Analytics and Real Application Testing options
SQL> @$HOME/labs/ENC/tablespace.sql
SQL> SET ECHO ON
SQL>
SQL> DROP TABLESPACE "ENCTBS"
2 INCLUDING CONTENTS AND DATAFILES
3 /
DROP TABLESPACE "ENCTBS"
*
ERROR at line 1:
ORA-00959: tablespace 'ENCTBS' does not exist
Tablespace created.
SQL>
3. Ensure the user dbsnmp is unlocked with a recognizable password to assist registering with a ble
f e r
Oracle Enterprise Manager Cloud Control.
ans
SQL> alter user dbsnmp account unlock identified by oracle_4U;
n - t r
a no
User altered.
h a s
m ) eฺ
o
lฺc Guid
SQL> exit
a i
Disconnected from Oracle Database
g t
m 12cenEnterprise Edition Release
Fla
Click Search.
h. Objects: Add Click Select All.
Click Next 10.
Click Select All.
Click Next 5.
Click Select All.
Click OK.
i. Reorganize You should see 23 objects (only 10 will be displayed at a
Objects: Objects. time).
Click Set Attributes By Type.
j. Objects: Set In the Destination Tablespace for the Tables section, select
Attributes By Type “Relocate objects to another tablespace” and enter
ENCTBS.
In the Destination Tablespace for the Indexes section,
select “Relocate objects to another tablespace” and
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
ur P
/NOLOG
m
Fla SQL*Plus: Release 12.1.0.2.0 Production on Sun Jan 22 13:32:33
2017
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)
ha s
------------------------- -------------------- --------- -------
--- ---------- )
m ideฺ
COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
c o
ailฺ t Gu
-------------- ---------- -------------
m
106 Valli
@ g den
Pataballa
VPATABAL
h t ica is Stu
590.423.4560 05-FEB-98 IT_PROG
4800
p a s th
a
pr to us103 e 60
( f
h t ica nse
p a s lice
ra SQL> SELECT tablespace_name FROM user_segments
ur P WHERE segment_name='EMPLOYEES';
F lam 2
TABLESPACE_NAME
------------------------------
ENCTBS
SQL> EXIT
$
7. Clean up the environment by moving the HR schema back into the EXAMPLE tablespace.
Note: This script was generated by the Reorganize Objects wizard in Enterprise Manager
Cloud Control to move back all HR objects to the EXAMPLE tablespace.
$ $HOME/labs/ENC/back_to_example_tbs.sh
sqlplus sys/oracle_4U@localhost:1521/orcl as sysdba
@$HOME/labs/ENC/back_to_example_tbs.sql
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced
Analytics
and Real Application Testing options
b le
Disconnected from Oracle Database 12c Enterprise Edition Releaseera
12.1.0.2.0 - 64bit Production
a n sf
With the Partitioning, Oracle Label Security, OLAP, Advanced n - tr
Analytics
a no
and Real Application Testing options
h a s
$ m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
ht cens e
a s li
rap
mur P
Fla
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
a ble
f e r
ans
n - t r
a no
h a s
Practices for m ) Lesson
e ฺ 8:
o id
Applying
a ilฺc File
G uEncryption
g m ent
c a @ tu8 d
Chapter
i
ht this S
a s
f p r ap use
a ( to
i c
ht cens e
a s li
r ap
mur P
Fla
Overview
Recovery Manager (RMAN) backups to disk can be encrypted.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Assumptions
This practice is performed on the db1 host using the orcl and dbsec database instances. The
keystore wallet has been created as described in Practice 7-1.
Task
1. Configure Recovery Manager (RMAN) to use transparent encryption for the orcl
database. Set the configuration to be a permanent configuration in the control file.
$ . oraenv
a ble
f e r
ORACLE_SID = [orcl] ? orcl
ans
The Oracle base remains unchanged with value /u01/app/oracle
n - t r
$ rman target '"john@orcl AS SYSBACKUP"'
a no
h a s
target database Password: ******
m ) eฺ
o
ilฺc Guid
connected to target database: ORCL (DBID=1345659572)
a
m ent
g
RMAN> select user from dual;
t i c a@ Stud
a s hcontrol
t h isfile instead of recovery catalog
using target database
f p r ap use
USER
a ( to
i c
ht cens e
------------------------------
a s
SYSBACKUP
li
r ap
m ur P RMAN> show all;
Fla
RMAN configuration parameters for database with db_unique_name
ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO
BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
RMAN> exit
2016
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
a ble
64bit Production
f e r
With the Partitioning, OLAP, Advanced Analytics and Real
ans
Application Testing options
n - t r
a no
SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN
h a s
) eฺ
IDENTIFIED BY secret;
m
o
2
a ilฺc Guid
keystore altered.
g m ent
t i c a@ Stud
SQL> EXIT
a s h this
$
f p r ap use
a ( s'"john@orcl
e. Perform the backup
c
$ rmantitarget e to
s h e n AS SYSBACKUP"'
r a pa lic
ur P 11:08:32 2016
Recovery Manager: Release 12.1.0.2.0 - Production on Wed Dec 14
m
Fla
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All
rights reserved.
RMAN>
f. List the encrypted backups. a ble
f e r
RMAN> SELECT tag, encrypted FROM v$backup_piece;
ans
n - t r
TAG ENC
a no
-------------------------------- ---
h a s
TRANSPARENT YES
m ) eฺ
o
lฺc Guid
a i
RMAN>
g m ent
t i c ud to
a@ Stencryption
3. Back up the USERS tablespace using dual-mode
/home/oracle/backup/users002.bck.
a h thisSet tag = dual so that it can be specified in
sencryption
the restore command. Topset e mode and password, use the following
r a s
command:
a (fp ON tIDENTIFIED
o u
t ic nse
SET ENCRYPTION
h
BY "oracle1";
a. Set
p a sencryption
l i c emode and password.
P ra RMAN> SET ENCRYPTION ON IDENTIFIED BY "oracle1";
r
mu
Fla executing command: SET encryption
RMAN>
b. Use the RMAN BACKUP command to make a backup to
/home/oracle/backup/USERS002.bck.
RMAN> backup tablespace users
format '/home/oracle/backup/users002.bck'
tag 'dual';
2> 3>
Starting backup at 14-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006
name=/u01/app/oracle/oradata/orcl/users01.dbf
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
TAG ENC
-------------------------------- ---
TRANSPARENT YES
DUAL YES a ble
f e r
ans
RMAN>
n - t r
o
4. Back up the USERS tablespace using password encryption to
s an
/home/oracle/backup/USERS003.bck. Set tag = password so that it can be
) ha
specified in the restore command. To set encryption mode and password, use the
following command: c o m ideฺ
ailฺ t Gu
SET ENCRYPTION ON IDENTIFIED BY "password1" only;
m
a. Set the password for encryption. @ g den
h t ica is Stu
RMAN> set encryption on identified by "password1" only;
p a s th
a e
pr toSETusencryption
( f
executing command:
h t ica nse
a s lice
RMAN>
p
Pb.r a Use the RMAN BACKUP command to make a backup to
u r
m /home/oracle/backup/USERS003.bck.
Fla RMAN> backup tablespace USERS
format '/home/oracle/backup/USERS003.bck'
tag 'password';
2> 3>
Starting backup at 14-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006
name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 14-DEC-16
channel ORA_DISK_1: finished piece 1 at 14-DEC-16
piece handle=/home/oracle/backup/USERS003.bck tag=PASSWORD
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
TAG ENC
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
-------------------------------- ---
TRANSPARENT YES
DUAL YES
PASSWORD YES
RMAN> EXIT
$
a ble
5. Close the keystore. f e r
ans
$ sqlplus / as SYSKM
n - t r
a no
h a s
SQL*Plus: Release 12.1.0.2.0 Production on Wed Dec 14 11:13:28
2016
m ) eฺ
o uidreserved.
lฺc rights
Copyright (c) 1982, 2014, Oracle. aiAll G
g m ent
t i c a@ Stud
Connected to: a s h this
r p Enterprise
a12c s e
Oracle Database
( f p t o u Edition Release 12.1.0.2.0 -
icaPartitioning,
64bit Production
s t
With hthe
e n se OLAP, Advanced Analytics and Real
a p a
Applicationl i c Testing options
r
ur P
SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE CLOSE
m
Fla
IDENTIFIED BY secret;
2
keystore altered.
SQL> EXIT
$
6. In another terminal session, remove the USERS tablespace file.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base has been set to /u01/app/oracle
$ sqlplus / AS SYSDBA
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
NAME
---------------------------------------------------------------
a ble
f e r
/u01/app/oracle/oradata/orcl/system01.dbf
ans
/u01/app/oracle/oradata/orcl/users01.dbf
n - t r
/u01/app/oracle/oradata/orcl/sysaux01.dbf
a no
/u01/app/oracle/oradata/orcl/undotbs01.dbf
h a s
/u01/app/oracle/oradata/orcl/enctbs01.dbf
m ) eฺ
o
ilฺc Guid
/u01/app/oracle/oradata/orcl/users01.dbf
a
m ent
g
a@ Stud
6 rows selected.
t i c
h this
a s
ap use
SQL> EXIT
f p r
$ rm /u01/app/oracle/oradata/orcl/users01.dbf
(
$
i c a e to
t ens
a
7. Attempt toh
s restorei cthe USERS tablespace by using the backup made with transparent
ra p
encryption.
l
Why does it fail?
r P
u Attempt to restore the backup with the transparent tag. The keystore is closed. As a
m
Fla result, the encryption key is not available.
$ rman target '"john@orcl AS SYSBACKUP"'
rP
SET DECRYPTION IDENTIFIED BY "password1";
m u
Fla executing command: SET decryption
RMAN>
9. In your second terminal session, again remove the USERS tablespace datafile.
$ rm /u01/app/oracle/oradata/orcl/users01.dbf
$
10. Attempt to restore the USERS tablespace by using dual-mode encryption. Why does it fail?
The restore fails because the keystore is not open and the password is not set.
a ble
RMAN> restore tablespace USERS from tag dual;
f e r
ans
n - t r
no
Starting restore at 14-DEC-16
using channel ORA_DISK_1
s a
h a
) seteฺrestore
channel ORA_DISK_1: starting datafile backup o m
channel ORA_DISK_1: specifying datafile(s)a ilฺc Gto uidrestore from
backup set g m ent
channel ORA_DISK_1: restoring
t i c S t ud 00006 to
a@ datafile
s h this
/u01/app/oracle/oradata/orcl/users01.dbf
a
channel ORA_DISK_1:
f p r ap reading
u s e from backup piece
a (
/home/oracle/backup/users002.bck
to
i c
ht cens
RMAN-00571: e
a s
===========================================================
li =============== ERROR MESSAGE STACK FOLLOWS
r apRMAN-00569:
ur P ===============
F lam RMAN-00571:
===========================================================
RMAN-03002: failure of restore command at 12/14/2016 11:20:53
ORA-19870: error while restoring backup piece
/home/oracle/backup/users002.bck
ORA-19913: unable to decrypt backup
ORA-28365: wallet is not open
RMAN>
a ble
channel ORA_DISK_1: starting datafile backup set restore
f e r
channel ORA_DISK_1: specifying datafile(s) to restore from
ans
backup set
n - t r
o
an
channel ORA_DISK_1: restoring datafile 00006 to
/u01/app/oracle/oradata/orcl/users01.dbf
ha s
channel ORA_DISK_1: reading from backup piece )
m ideฺ
/home/oracle/backup/users002.bck
c o
channel ORA_DISK_1: piece
m ailฺ t Gu
g den
handle=/home/oracle/backup/users002.bck tag=DUAL
@
h t ica is Stu
channel ORA_DISK_1: restored backup piece 1
a s th
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
p
a
pr to us
Finished restore at 14-DEC-16 e
( f
ica nse
RMAN>htexit
$a
p s lice
r a
mur P
12. In your second terminal session, again remove the data file.
Fla $ rm /u01/app/oracle/oradata/orcl/users01.dbf
$
13. Open the encryption keystore.
$ sqlplus / as SYSKM
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
keystore altered.
SQL> EXIT
$
14. Restore the USERS tablespace by using transparent encryption.
Transparent mode encryption requires the keystore to be open.
$ rman target '"john@orcl AS SYSBACKUP"'
a b le
e r
Recovery Manager: Release 12.1.0.2.0 - Production on Wed Dec 14
a n sf
11:23:29 2016
n - tr
a no All
Copyright (c) 1982, 2014, Oracle and/or its affiliates.
rights reserved. h a s
m ) eฺ
o
target database Password: a ilฺc Guid
connected to target database: g ORCL e t
m (DBID=1454032016,
n not open)
a @ t u d
s h ticUSERSi s S
RMAN> restore tablespace
p a e t h from tag transparent;
( f p ra us
Starting a
i c restore at
e to 14-DEC-16
s
using
a httarget c e s
ndatabase control file instead of recovery catalog
p l i
a allocated channel: ORA_DISK_1
r
ur P channel ORA_DISK_1: SID=21 device type=DISK
F lam
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from
backup set
channel ORA_DISK_1: restoring datafile 00006 to
/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece
/home/oracle/backup/users001.bck
channel ORA_DISK_1: piece
handle=/home/oracle/backup/users001.bck tag=TRANSPARENT
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 14-DEC-16
RMAN>
16. Attempt to restore the USERS tablespace by using password-encrypted backup without
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
channel ORA_DISK_1: starting datafile backup set restore
f e r
channel ORA_DISK_1: specifying datafile(s) to restore from
ans
backup set
n - t r
o
channel ORA_DISK_1: restoring datafile 00006 to
/u01/app/oracle/oradata/orcl/users01.dbf s an
channel ORA_DISK_1: reading from backup piece ) ha
/home/oracle/backup/USERS003.bck
c o m ideฺ
RMAN-00571:
m ailฺ t Gu
g den
===========================================================
@
t ica is Stu
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
h
===============
p a s th
RMAN-00571: a
pr to us e
( f
===========================================================
t ica nse
RMAN-03002: failure of restore command at 12/14/2016 11:25:31
h
p a s lice
ORA-19870: error while restoring backup piece
r a
ur P
/home/oracle/backup/USERS003.bck
ORA-19913: unable to decrypt backup
m
Fla
RMAN>
17. Restore dual-mode backup without a password.
Dual-mode encrypted backup uses either the keystore or the password.
RMAN> restore tablespace USERS from tag dual;
RMAN>
18. Recover the USERS tablespace, open the database, and then exit Recovery Manager.
RMAN> recover tablespace USERS;
a ble
Starting recover at 14-DEC-16
f e r
using channel ORA_DISK_1
ans
n - t r
o
an
starting media recovery
media recovery complete, elapsed time: 00:00:01
ha s
)
m ideฺ
c o
ailฺ t Gu
Finished recover at 14-DEC-16
m
g den
RMAN> ALTER DATABASE OPEN; @
h t ica is Stu
p a s th
Statement processed
a
pr to us e
( f
ica nse
RMAN> tEXIT
h
$ as i c e
r a p l
mur P
Fla
Overview
In this practice, you perform various data pump export operations by using different parameters
for encryption. This helps you understand that you may export data in an unsecure manner.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Assumptions
In Practice 7-1 you successfully completed the creation of a password-based keystore in dbsec
and the generation of master keys for each PDB in dbsec.
Tasks
1. Execute the $HOME/labs/ENC/create_tables_pdb1.sql script to create a table with
an encrypted column in the pdb1 pluggable database.
a ble
$ . oraenv
f e r
ORACLE_SID = [orcl] ? dbsec
ans
n - t r
no
The Oracle base remains unchanged with value /u01/app/oracle
$ sqlplus / as sysdba
s a
h a
SQL*Plus: Release 12.1.0.2.0 Production m on) Wed Dec ฺ 14 11:31:17
c o i d e
ailฺ t Gu
2016
m
g dAll e nrights reserved.
@
ic is Stu
Copyright (c) 1982, 2014, aOracle.
s h t
a p a e th
Connected to: ( f pr to us
ca nse12c Enterprise Edition Release 12.1.0.2.0 -
OracletiDatabase
h
p a s Production
64bit
l i c e
r a With the Partitioning, OLAP, Advanced Analytics and Real
ur P Application Testing options
F lam
SQL> @$HOME/labs/ENC/create_tables_pdb1.sql
SQL>
SQL> connect system/oracle_4U@localhost:1521/pdb1.example.com
Connected.
SQL> ALTER USER oe IDENTIFIED BY oracle_4U ACCOUNT UNLOCK;
User altered.
Grant succeeded.
SQL>
SQL> connect system/oracle_4U@localhost:1521/pdb2.example.com
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
User altered.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Grant succeeded.
SQL>
SQL> connect oe/oracle_4U@localhost:1521/pdb1.example.com
Connected.
a ble
SQL> create directory dp as '/tmp';
f e r
ans
Directory created.
n - t r
a no
a s
SQL> connect oe/oracle_4U@localhost:1521/pdb2.example.com
h
Connected. m ) eฺ
SQL> create directory dp as '/tmp';ilฺc o uid
a
m ent G
g
Directory created.
t i c a@ Stud
a s h this
SQL>
f p r ap use
SQL> connect
a ( oe/oracle_4U@localhost:1521/pdb1.example.com
to
i c
t ens
hdrop
Connected. e
a s lictable cust_payment_info;
r ap
SQL>
ur P
drop table cust_payment_info
m *
Fla ERROR at line 1:
ORA-00942: table or view does not exist
Table created.
SQL>
1 row created.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
1 row created.
ur P
2 ('Elliott', 'Meyer', 10006, 4222222222222,'YES');
m
Fla 1 row created.
1 row created.
1 row created.
SQL>
SQL> COMMIT;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Commit complete.
SQL> exit
$
2. Export the OE.CUST_PAYMENT_INFO table that holds one encrypted column.
$ expdp oe@pdb1 tables=cust_payment_info directory=dp
a ble
REUSE_DUMPFILES=YES
f e r
a n s
Export: Release 12.1.0.2.0 - Production on Wed Dec n -t r
14 11:33:13
2016 n o
s a
a
) haffiliates.
Copyright (c) 1982, 2014, Oracle and/or its
o m e ฺ All
rights reserved.
a ilฺc Guid
Password:
g m ent
c a@ 12c d
tuEnterprise
t i
h this
Connected to: Oracle Database S Edition Release
s
12.1.0.2.0 - 64bitaProduction
f p r
With the Partitioning,ap usOLAP,
e Advanced Analytics and Real
Application a ( Testingto options
h i c se
t "OE"."SYS_EXPORT_TABLE_01":
n
a s
Starting
lic e
ptables=cust_payment_info
oe/********@pdb1
Fla
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type
TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
. . exported "OE"."CUST_PAYMENT_INFO" 7.203
KB 9 rows
ORA-39173: Encrypted data has been stored unencrypted in dump
file set.
Master table "OE"."SYS_EXPORT_TABLE_01" successfully
loaded/unloaded
****************************************************************
**************
Dump file set for OE.SYS_EXPORT_TABLE_01 is:
/tmp/expdat.dmp
$
Notice the warning message: ORA-39173: Encrypted data has been stored
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
ab le
Export: Release 12.1.0.2.0 - Production on Wed Dec 14 11:35:07 fer
2016 a n s
n -t r
o
n All
Copyright (c) 1982, 2014, Oracle and/or its affiliates.
s a
rights reserved.
) ha
Password:
c o m ideฺ
a ilฺ Gu
Connected to: Oracle Database g m e n t
12c Enterprise Edition Release
@ d
tu Analytics and Real
ica isAdvanced
12.1.0.2.0 - 64bit Production
With the Partitioning, h t
soptionsth
OLAP, S
p a
use
Application Testing
f pra tooperation
ORA-39002: (invalid
t i
ORA-39050:
h ca parameter
n s e ENCRYPTION is incompatible with parameter
a s lice
ENCRYPTION_MODE
p
r a
ur P $
F lam By default, the ENCRYPTION parameter, when not explicitly defined, sets the scope of
encryption to columns only. This encryption scope is incompatible with dual mode
encryption export.
4. Set the ENCRYPTION parameter explicitly to a compatible value.
$ expdp oe@pdb1 tables=cust_payment_info encryption_mode=dual
encryption=data_only directory=dp REUSE_DUMPFILES=YES
$
The ENCRYPTION parameter sets the scope of encryption to a value compatible with the
encryption scope, but the dual mode requires the keystore to be opened and a password
explicitly defined. The operation will export data only.
$ expdp oe@pdb1 tables=cust_payment_info encryption_mode=dual
encryption=data_only encryption_password="welcome1"
directory=dp dumpfile=reuse
b le
Export: Release 12.1.0.2.0 - Production on Wed Dec 14 11:37:44 era
2016
a n sf
n - tr
Copyright (c) 1982, 2014, Oracle and/or its affiliates. a no All
rights reserved.
h a s
Password: m ) eฺ
o
a ilฺc Guid
Connected to: Oracle Database 12c
g m Enterprise
e n t Edition Release
12.1.0.2.0 - 64bit Production
t i c S tud Analytics and Real
a@Advanced
With the Partitioning,
a s h this
OLAP,
ap use
Application Testing options
f p r
Starting "OE"."SYS_EXPORT_TABLE_01":
( oe/********@pdb1
t o
h t ica nse encryption_password=******** directory=dp
tables=cust_payment_info encryption_mode=dual
p a s lice
encryption=data_only
dumpfile=reuse
r a
ur P
Estimate in progress using BLOCKS method...
m Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Fla Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type
TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
. . exported "OE"."CUST_PAYMENT_INFO" 7.210
KB 9 rows
Master table "OE"."SYS_EXPORT_TABLE_01" successfully
loaded/unloaded
****************************************************************
**************
Dump file set for OE.SYS_EXPORT_TABLE_01 is:
/tmp/reuse.dmp
Job "OE"."SYS_EXPORT_TABLE_01" successfully completed at Wed Dec
14 11:38:09 2016 elapsed 0 00:00:20
directory=dp REUSE_DUMPFILES=YES
ailฺ t Gu
tables=cust_payment_info encryption_mode=dual
m
encryption=metadata_only encryption_password=********
g den
directory=dp REUSE_DUMPFILES=YES
@
t ica is Stu
Estimate in progress using BLOCKS method...
h
p a s th
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
a
pr to us e
f
Total estimation using BLOCKS method: 64 KB
(
h t ica nse
Processing object type TABLE_EXPORT/TABLE/TABLE
a s lice
Processing object type
p
r a TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Fla
. . exported "OE"."CUST_PAYMENT_INFO" 7.203
KB 9 rows
ORA-39173: Encrypted data has been stored unencrypted in dump
file set.
Master table "OE"."SYS_EXPORT_TABLE_01" successfully
loaded/unloaded
****************************************************************
**************
Dump file set for OE.SYS_EXPORT_TABLE_01 is:
/tmp/expdat.dmp
Job "OE"."SYS_EXPORT_TABLE_01" successfully completed at Wed Dec
14 11:39:40 2016 elapsed 0 00:00:08
$
Notice the warning message: ORA-39173: Encrypted data has been stored
unencrypted in dump file set.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
a ble
Connected to:
f e r
ans
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production n - t r
a
With the Partitioning, OLAP, Advanced Analytics and Real no
Application Testing options
h a s
m ) eฺ
SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE CLOSE
o
ilฺc Guid
IDENTIFIED BY secret_dbsec
a
g m ent
CONTAINER=ALL;
2 3
t i c a@ Stud
keystore altered.
a s h this
SQL> exit (fpr
ap use
i c a e to
$
a s ht mode.c e ns
r a p
7. Export in dual li
ur P
$ expdp oe@pdb1 tables=cust_payment_info encryption_mode=dual
m encryption=data_only encryption_password="welcome1" directory=dp
Fla REUSE_DUMPFILES=YES
Password: ******
u r
l a m REUSE_DUMPFILES=YES
F
Export: Release 12.1.0.2.0 - Production on Wed Dec 14 13:03:03
2016
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
SQL> exit
$
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
h i c
t ens
ENCRYPTION_PWD_PROMPT=YESe directory=dp REUSE_DUMPFILES=YES
a s
Estimate
p l i
inc progress using BLOCKS method...
r a
ur P
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Overview
In this practice, you import the OE.CUST_PAYMENT_INFO table that holds one encrypted
column into another PDB of dbsec.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Assumptions
The last export operation successfully completed in Practice 8-2.
Tasks
1. The SYSKM administrator decides to temporarily close the keystore for an administrative
keystore maintenance task.
$ sqlplus / as SYSKM
a ble
f e r
ans
SQL*Plus: Release 12.1.0.2.0 Production on Wed Dec 14 13:10:24
2016 n - t r
a no
Copyright (c) 1982, 2014, Oracle. All rights areserved.
h s
m ) eฺ
o
Connected to:
a ilฺc Guid
Oracle Database 12c Enterprisegm
e t
EditionnRelease 12.1.0.2.0 -
@ tu d
64bit Production
h t ica isAdvanced
S
With the Partitioning,
a s OLAP,
t h Analytics and Real
Application Testing
f p r ap useoptions
SQL> exit
$
2. Import the OE.CUST_PAYMENT_INFO table into pdb2 of dbsec. The
OE.CUST_PAYMENT_INFO table does not exist in pdb2.
a. If it exists, drop the table.
$ sqlplus system@pdb2
Table dropped.
Password: ******
…
Connected to: Oracle Database 12c Enterprise Edition Release
12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
ORA-39002: invalid operation
a ble
ORA-39174: Encryption password must be supplied.
f e r
ans
$ n - t r
a no
c. The export operation used a password to encrypt data in the dump file. The import
h a s
operation requires the same password to decrypt the data. Deliberately enter an
incorrect password, such as oracle_4u. m ) eฺ
o
a
$ impdp oe@pdb2 tables=cust_payment_info ilฺc Guid
g m ent
ENCRYPTION_PWD_PROMPT=YES directory=dp
t i c a@ Stud
Password: ******
a s h this
f p r ap use
( 12.1.0.2.0
Import: Release to - Production on Wed Dec 14 13:14:57
2016 tica e
a s h cens
r ap li
ur P
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All
rights reserved.
m
Fla Password:
Encryption Password:
ORA-39002: invalid operation
ORA-39176: Encryption password is incorrect.
Password: ******
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Encryption Password:
a ble
Master table "OE"."SYS_IMPORT_TABLE_01" successfully
f e r
loaded/unloaded
ans
Starting "OE"."SYS_IMPORT_TABLE_01": oe/********@pdb2 n - t r
o
an
tables=cust_payment_info ENCRYPTION_PWD_PROMPT=YES directory=dp
s
Processing object type TABLE_EXPORT/TABLE/TABLE
) ha
c o m ideฺ
ORA-39083: Object type TABLE:"OE"."CUST_PAYMENT_INFO" failed to
ailฺ t Gu
create with error:
ORA-28365: wallet is not open
m
g den
@
ica is Stu
Failing sql is:
h t
CREATE TABLE "OE"."CUST_PAYMENT_INFO" ("FIRST_NAME" VARCHAR2(11
s
p a th
BYTE), "LAST_NAME" VARCHAR2(10 BYTE), "ORDER_NUMBER"
a e
( f pr to us
NUMBER(5,0), "CREDIT_CARD_NUMBER" VARCHAR2(20 BYTE) ENCRYPT
ica nse
USING 'AES192' 'SHA-1', "ACTIVE_CARD" VARCHAR2(3 BYTE)) SEGMENT
h t
CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
s lice
a p a
NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS
r 1 MAXEXTENTS
$
The table is created with a CREDIT_CARD_NUMBER column, which holds the ENCRYPT
attribute. The password is required to decrypt the values of the CREDIT_CARD_NUMBER
column stored in the dump file and requires the keystore to be opened to re-encrypt the
values in the data file where the table segment is stored.
CONTAINER=ALL;
2 3
keystore altered.
SQL> exit
$
f. Re-attempt the import operation.
a ble
$ impdp oe@pdb2 tables=cust_payment_info
f e r
ENCRYPTION_PWD_PROMPT=YES directory=dp
ans
…
n - t r
Import: Release 12.1.0.2.0 - Production on Wed Dec 14 13:19:09
a no
2016
h a s
m ) eฺ
Copyright (c) 1982, 2014, Oracle and/or
l ฺ c o its
u id
affiliates. All
i
rights reserved.
g ma ent G
a@ Stud
Password: *******
t i c
hDatabase
a s t h is12c Enterprise Edition Release
ap Production
Connected to: Oracle
12.1.0.2.0 - 64bit
p r u s e
With the a ( f to OLAP, Advanced Analytics and Real
i c
ht ceTesting
Application ns e
Partitioning,
options
a s li
r ap
mur P Encryption Password: *******
Fla
Master table "OE"."SYS_IMPORT_TABLE_01" successfully
loaded/unloaded
Starting "OE"."SYS_IMPORT_TABLE_01": oe/********@pdb2
tables=cust_payment_info ENCRYPTION_PWD_PROMPT=YES directory=dp
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "OE"."CUST_PAYMENT_INFO" 7.210
KB 9 rows
Processing object type
TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
Job "OE"."SYS_IMPORT_TABLE_01" successfully completed at Wed Dec
14 13:19:34 2016 elapsed 0 00:00:20
Table dropped.
P ra 2 3 CONTAINER=ALL;
mur
Fla keystore altered.
SQL> exit
$
c. Use the impdp command to import the OE.CUST_PAYMENT_INFO table.
$ impdp oe@pdb2 tables=cust_payment_info directory=dp
…
Password: ******
…
ORA-39002: invalid operation
ORA-39174: Encryption password must be supplied.
$
a ble
f e r
ans
n - t r
a no
h a s
Practices for m ) Lesson
e ฺ 9
o uid Key Vault
a ilฺc Oracle
Installing G
g m ent
c a @ tu9 d
Chapter
i
ht this S
a s
f p r ap use
a ( to
i c
ht cens e
a s li
rap
mur P
Fla
Assumptions
Due to the memory requirements of the Oracle Key Vault, the em13 and cl1 virtual machines
should be shut down, as described at the end of the Practice 8.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Practices Overview
In these practices, you install Oracle Key Vault version 12.2 and perform basic configuration.
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Tasks
1. As self-assessment, choose the right definition for each term:
a. Oracle Key Vault
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
b. Endpoint
c. Virtual wallet
1. Can be a database server, middleware server, or generic server system that contains
the keys that you want to manage with Oracle Key Vault
2. Is a container for security objects in Oracle Key Vault that you upload from endpoints to
share access by group of servers
3. Is a software appliance that consists of a pre-configured operating system, an Oracle
a ble
database, and an APEX application f e r
ans
n - t r
2. If you have access to outside Internet connections, locate the Oracle Key Vault o
documentation on the Oracle Help Center.
s an
ha
a. Open a browser and enter the URL http://docs.oracle.com.
)
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
P r a
r
u b. Locate and click the Database user assistance icon.
m
Fla
d. Scroll to the Oracle Key Vault section and click the Release 12.2 link.
e. If time permits, review the Oracle Key Vault Installation and Configuration information
in Key Vault Administrator’s Guide. Determine the minimum hardware configuration
required for the Oracle Key Vault installation.
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
r a
mur P
Fla
Overview
In this practice, you will watch the installation and post-installation videos. These videos
demonstrate similar steps to the following practices, in case the practice cannot be performed
due to time or equipment limitations.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Your instructor will advise you whether the Virtual Machine environment can be used to run the
Oracle Key Vault lab steps.
Tasks
1. If necessary, log on to the host desktop as user oracle. Change to the Videos directory.
$ cd Videos
2. Use the vlc program to watch the ovk_install.mp4 video, which demonstrates the
a ble
Practice 9-3 installation steps. Any messages from vlc may be ignored.
f e r
ans
$ vlc okv_install.mp4
n - t r
3. Use the vlc program to watch the ovk_post_install.mp4 video, which demonstrates o
the Practice 9-4 post installation steps.
s an
$ vlc okv_post_install.mp4 ) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Overview
In this practice, you install the Oracle Key Vault from DVD. This involves booting the Key Vault
machine into install mode and responding to a few basic questions. The process copies the
required files from DVD to disk. You then remove the DVD and reboot the machine to finalize
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
the configuration. Because these two major operations take up to 45 minutes with limited user
interaction, you may wish to review the steps in this practice and start at Practice 9-3.
Tasks
1. Log in, or return to the virtual machine host.
2. Verify that only the database virtual machine and the control domains (Domain-0) are
running.
a ble
[Host Desktop]$ sudo xm list
f e r
Name ID Mem VCPUs State Time(s)
ans
Domain-0 0 1024 2
n - t
r----- 322348.3r
db1 1 3072
a no 1 -b---- 113232.9
em13 12
h a s
9216 2 -b---- 36465.1
[Host Desktop]$ m ) eฺ
o id by logging on as
ilฺc down
a. If the em13 or cl1 machines are running, shut them
a G ugracefully
root and issuing the shutdown –P now g m
command.
e n t
[Host Desktop]$ ssh -l root
t i c a@em13Stud
root@em13's password:
a s h this
Last login: Fri r p 9 s04:50:07
aDec e 2016 from 192.0.2.1
( f p o u
[root@em13
t i c a se t
~]# shutdown -P now
p a sh licmessage
en from [email protected]
P ra Broadcast
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o uid(wipes system) and
4. Using the arrow keys on your keyboard, select and a ilฺc G
highlight Install
g
press Enter. The screen will scroll initialization
m e n
information
tsimilar to the first screenshot,
c a@to the
and proceed to Package Installationisimilar
d screenshot.
tusecond
s t
h this S
a
ap use
( f p r
i c a e to
a s ht cens
r a p li
mur P
Fla
In the development environment for the course, this took 15-20 minutes. After the core
installation is complete, you will be prompted for an installation passphrase.
a ble
f e r
a n s
n
5. Enter a passphrase and record it carefully because it will be required several times,
r
-t and is
also the emergency access code. n o
s a
) ha offrom
It must contain 8 or more characters and contains at least one of each
uppercase letter, a lowercase letter, a number, and a special character
the following: an
the set: period
o e ฺ
m A reasonable
(.), comma (,), underscore (_), plus (+), colon (:) andcspace.
i l ฺ u id example would
be: My passcode is No 1.
m a t G
Because the mouse has no effect on the @ g
console, use n
dethe Tab key to highlight OK and
press Enter. i c a S t u
a
6. On the Confirm Passphrase screen,s ht enter
t h i
thes passphrase again, press Tab to the highlight
OK, and press Enter rap e
7. On the Successa (fppresstEnter
page, o us
h
8. On the Select
s ticNetwork
e n se page, you should have only one interface (network card)
Interface
pa If necessary,
identified.
r a lic use the Up and Down keys to select the line, and press Enter.
mur P
Fla
a ble
f e r
ans
n - t r
o
an
10. Enter the IP address 192.0.2.22, ensure the Network Mask is set to 255.255.255.0,
and set the Gateway to 192.0.2.1.
ha s
)
m ideฺ
c o
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
11. Tab to the Reboot line and press Enter. The VNC console is lost during the reboot. If you
were to re-establish that console you would see that you are returned to the initial install
screen.
Because there is no DVD eject capability, the VM will continue to boot from the DVD to the
first install screen. You must stop the VM and switch to another configuration.
12. In a terminal window, shut down the VM and verify it is down.
[Host Desktop]$ sudo xm shutdown -w okv
Domain okv-install terminated
All domains terminated
[Host Desktop]$ sudo xm list
Name ID Mem VCPUs State Time(s)
Domain-0 0 1024 2 r----- 323582.5
db1 1 3072 1 ------ 114374.3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
following is displayed.
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
15. Browse the various selections in the console.gWhen m finished,
e n t scroll down to the Power Off
setting click Enter. You will be challenged
c a@with thet d
upasscode you created earlier and the
t i S
sh tfor
machine will power-off. The passphrase
including the final period. pa h isa restored image is My passcode is No 1.
f p r a use
a ( to
i c
ht cens e
p a s li
r a
u rP
m
Fla
16. Verify that the virtual machine is off by using the sudo xm list command. This should be
familiar by now.
Overview
In this practice, you start Oracle Key Vault that has just been installed, and perform the required
post-install tasks. After the machine has been started, all tasks are performed in the browser.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Optional: If you experienced any difficulty with the installation up to this point, or decided to
skip Practice 9-2, you can install a copy of the image needed for this practice. Because this
extracts a large file, it may take several minutes.
[Host Desktop]$ sudo su -
[Host Desktop]# cd /OVS/running_pool/okv
[Host Desktop]# ./okv_setup.sh
a ble
This script installs the Oracle Key Vault disk image
f e r
in preparation for specific tasks in the course.
ans
n - t r
Select one of the following:
a no
h a s
m ) eฺ
0 - abort/exit
o
1 - ready to install Oracle Key Vault
a ilฺc Guid
2 - ready for first boot g m ent
3 - ready for post-install
t i c a@ tud
configuration
S
4 - ready for Key Vault
a s h operations
t h is
f p r ap use
Enter your (selection to (0-4): 3
i c a e
a s ht that
Confirm
c e s want to set up for post-install: (y/n) y
nyou
rapRemoving liokv_disk1of1.img and extracting post-install image
mur P Done.
Fla
[Host Desktop]# exit
2. Open a terminal, go to the Key Vault directory, start the Key Vault.
The vm-postinstall.cfg configuration file uses a backup of the Key Vault taken at the
end of the installation phase. This permits you to catch up without waiting for the entire
installation process.
[Host Desktop]$ cd /OVS/running_pool/okv/
[Host Desktop]$ sudo xm create okv
Using config file "/etc/xen/okv".
Started domain okv (id=25)
[Host Desktop]$ sudo xm list
Name ID Mem VCPUs State Time(s)
Domain-0 0 1024 2 r----- 328931.3
db1 1 3072 1 ------ 118172.3
okv 25 4096 1 ------ 4.3
[Host Desktop]$
oracle@db1's password:
Last login: Thu Dec 15 04:28:36 2016 from 192.0.2.1
[oracle@db1 ~]$ firefox &
[1] 25161
[oracle@db1 ~]$
5. Go to the URL https://okv.example.com.
a ble
f e r
a n s
t r
on- page
6. Because this uses a self-signed certificate, you will probably see an untrusted connection
page. Click Advanced to expand the information panel. (If the Installation n
Passphrase
is displayed, skip to Task 9.) s a
a
) h eฺ
m
co uid
i l ฺ
g ma ent G
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
t ens
hException e
p a
7. Click Add s l i c …
P ra
r
mu
Fla
a ble
f e r
ans
n - t r
o
9. an
The Initial Login page is displayed. Enter the passphrase My passcode is No 1., and
s
click Login.
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
g m ent
c
Enter the following values on the Post-Install
t i S tud page, and then click Save.
a@ Configuration
Key Administrator a s h OKV_KEYS_KATE
t h is
Password f p r ap usStudent_1
e
a ( to Student_1
i c
Re-enter tPasswords e
p
Fulla sh licen
Name
P r a Kate Key Admin
u r Email .
l a m
F System Administrator OKV_SYS_SEAN
Password Student_1
Re-enter Password Student_1
Full Name Sean System Admin
Email
Audit Manager OKV_AUD_AUDREY
Password Student_1
Re-enter Password Student_1
Full Name Audrey Audit Mgr
Email
Recovery Passphrase Note your recovery passphrase; oracle_4U
Re-enter Password oracle_4U
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
a ble
Be very careful when changing these passwords. Until you have added more
f e r
administrators, recovery from a lost password may require reinstall.
ans
13. Optionally, review the Home page and the Users page. If an alert is displayed on the home n - t r
o
an
page, scroll right to display the Click here for details link and view the details.
s
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
14. Click Logout (top-right) and proceed to test the next administrator.
15. On the Oracle Key Vault Login page, enter OKV_KEYS_KATE as User Name and your
initialized Password (Student_1), and then click Login.
a. On the Reset Password page, carefully update the password and click Save.
b. Optionally review the Keys and Wallets page (top menu), and then click Logout.
16. Repeat for OKV_AUD_AUDREY. On the Oracle Key Vault Login page, enter
OKV_AUD_AUDREY as User Name and your initialized Password (Student_1), and then
click Login.
a. On the Reset Password page, carefully update the password and click Save.
b. Optionally review the Reports page (top menu), and then click Logout.
Overview
In this practice, you shut down the Oracle Key Vault that you installed and switch to a saved
version to ensure usernames and passwords are consistent for the following practices.
If you have created all users as described, and use the same passwords as described, you may
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
simply review the steps and continue to use your virtual machine.
Tasks
1. Shut down the machine from the console. If necessary, review Practice 9-2 Task 3 to
access a console using VNC.
a. Select Power Off and press Enter. Note that the console display is subtly different from
the console previously shown. The Change Installation Passphrase item is no
longer available. a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
a s h this
f p r ap use
b. Use the root a ( to
passphrase/password you created in Practice 9-3 Task 10 instead of the
t i
h cen
installation
c s
passphrase e to shut down the machine.
p a s li
r a
mur P
Fla
2. Verify the machine is shut down by using the sudo xm list command.
0 - abort/exit
1 - ready to install Oracle Key Vault
a ble
f e r
2 - ready for first boot
ans
3 - ready for post-install configuration
n - t r
4 - ready for Key Vault operations
a no
h a s
m) configuration
Enter your selection (0-4): 4
Confirm that you want to install the c o d e ฺ
i l ฺ final
u i image:
ma ent G
(y/n) y
Removing okv_disk1of1.img and g
a @ t u d
extracting final configuration
image
s h tic is S
Done.
a p a e th
fpr toVault
us
[Host Desktop]# exit
4. Open a terminal,ago( to the Key directory, and start the Key Vault.
t i c s e
p a sh Desktop]$
[Host
l i c en cd /OVS/running_pool/okv/
P ra [Host Desktop]$ sudo xm create okv
r
mu
Using config file "/etc/xen/okv".
a ble
f e r
ans
n - t r
a no
h a s
Practices for m ) Lesson
e ฺ 10:
o id
Workinga ilฺcwith
G uEndpoints and
m
g den
Wallets t
@ tu10
h t ica Chapter
s S
p a s
e t hi
( f pra to us
h t ica nse
p a s lice
ra
mur P
Fla
Practices Overview
In these practices, you enroll an Oracle Database 12c server as an Oracle Key Vault endpoint
and learn to use the Oracle Key Vault management console.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Overview
In this practice, you watch videos to demonstrate how to enroll endpoints, set up encryption and
use wallets. These videos demonstrate similar steps to the following practices, in case the
practice cannot be performed due to time or equipment limitations.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Your instructor will advise you whether the Virtual Machine environment can be used to run the
Oracle Key Vault lab steps.
Tasks
1. If necessary, log on to the host desktop as user oracle. Change to the Videos directory.
$ cd Videos
2. Use the vlc program to watch the ovk_11enpoints.mp4 video, which demonstrates the
a ble
Practice 10-2 endpoint enrollment steps. The messages from vlc may be ignored.
f e r
ans
$ vlc okv_11endpoint.mp4
n - t r
3.
no
Use the vlc program to watch the ovk_encrypt.mp4 video, which demonstrates the
Practice 10-3 steps to set up for database encryption. a
h a s
$ vlc okv_encrypt.mp4
m ) eฺ
o uiddemonstrates the
a il c which
4. Use the vlc program to watch the ovk_wallet.mp4 ฺvideo,
Practice 10-4 steps to upload and download a wallet. G
g m ent
$ vlc okv_wallet.mp4
t i c a@ Stud
a s h this
f p r ap use
a ( to
i c
ht cens e
p a s li
r a
u rP
m
Fla
In this practice, you enroll an Oracle Database server as an Oracle Key Vault endpoint. The
task steps are performed from the Oracle Key Vault management console, as well as the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
command-line interface.
Assumptions
You have completed Practice 9 and have a database machine, db1, and a Key Vault machine,
okv, running.
You are logged in to your host machine as user oracle.
Tasks
a ble
f e r
1. Connect to the db1 VM by using X tunneling, open a web browser, and open the Oracle
ans
Key Vault management console.
n - t r
no
a. From the host desktop, start a new terminal session to the db1 host.
a
[Host Desktop]$ ssh -X -l oracle db1
h a s
oracle@db1's password:
Last login: Tue Dec 20 07:52:06 2016ฺc o m)192.0.2.1
i d eฺ
ail t Gu
from
[oracle@db1 ~]$ m
g den
b. Start Firefox as your web browser.a@
h t ic is Stu
$ firefox &
p a s th
[1] 6129 a
pr to us e
[oracle@db1(f~]$
t a se
icURL
c. Enter h the n
https://okv.example.com to access the Oracle Key Vault management
a s
pconsole. li c e
r a
mur P
Fla
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
a s h this
r ap isuassystem
Note that endpoint registration
f p e administrator task. Also note the endpoint
( bottomtofo the page.
enrollment link at the
a
i
3. Click Endpoints.
h c
t ense
pa s lic
r a
u rP
m
Fla
5. Enter and confirm the following values, and then click Register:
Endpoint Name CUSTOMER_DB
Type Oracle Database a ble
f e r
Platform Linux
ans
Description Customer Database orcl n - t r
o
Administrator Email s an
[email protected]
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
After successful registration, the endpoint appears with an enrollment token. In real world
deployments, the enrollment token is communicated by the system administrator in a
secure way to the endpoint administrator. This enrollment token is used for authentication
to download the endpoint software by the endpoint administrator.
Simulate this interaction by copying the enrollment token as the system administrator and
pasting it as the endpoint administrator.
a ble
f e r
a n s
7. Open another browser tab and point to the same URL https://okv.example.com. n r
-Ast the
o
click the Endpoint Enrollment and Software Download link. s a n console),
endpoint administrator (without logging in to the Oracle Key Vault management
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr totoken
8. Paste or enter the enrollment
e
usand click Submit Token.
( f
h t ica nse
p a s lice
P ra
r
mu
Fla
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
g den
10. When prompted, select Save File and click OK.
@
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
P ra
u r
m
Fla
a ble
f e r
ans
n - t r
o
12. Close the Oracle Key Vault enrollment window.
s an
ha
13. Optionally return to the Oracle Key Vault management console and view the endpoints. If
)
necessary, log in again as OKV_SYS_SEAN.
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Note the status has changed to Enrolled and the Enrollment Token is cleared.
14. Click Logout and close the browser.
15. Create a directory for the Oracle Key Vault client and install the Oracle Key Vault endpoint
software. The –d option specifies the location where the Oracle Key Vault endpoint
software will be installed. The endpoint administrator who is performing the endpoint
software installation must have read and write access to this location. In training, use the
auto-login wallet by pressing Enter when prompted.
a. Create the directory and move the client software into that directory.
$ mkdir /u01/app/oracle/okvutil/
$ mv okvclient.jar /u01/app/oracle/okvutil/
s h tic ~]#
TDE can directly
e n scde /u01/app/oracle/okvutil/bin
connect
a a
[root@db1
p[root@db1 licbin]# ls
r
mur P okveps.x64 okveps.x86 okvutil root.sh
Fla [root@db1 bin]# ./root.sh
Creating directory: /opt/oracle/extapi/64/hsm/oracle/1.0.0/
Copying PKCS library to /opt/oracle/extapi/64/hsm/oracle/1.0.0/
Setting PKCS library file permissions
Installation successful.
[root@db1 bin]#
18. Switch back to the oracle OS user. If you want to confirm your login, use the whoami
command.
]# exit
logout
$ whoami
oracle
$
software installation has some potential issues that must be resolved before continuing
with this training.
$ cd /u01/app/oracle/okvutil/bin
$ ./okvutil list
No objects found
$
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
r a
mur P
Fla
Overview
In this practice, you set up test users and data in two database instances and encrypt them with
Transparent Data Encryption (TDE) for subsequent practices.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Assumptions
The orcl database instance is running and the database has been enrolled with Oracle Key
Vault.
Tasks
1. If necessary, log in to the db1 VM and verify that the orcl database is running. Review
earlier practices if necessary to perform this task.
2. View the encryption parameters and confirm that transparent data encryption is enabled. a ble
f e r
$ . oraenv
ans
ORACLE_SID = [oracle] ? orcl
n - t r
The Oracle base has been set to /u01/app/oracle
a no
$ sqlplus /NOLOG
h a s
m ) eฺ
o uid Dec 20 09:25:49
SQL*Plus: Release 12.1.0.2.0 Production
a ilฺc onGTue
2016
g m ent
c @ tud
aOracle.
Copyright (c) 1982, 2014, t i
h this S All rights reserved.
a s
f p r aaspsysdba
u s e
SQL> connect
a ( /
to
i c
t ens
Connected.
hCOLUMN e
a
SQL>
p s l i c parameter FORMAT A30
ra
ur P
SQL> COLUMN value FORMAT A10
SQL>
*
ERROR at line 1:
ORA-01918: user 'INFOSEC_ISABEL' does not exist
User created.
Grant succeeded.
Grant succeeded.
drop user dba_debra cascade
a ble
*
f e r
ERROR at line 1:
ans
ORA-01918: user 'DBA_DEBRA' does not exist
n - t r
o
User created.
s an
Grant succeeded.
) ha
Grant succeeded.
c o m ideฺ
Connected.
m ailฺ t Gu
g den
drop tablespace bankingCLEAR including contents and datafiles
@
*
h t ica is Stu
ERROR at line 1:
p a s th
a
pr to us e
ORA-00959: tablespace 'BANKINGCLEAR' does not exist
( f
ica nse
Tablespace created.
h t
DROP USER
s lice banking cascade
a p a *
r
ur P
ERROR at line 1:
m
Fla
ORA-01918: user 'BANKING' does not exist
User created.
Grant succeeded.
drop table banking.customers
*
ERROR at line 1:
ORA-00942: table or view does not exist
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
System altered.
SQL>
4. Your output may look a little different depending on your environment. Confirm that you can
query the data that is to be encrypted, and then exit.
SQL> select ccn from banking.customers;
CCN
a ble
--------------------
f e r
5421-5424-1451-5340
ans
5325-8942-5653-0031
n - t r
o
4553-0984-2344-4101
s an
4489-4023-0489-0492
) ha
5193-0013-0002-2345
c o m ideฺ
4545-5702-4211-8889
m ailฺ t Gu
5900-4451-8812-7171
@ g den
4331-4921-5031-9871
h t ica is Stu
4442-1902-7477-3239
p a s th
a
pr to us
4921-1212-6612-0080 e
( f
ica nse
5890-1454-3554-9886
h t
s lice
11a rows selected.
p
ra
m ur P
Fla
SQL> exit
$
5. If you completed Lesson 7, the wallet should exist. If it does not exist, create a directory for
the Oracle wallet.
$ ls /u01/app/oracle/admin/orcl/wallet
ls: cannot access /u01/app/oracle/admin/orcl/wallet: No such
file or directory
$ mkdir /u01/app/oracle/admin/orcl/wallet
$
6. Confirm that the sqlnet.ora file contains a path that points to the wallet directory. If it
does not, add it at the end of the file.
$ grep ENCRYPTION_WALLET_LOCATION
$ORACLE_HOME/network/admin/sqlnet.ora
$
$ cat <<EOF >> $ORACLE_HOME/network/admin/sqlnet.ora
EOF
$ tail $ORACLE_HOME/network/admin/sqlnet.ora
#
a ble
ENCRYPTION_WALLET_LOCATION=
f e r
(SOURCE =
ans
(METHOD = FILE) n - t r
(METHOD_DATA =
a no
(DIRECTORY = /u01/app/oracle/admin/orcl/wallet)))
h a s
m ) eฺ
o
$
a ilฺc Guid
Note: The path points to the directory for theg m wallet.
local e n t
c
7. If it does not exist, create an Oracle iwallet.
t tud 7, Task 1 as your guide.) Open the
a@(UseSLesson
wallet.
a s h this
a. Use the following tora p theswallet
create e if the ls command does not display
ewallet.p12.( f p to u
i c
t ens a e
$ ls h$ORACLE_BASE/admin/orcl/wallet
a s
p$ sqlplus / lasicsyskm
r a
mur P
Fla
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced Analytics and Real
Application Testing options
SQL> EXIT
$ ls $ORACLE_BASE/admin/orcl/wallet
ewallet.p12
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
a ble
64bit Production
f e r
ans
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options n - t r
a no
SQL> SELECT WRL_PARAMETER, STATUS, WRL_TYPE FROM
h a s
V$ENCRYPTION_WALLET;
m ) eฺ
o
a ilฺc Guid
WRL_PARAMETER
g m ent
t i c a@ Stud
----------------------------------------------------------------
--
a s h this
STATUS
r a p se WRL_TYPE
a (fp to u
------------------------------ --------------------
s h tic ense
/u01/app/oracle/admin/orcl/wallet/
apa lic
CLOSED FILE
r
m ur P SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN
Fla IDENTIFIED BY secret;
2
keystore altered.
WRL_PARAMETER
----------------------------------------------------------------
--
STATUS WRL_TYPE
------------------------------ --------------------
/u01/app/oracle/admin/orcl/wallet/
OPEN FILE
Connected.
SQL> ALTER TABLE banking.customers MODIFY (ccn ENCRYPT);
Table altered.
9. Confirm the data is still displayed correctly.
SQL> SELECT * from banking.customers;
a ble
f e r
FIRST_NAME LAST_NAME CCN
ans
-------------------- --------------------
t r
--------------------
n -
o
an
Mike Anderson 5421-5424-1451-5340
Jon Hewell
ha s 5325-8942-5653-0031
Andrew Forsyth )
m ideฺ
4553-0984-2344-4101
c o
ailฺ t Gu
Ellen Kane 4489-4023-0489-0492
Randall
m Summers
g den
5193-0013-0002-2345
Julia @ Cortez 4545-5702-4211-8889
Melissa
h t ica is Stu
Hiam 5900-4451-8812-7171
Elise
p a s th Fenters 4331-4921-5031-9871
a
pr to us e
Paul
( f Watts 4442-1902-7477-3239
Jim
h t ica nse Johnson 4921-1212-6612-0080
p a s lice
Scott Manning 5890-1454-3554-9886
ra
m ur P 11 rows selected.
Fla SQL>
ERROR at line 1:
ORA-00959: tablespace 'BANKINGENC' does not exist
a s
12.1.0.2.0 - 64bit Production
p sOLAP,
u e
pra to options
With the Partitioning, Advanced Analytics and Real
Application(fTesting
$
h t ica nse
p a s lice
ra
mur P
Fla
Overview
In this practice, you upload an existing Oracle wallet from the Oracle Database endpoint to
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Oracle Key Vault for long-term retention. Then you download the wallet and demonstrate that
you can query encrypted data by using the downloaded wallet.
Assumptions
You successfully completed the previous practice.
Tasks
1. Connected to the db1 VM and open the Oracle Key Vault management console in your
a ble
web browser. Log in as the OKV_KEYS_KATE key administrator.
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a sto Keyslic&eWallets and click the Create button.
ra
2. Navigate
P
u r
m
Fla
a ble
f e r
ans
n - t r
4. When the CUSTOMER_DB_WALLET wallet appears on the page (which means that it has o
been created), click the Details pencil icon.
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t icaWalletnsAccess
e Settings section.
pa s
5. Click Add in the
lic e
r a
mur P
Fla
a ble
f e r
ans
n - t r
a no
has wallet in Oracle Key
7. Note the changed Access. Because you are viewing a newly )created
o msection.
Vault, it displays No Members found in the Wallet Contents
d e ฺ Save again.
Click
c i
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
P ra
u r
m
Fla
8. Minimize the Oracle Key Vault management console and open a new terminal window on
the db1 VM. (As always, set the environment variables to the orcl instance.)
$ ssh oracle@db1
oracle@db1's password:
Last login: Tue Dec 20 10:54:00 2016 from 192.0.2.1
[oracle@db1 ~]$ . oraenv
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
a. Ensure that the listener is up. If not, start it with: lsnrctl start. IF you need to start
the listener, wait until the database registers or use the ALTER SYSTEM REGISTER
command to register the database with the listener manually.
$ lsnrctl status
1521))) ha s
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db1.example.com)(PORT=
)
m ideฺ
STATUS of the LISTENER
c o
------------------------
m ailฺ t Gu
Alias LISTENER
@ g den
Version
t ica is Stu
TNSLSNR for Linux: Version 12.1.0.2.0
h
- Production
p a s th
Start Date a
pr to us e
20-DEC-2016 11:19:27
( f
ica nse
Uptime 0 days 0 hr. 0 min. 56 sec
h t
s lice
Trace Level off
a p a
Security ON: Local OS Authentication
r
mur P SNMP OFF
Fla
Listener Parameter File
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.o
ra
Listener Log File
/u01/app/oracle/diag/tnslsnr/db1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db1.example.com)(PORT=
1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this
service...
Service "orclXDB.example.com" has 1 instance(s).
$ cd /u01/app/oracle/okvutil/bin
$
11. Start the upload and provide the password of the wallet; secret, in this example.
$ ./okvutil upload -t WALLET -l
/u01/app/oracle/admin/orcl/wallet -g CUSTOMER_DB_WALLET
Enter source wallet password:
Upload succeeded
a ble
$
f e r
If you receive an error, review the spelling of the wallet name that you created in the Key ans
Vault console. n - t r
o
an
12. Return to the Oracle Key Vault management console in your browser. On the Wallets page,
s
Contents section. ) ha
click the CUSTOMER_DB_WALLET link and notice that entries appear in the Wallet
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
.
SQL> alter system set encryption wallet close identified by
"secret";
System altered.
SQL>
16. Query both test tables to confirm that the data is readable, and then exit.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
h t i ca s Stu
11 rows selected. s
p a e t hi
( f p ra us
SQL> SELECT a * fromtobanking.customersenc;
h i c
t ense
a s lic
rapFIRST_NAME LAST_NAME CCN
Fla
Mike Anderson 5421-5424-1451-5340
Jon Hewell 5325-8942-5653-0031
Andrew Forsyth 4553-0984-2344-4101
Ellen Kane 4489-4023-0489-0492
Randall Summers 5193-0013-0002-2345
Julia Cortez 4545-5702-4211-8889
Melissa Hiam 5900-4451-8812-7171
Elise Fenters 4331-4921-5031-9871
Paul Watts 4442-1902-7477-3239
Jim Johnson 4921-1212-6612-0080
Scott Manning 5890-1454-3554-9886
11 rows selected.
SQL> exit
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
a ble
f e r
ans
n - t r
a no
h a s
Practices for m ) Lesson
e ฺ 11:
Using
o
lฺc GTDE uid with Oracle
a iDirect
g m ent
Database
t i c a@ Stud
a s h thChapter
is 11
f p r ap use
a ( to
i c
ht cens e
a s li
rap
mur P
Fla
Practices for Lesson 11: Using Direct TDE with Oracle Database
Chapter 11 - Page 1
Practices for Lesson 11: Overview
Practices Overview
In these practices, you use the Online Master Key with Oracle Key Vault and perform a number
of different tasks, switching between the system, endpoint, and key administrator roles.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Practices for Lesson 11: Using Direct TDE with Oracle Database
Chapter 11 - Page 2
Practice 11-1: TDE Direct Video
Overview
In this practice, you watch videos to demonstrate how to configure Oracle Key Vault to interact
with a database. The video demonstrates similar steps to the following practices, in case the
practice cannot be performed due to time or equipment limitations.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Your instructor will advise you whether the Virtual Machine environment can be used to run the
Oracle Key Vault lab steps.
Tasks
1. If necessary, log on to the host desktop as user oracle. Change to the Videos directory.
$ cd Videos
2. Use the vlc program to watch the ovk_tde.mp4 video, which demonstrates the Practice
a ble
11-2 steps for using TDE master keys. The messages from vlc may be ignored.
f e r
ans
$ vlc okv_tde.mp4
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Practices for Lesson 11: Using Direct TDE with Oracle Database
Chapter 11 - Page 3
Practice 11-2: Using the Online Master Key with Oracle Key Vault
Overview
In this practice, you perform a number of different tasks, switching between the system,
endpoint, and key administrator roles.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Assumptions
a ble
The Practice 10 has been completed successfully. The db1 and okv VMs are running. The f e r
ans
orcl database on db1 and the listener on db1 are up.
n - t r
Tasks a no
h
1. From the desktop, start a terminal session on the db1 VM and pointa sto the orcl database
instance. m ) eฺ
o
$ ssh -X -l oracle db1 a ilฺc Guid
oracle@db1's password: g m ent
Last login: Tue Dec 20 11:19:00
t i c a@ S2016 tud from 192.0.2.1
$ . oraenv
a s h this
p
ORACLE_SID = [oracle]
f r ap u?seorcl
The Oracle a (base hasto been set to /u01/app/oracle
h i c
t ense
$
s
pa that thelilistener
c is up. If not, start it with the lsnrctl start command.
r a
2. Confirm
u r P $ lsnrctl status
m
Fla LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 21-DEC-
2016 04:18:46
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db1.example.com)(PORT=
1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0
- Production
Start Date 20-DEC-2016 11:19:27
Practices for Lesson 11: Using Direct TDE with Oracle Database
Chapter 11 - Page 4
Uptime 0 days 16 hr. 59 min. 19 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.o
ra
Listener Log File
/u01/app/oracle/diag/tnslsnr/db1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db1.example.com)(PORT=
1521)))
a ble
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
f e r
Services Summary...
ans
Service "orcl.example.com" has 1 instance(s).
n - t r
Instance "orcl", status READY, has 1 handler(s) for this
a no
service...
h a s
Service "orclXDB.example.com" has 1 instance(s).
m ) eฺ
o
ilฺc Guid
Instance "orcl", status READY, has 1 handler(s) for this
a
service...
g m ent
The command completed successfully
t i c a@ Stud
$
a h this
sVault,
3. Before migrating to Oracle p Key close the wallet in SQL*Plus by using your password.
r a s e
p to u the password to welcome1.)
(Remember in Practice
( f 10 you changed
t
$ sqlplus
h ica/ as n e
ssyskm
a s
pSQL*Plus: e
licRelease 12.1.0.2.0 Production on Wed Dec 21 04:52:46
r a
mur P 2016
Fla Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
keystore altered.
SQL>
4. Note the wallet information
Practices for Lesson 11: Using Direct TDE with Oracle Database
Chapter 11 - Page 5
SQL> select wrl_type, status from v$encryption_wallet;
WRL_TYPE STATUS
-------------------- ------------------------------
FILE CLOSED
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
SQL>
5. Exit SQL*Plus and modify the sqlnet.ora file to change METHOD=FILE to METHOD=HSM.
Choose vi or other available editors. Note that opening a shell using the exclamation mark
(!) is insufficient.
SQL> exit
$ cd $ORACLE_HOME/network/admin
a ble
$ vi sqlnet.ora
f e r
Adjust the relevant area of the sqlnet.ora file to comment out
ans
ENCRYPTION_WALLET_LOCATION for METHOD = FILE and create an entry with METHOD
n - t r
= HSM, similar to the following.
a no
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, LDAP)
h a s
# m ) eฺ
o
#ENCRYPTION_WALLET_LOCATION=
a ilฺc Guid
# (SOURCE = g m ent
# (METHOD = FILE)
t i c a@ Stud
(METHOD_DATA = sh is
#
a t h
# (DIRECTORY
f p r a=p/u01/app/oracle/admin/orcl/wallet)))
u s e
a ( to
i c
ht cens e
ENCRYPTION_WALLET_LOCATION=
a s
rap(SOURCE li=
mur P (METHOD = HSM)
Fla
(METHOD_DATA =
(DIRECTORY = /u01/app/oracle/admin/orcl/wallet)))
6. Oracle Key Vault 12 looks for configuration information in the $ORACLE_BASE/okv/orcl
directory. In preparation for the migration, create the directory and copy the configuration
file.
$ mkdir –p $ORACLE_BASE/okv/orcl
$ cp $ORACLE_BASE/okvutil/conf/*.ora $ORACLE_BASE/okv/orcl
7. Open a new SQL*Plus session and confirm that you have two wallet types: FILE and HSM,
both in a CLOSED state.
$ sqlplus / as syskm
Practices for Lesson 11: Using Direct TDE with Oracle Database
Chapter 11 - Page 6
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
WRL_TYPE STATUS
-------------------- ------------------------------
FILE CLOSED
a ble
f e r
HSM CLOSED
ans
n - t r
SQL>
a no
has wallet during the
8. Use the migration command to move the TDE master key from the wallet file to Oracle Key
Vault, of course, with your passwords. Because you used the )auto-login
endpoint software installation, the password in this example o mis “null.”
d e ฺ
However, if you used
l ฺ c u i
ai t G
an endpoint password, that password needs to be entered.
SQL> administer key managementgm e n
set encryption key identified by
@ d
tu backup;
"null" migrate using "welcome1"
h t ica is Swith
p a s th
keystore altered. a
pr to us e
( f
SQL> hexitt ica nse
$a
p s lice
P ra
r
9. Optionally, list the wallet directory to view the automatically created backup file. The sample
mu output has been trimmed to remove rows, and will have different date and time stamps than
Fla on your system.
$ ls -l /u01/app/oracle/admin/orcl/wallet
total 12
…
-rw-r-----. 1 oracle oinstall 6048 Dec 21 06:18
ewallet_2016122111181704.p12
-rw-r-----. 1 oracle oinstall 6048 Dec 21 06:18 ewallet.p12$
10. Invoke the Firefox browser and enter the https://okv.example.com URL.
[oracle@db1 ~]$ firefox &
Practices for Lesson 11: Using Direct TDE with Oracle Database
Chapter 11 - Page 7
11. Log in to the Oracle Key Vault management console as the OKV_KEYS_KATE key
administrator.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
12. Logged in to the Oracle Key Vault management console as the OKV_KEYS_KATE key
administrator, view the TDE items under All Items.
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
a s h this
f p r ap use
(
amonths topassed and as the endpoint administrator, you have the task
13. Assume thattsix i c e
ns key. Because you used the auto-login wallet during the endpoint
hthe TDEcemaster have
a s
of rotating
li the password in this example is “null.” However, if you used an
p installation,
r a
software
keystore altered.
SQL> exit
$
14. Exit all windows.
Practices for Lesson 11: Using Direct TDE with Oracle Database
Chapter 11 - Page 8
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
n - t r
a no
h a s
Practices for m ) Lesson
e ฺ 12:
o uid Key Vault
Performing
a ilฺc G Oracle
g m ent
Administrative Tasks
a @ t u d
s h tic Chapter
i s S 12
a
p se t h
r a
a (fp to u
s h tic ense
rapa lic
mur P
Fla
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 1
Practices for Lesson 12: Overview
Practices Overview
In these practices, you will perform audits, archive and delete audit trail records, and configure
and perform backups.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 2
Practice 12-1: Key Vault Administration Videos
Overview
In this practice, you watch videos to demonstrate how to perform basic Key Vault system
administration sch as auditing and backups. These videos demonstrate similar steps to the
following practices, in case the practice cannot be performed due to time or equipment
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
limitations.
Your instructor will advise you whether the Virtual Machine environment can be used to run the
Oracle Key Vault lab steps.
Tasks
1. If necessary, log on to the host desktop as user oracle. Change to the Videos directory.
$ cd Videos
a ble
2. Use the vlc program to watch the ovk_sysadmin.mp4 video, which demonstrates system
f e r
administration tasks such as setting system and logging. The messages from vlc may be
ans
ignored.
n - t r
$ vlc okv_sysadmin.mp4
a no
a s
3. Use the vlc program to watch the ovk_audit.mp4 video, which demonstrates
h the Practice
12-2 steps to set up for database encryption. )
m ideฺ
c o
$ vlc okv_audit.mp4
m ailฺ t Gu
4. Use the vlc program to watch the ovk_backup.mp4
@ g dvideo,e n which demonstrates the
Practice 12-3 steps to perform backups
t i S tu
caandsrecovery.
$ vlc okv_backup.mp4s
a h t hi
p e
( f pra to us
h t ica nse
p a s lice
P ra
r
mu
Fla
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 3
Practice 12-2: Using and Managing the Audit Trail
Overview
In this practice, you log on to the Oracle Key Vault management console as an administrator
with audit privileges, OKV_AUD_AUDREY, and review and manage the audit trail.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Assumptions
You have completed Practice 11. Your db1 and okv machines are up and running. The orcl
database is running, as is the listener on db1.
Tasks
1. Login to the db1 machine as user oracle with X tunnel capability, set your environment to
orcl, and ensure that your database and listener are up.
a ble
$ ssh -X -l oracle db1
f e r
oracle@db1's password:
ans
Last login: Wed Dec 21 05:05:01 2016 from 192.0.2.1 n - t r
o
$ . oraenv
s an
ORACLE_SID = [oracle] ? orcl
) ha
o m ideฺ
The Oracle base has been set to /u01/app/oracle
c
$ lsnrctl status | grep orcl
m ailฺ t Gu
g den
Service "orcl.example.com" has 1 instance(s).
@
h t ica is Stu
Instance "orcl", status READY, has 1 handler(s) for this
service...
p a s th
a
pr to us e
Service "orclXDB.example.com" has 1 instance(s).
( f
Instance "orcl", status READY, has 1 handler(s) for this
t ica nse
service...
h
p$a s lice
P
2.Start
a
r your browser to log in to the Oracle Key Vault.
u r
m
Fla
$ firefox https://okv.example.com &
$
3. Access the Oracle Key Vault management console as user OKV_AUD_AUDREY.
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 4
4. Select Reports and click on Audit Trail.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
5. Use some filters to narrow the scope of the trail. ailฺ u
a. Click on Time and select Last Hour. g m n t G
@ d e
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
P ra
u r
m
Fla
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 5
b. Notice that the filter is displayed and a subset of the data is displayed. Check your list
to ensure the time is within the last hour, based on the time zone of the VMs.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
c. Optionally scroll through the filtered list and note the various operations that have been
recorded. Add a filter based on Operation and view the changes in the list. In this
example, the Operation ‘Get Attributes’ filter was selected. a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h
Clickingt icathe Object
on n seidentifier provides detailed information.
s e
r apa lic
mur P
Fla
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 6
6. To manage the amount of information in the audit trail, export and delete rows.
a. Click Export/Delete.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g Export.
b. The current date should be displayed. Click
d e n
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p as the date,
Toachange l iceuse the calendar icon next to the displayed date.
P r
u r c. Select Open with gedit and click OK.
m
Fla
In a production environment, an archive strategy should be developed. Note the data format
used in the export.
d. Close the editor.
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 7
e. Click Delete. On the pop-up dialog box, click OK.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Note that there is one record remaining. Investigate and discuss this.
f. Log out of the console.
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
r a
mur P
Fla
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 8
Practice 12-3: Backing Up the Key Vault
Overview
In this practice, you will take a backup of the Oracle Key Vault.
Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 9
b. Select the System Backup page and click Manage Backup Destinations.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
c. Click Create.
a ble
f e r
ans
n - t r
a no
h a s
m ) eฺ
o
a ilฺc Guid
Note the mandatory LOCAL backup destination.
g m ent
d. Create the backup destination based
t i c a@ S tud in this table and click Save.
on the values
Field
a s hValue this
Destination Name
f p r ap uDaily s eBackup
Hostname ica
( to db1.example.com
ht cens e
Portpas li 22
r a
PDestination Path
u r /home/oracle/okvbackup
l a m Username oracle
F
select Password Authentication
Password oracle
Confirm Password oracle
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 10
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
e. Click Done. n - t r
o
4. Perform the Backup.
s an
a. On the System Backup page, click Backup.
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
P r a
r
u b.
m Enter a name for the backup, ensure that Destination is the one you just created,
Fla select Type ONE-TIME, click Now to clear the Start Time, and click Schedule.
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 11
c. The System Backup page is displayed. Browse some of the other pages for a few
minutes, periodically returning to the System Backup page. After several minutes, the
Status should show DONE and some timing information should be available. In the
example, the backup took about seven minutes.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
n - t r
5. Restore the backup. a no
a. On the System Backup page, click Restore. h a s
m ) eฺ
o
a ilฺc Guid
g m ent
t i c a@ Stud
b. Select the Daily Backup source,
a h wait
screated. t h ifors the list of available backups to be loaded, and
select the backup you p just
f p r a use
a ( to
i c
ht cens e
p a s li
r a
mur P
Fla
c. Enter the Recovery Passphrase oracle_4U that was set in the post-installation
configuration. Depending on available time, you may choose to Cancel or to Restore.
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 12
If you click Restore, the Oracle Key Vault will locate the backup, restore it, and reboot.
This process can take 10 minutes in your environment. If you then log in as System
Administrator and return to the Restore page, you will see the Last Restore Details as
follows:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ close
6. Log out of Oracle Key Vault management console and
t Gtheubrowser.
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
P ra
u r
m
Fla
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 13
Practice 12-4: Cleaning Up
Overview
In this practice, you remove the Oracle Key Vault and start the Oracle Enterprise Manager.
Assumptions
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
Tasks
1. Restore sqlnet.ora
[oracle@db1 ~]$ . oraenv
ORACLE_SID = [oracle] ? orcl
The Oracle base has been set to /u01/app/oracle
a ble
[oracle@db1 ~]$ sqlplus / as syskm
f e r
a n s
n -t r
SQL*Plus: Release 12.1.0.2.0 Production on Wed Dec
o
21 09:54:43
n
2016
s a
a
) h reserved.
Copyright (c) 1982, 2014, Oracle. All rights
o m d e ฺ
c i
m ailฺ t Gu
@ g den
Connected to:
h t i ca s Stu
Oracle Database 12c s
p a Enterprise
e t hi Edition Release 12.1.0.2.0 -
keystore altered.
WRL_TYPE STATUS
-------------------- ------------------------------
FILE CLOSED
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 14
HSM CLOSED
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release
12.1.0.2.0 - 64bit Production
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
ENCRYPTION_WALLET_LOCATION=
(SOURCE =
(METHOD = FILE)
a ble
f e r
(METHOD_DATA =
ans
(DIRECTORY = /u01/app/oracle/admin/orcl/wallet)))
n - t r
a no
h a s
#ENCRYPTION_WALLET_LOCATION=
m ) eฺ
o
ilฺc Guid
# (SOURCE =
# (METHOD = HSM) a
m ent
g
# (METHOD_DATA =
t i c a@ Stud
#
h this
(DIRECTORY = /u01/app/oracle/admin/orcl/wallet)))
a s
ap use
#
f p r
( ~]$ sqlplus
i c a e to / as sysdba
ht cens
[oracle@db1
a s
rapSQL*Plus:li Release 12.1.0.2.0 Production on Wed Dec 21 10:06:45
ur P 2016
F lam
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 -
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
keystore altered.
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 15
SQL> wrl_type, status from v$encryption_wallet;
SP2-0734: unknown command beginning "wrl_type, ..." - rest of
line ignored.
SQL> select wrl_type, status from v$encryption_wallet;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
WRL_TYPE STATUS
-------------------- ------------------------------
FILE OPEN
2. Remove the users.
SQL> drop user banking cascade;
User dropped.
a ble
f e r
SQL> drop user dba_debra cascade;
ans
n - t r
User dropped.
a no
3. Drop the encrypted tablespace. h a s
m ) eฺ
o
ilฺc Guid
SQL> connect / as sysdba
Connected. a t
m encontents;
SQL> drop tablespace ENCTBS includingg
t i c a@ Stud
Tablespace dropped. a s h this
f p r ap use
(
SQL> dropatablespace to BANKINGCLEAR including contents;
i c
ht cens e
a s
pTablespaceli dropped.
r a
u rP
m
Fla SQL> drop tablespace BANKINGENC including contents;
Tablespace dropped.
SQL>
4. Stop Key Vault and Start EM13.
[oracle@db1 ~]$ exit
logout
Connection to db1 closed.
[Host Desktop]$ sudo xm shutdown -w okv
Domain okv terminated
All domains terminated
[Host Desktop]$ sudo xm create em13
Using config file "/etc/xen/em13".
Started domain em13 (id=36)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 16
[Host Desktop]$ sudo xm list
Name ID Mem VCPUs
State Time(s)
Domain-0 0 1024 2
r----- 384296.5
db1 32 3072 1 -
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
b---- 13119.8
em13 36 9216 1 -
----- 5.2
[Host Desktop]$
5. Check the disk space on the host. Hosts with 500GB disks may experience problems with
the remaining practices due to low disk space. Remove the Oracle Key Vault virtual
machine directory if less than 20GB remains.
a ble
$ df -h
f e r
Filesystem Size Used Avail Use% Mounted on
ans
/dev/sda2 499G 484G 15G 97% / n - t r
/dev/sda1 190M
a no
28M 153M 16% /boot
tmpfs 464M
h a s
0 464M 0% /dev/shm
none 464M m ) eฺ
152K 463M 1% /var/lib/xenstored
o
$ ./clean_okv.sh
a ilฺc Guid
Root filesystem usage: g m ent
Filesystem Size
t i c ud Use% Mounted on
a@UsedStAvail
/dev/sda2 s
499G
a h th484G is 15G 97% /
f p r ap use
If you are (low on tspace,
o
i c a e
and have completed lesson 12,
a s ht remove
you may
c e nsthe /OVS/running_pol/okv directory.
rap li
ur P
Remove /OVS/running_pool/okv to restore space? (y/n) y
m
Fla
$
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 17
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ
a ble
f e r
ans
n - t r
o
s an
) ha
c o m ideฺ
m ailฺ t Gu
@ g den
h t ica is Stu
p a s th
a
pr to us e
( f
h t ica nse
p a s lice
ra
mur P
Fla
Practices for Lesson 12: Performing Oracle Key Vault Administrative Tasks
Chapter 12 - Page 18