6 Working with Labeled Data
You can manage labeled data, view that data of security attributes for a session, and change the value of session attributes.
Note:
Many of the examples in this guide use the HUMAN_RESOURCES
sample policy. Its policy name is HR
and its policy label column is HR_LABEL
. Unless otherwise noted, the examples assume that the SQL statements are performed on rows within the user's authorization and with full Oracle Label Security policy enforcement in effect.
- How Policy Label Column and Label Tags Work
You should understand how policy label columns in a table or schema are created and filled. - Assignments of Labels to Data Rows
For existing data rows, labels can be assigned by a labeling function that you create. - Presenting the Label
When you retrieve labels, you do not automatically obtain the character string value. - Filtration of Data Using Labels
When SQL statements are processed, Oracle Label Security makes calls to the security policies defined in the database by create-and-apply procedures. - Inserting Labeled Data
You can insert labeled data in a variety of situations. - Changing Session and Row Labels
During a session, a user can change labels based on the authorizations an administrator sets.
Parent topic: Using Oracle Label Security Functionality
How Policy Label Column and Label Tags Work
You should understand how policy label columns in a table or schema are created and filled.
- The Policy Label Column
You should understand how to use policy label columns. - Label Tags
You can create label tags, either manually or automatically generating them, that define the label components.
Parent topic: Working with Labeled Data
The Policy Label Column
You should understand how to use policy label columns.
- About the Policy Label Column
Each policy that is applied to a table creates a column in the database. - Hiding the Policy Label Column
You can choose not to display the column representing a policy.
Parent topic: How Policy Label Column and Label Tags Work
About the Policy Label Column
Each policy that is applied to a table creates a column in the database.
By default, the data type of the NUMBER
.
Each row's label for that policy is represented by a tag in that column, using the numeric equivalent of the character-string label value. The label tag is automatically generated when the label is created, unless the administrator specifies the tag manually at that time.
The automatic label generation follows the rules established by the administrator while defining the label components.
Note:
The act of creating a policy does not in itself have any effect on tables or schemas. It only applies the policy to a table or schema.
Related Topics
Parent topic: The Policy Label Column
Hiding the Policy Label Column
You can choose not to display the column representing a policy.
Related Topics
Parent topic: The Policy Label Column
Label Tags
You can create label tags, either manually or automatically generating them, that define the label components.
- About Label Tags
The administrator first defines a set of label components to be used in a policy. - Manually Defined Label Tags to Order Labels
By manually defining label tags, you can implement a data manipulation strategy that permits labels to be meaningfully sorted and compared. - Manually Defined Label Tags to Manipulate Data
An administratively defined label tag is a convenient way to reference a complete label string (that is, a combination of label components). - Automatically Generated Label Tags
Dynamically generated label tags have 10 digits, with no relationship to numbers assigned to any label component.
Parent topic: How Policy Label Column and Label Tags Work
About Label Tags
The administrator first defines a set of label components to be used in a policy.
When creating labels, the administrator specifies the set of valid combinations of components that can make up a label, that is, a level optionally combined with one or more groups or compartments.
Each such valid label within a policy is uniquely identified by an associated numeric tag assigned by the administrator or generated automatically upon its first use. Manual definition has the advantage of allowing the administrator to control the ordering of label values when they are sorted or logically compared.
However, label tags must be unique across all policies in the database. When you use multiple policies in a database, you cannot use the same numeric label tag in different policies. Remember that each label tag uniquely identifies one label, and that numeric tag is what is stored in the data rows, not the label's character-string representation.
Parent topic: Label Tags
Manually Defined Label Tags to Order Labels
By manually defining label tags, you can implement a data manipulation strategy that permits labels to be meaningfully sorted and compared.
To do this, you must predefine all of the labels to be associated with protected data, and assigns to each label a meaningful label tag value. Manually assigned label tags can have up to eight digits. The value of a label tag must be greater than zero.
It may be advantageous to implement a strategy in which label tag values are related to the numeric values of label components. In this way, you can use the tags to group data rows in a meaningful way. This approach, however, is not mandatory. It is good practice to set tags for labels of higher sensitivity to a higher numeric value than tags for labels of lower sensitivity.
Table 6-1 illustrates a set of label tags that have been assigned.
Table 6-1 Administratively Defined Label Tags (Example)
Label Tag | Label String |
---|---|
10000 |
P |
20000 |
C |
21000 |
C:FNCL |
21100 |
C:FNCL,OP |
30000 |
S |
31110 |
S:OP:WR |
40000 |
HS |
42000 |
HS:OP |
In this example, labels with a level of PUBLIC
begin with "1", labels with a level of CONFIDENTIAL
begin with "2", labels with a level of SENSITIVE
begin with "3", and labels with a level of HIGHLY_SENSITIVE
begin with "4".
Labels with the FINANCIAL
compartment then come in the 1000 range, labels with the compartment OP
are in the 1100 range, and so on. The tens place is used to indicate the group WR
, for example.
Another strategy might be completely based on groups, where the tags might be 3110, 3120, 3130, and so on.
Note, however, that label tags identify the whole label, independent of the numeric values assigned for the individual label components. The label tag is used as a whole integer, not as a set of individually evaluated numbers.
Related Topics
Parent topic: Label Tags
Manually Defined Label Tags to Manipulate Data
An administratively defined label tag is a convenient way to reference a complete label string (that is, a combination of label components).
For example, the tag "31110" could stand for the complete label string "S:OP:WR".
Label tags can be used as a convenient way to partition data. For example, all data with labels in the range 1000 - 1999 could be placed in tablespace A, all data with labels in the range 2000 - 2999 could be placed in tablespace B, and so on.
This simplified notation also comes in handy when there is a finite number of labels and you need to perform various operations upon them. Consider a situation in which one company hosts a human resources system for many other companies. Assume that all users from Company Y have the label "C:ALPHA:CY", for which the tag "210" has been set. To determine the total number of application users from Company Y, the host administrator can enter:
SELECT * FROM tab1 WHERE hr_label = 210;
Parent topic: Label Tags
Automatically Generated Label Tags
Dynamically generated label tags have 10 digits, with no relationship to numbers assigned to any label component.
You cannot group the data by label.
Table 6-2 describes how automatically generated label tags work.
Table 6-2 Generated Label Tags (Example)
Label Tag | Label String |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Parent topic: Label Tags
Assignments of Labels to Data Rows
For existing data rows, labels can be assigned by a labeling function that you create.
In such a function, you specify the exact table and row conditions defining what label to insert. The function can be named in the call to apply a policy to a table or schema, or in an update by the administrator.
Presenting the Label
When you retrieve labels, you do not automatically obtain the character string value.
By default, the label tag value is returned. Two label manipulation functions enable you to convert the label tag value to and from its character string representation.
- Converting a Character String to a Label Tag with CHAR_TO_LABEL
TheCHAR_TO_LABEL
function converts character strings to a label tag, returning the label tag for the specified character string. - Conversion of a Label Tag to a Character String, with LABEL_TO_CHAR
You can convert label tags to character strings.
Parent topic: Working with Labeled Data
Converting a Character String to a Label Tag with CHAR_TO_LABEL
The CHAR_TO_LABEL
function converts character strings to a label tag, returning the label tag for the specified character string.
Parent topic: Presenting the Label
Conversion of a Label Tag to a Character String, with LABEL_TO_CHAR
You can convert label tags to character strings.
- Converting a Label Tag to a Character String with LABEL_TO_CHAR
TheLABEL_TO_CHAR
function returns aVARCHAR2
string when it converts a label tag to a character string. - LABEL_TO_CHAR Examples
Oracle provides examples that illustrate the use ofLABEL_TO_CHAR
. - Retrieving All Columns from a Table When the Policy Label Column Is Hidden
If the policy label column is hidden, then it is not automatically returned when you executeSELECT *
on the table.
Parent topic: Presenting the Label
Converting a Label Tag to a Character String with LABEL_TO_CHAR
The LABEL_TO_CHAR
function returns a VARCHAR2
string when it converts a label tag to a character string.
LABEL_TO_CHAR
function to display the character string value of each label. Note that all conversions must be explicit. There is no automatic casting to and from tag and character string representations.
LABEL_TO_CHAR Examples
Oracle provides examples that illustrate the use of LABEL_TO_CHAR
.
Example: Retrieving a Row Label from a Table or a View
To retrieve the label of a row from a table or view, specify the policy label column in the SELECT
statement.
SELECT label_to_char (hr_label) AS label, ename FROM tab1; WHERE ename = 'RWRIGHT';
This statement returns the following:
LABEL ENAME ------------ ---------- S:A,B:G1 RWRIGHT
Example: Retrieving a Policy Label Column
You can also specify the policy label column in the WHERE
clause of a SELECT
statement.
The following statement displays all rows that have the policy label S:A,B:G1
SELECT label_to_char (hr_label) AS label,ename FROM emp WHERE hr_label = char_to_label ('HR', 'S:A,B:G1');
This statement returns the following:
LABEL ENAME ------------- --------- S:A,B:G1 RWRIGHT S:A,B:G1 ESTANTON
Alternatively, you could use a more flexible statement to look up data that contains the string "S:A,B:G1" anywhere in the text of the HR_LABEL
column:
SELECT label_to_char (hr_label) AS label,ename FROM emp WHERE label_to_char (hr_label) like '%S:A,B:G1%';
If you do not use the LABEL_TO_CHAR
function, then you will see the label tag.
Example: Retrieving a Numeric Column Data Type
The following example is with the numeric column data type (NUMBER
) and dynamically generated label tags, but without using the LABEL_TO_CHAR
function. If you do not use the LABEL_TO_CHAR
function, then you will see the label tag.
SQL> select empno, hr_label from emp where ename='RWRIGHT'; EMPNO HR_LABEL ---------- ---------- 7839 1000000562
Filtration of Data Using Labels
When SQL statements are processed, Oracle Label Security makes calls to the security policies defined in the database by create-and-apply procedures.
For SELECT
statements, the policy filters the data rows that the user is authorized to see. For INSERT
, UPDATE
, and DELETE
statements, Oracle Label Security permits or denies the requested operation, based on the user's authorizations.
- Use of Numeric Label Tags in WHERE Clauses
There are different techniques of using numeric label tags inWHERE
clauses ofSELECT
statements. - Ordering Labeled Data Rows
TheORDER BY
clause of aSELECT
statement can be used to order rows by the numeric label tag. - Ordering by Character Representation of Label
TheLABEL_TO_CHAR
function orders data rows by the character representation of the label. - Determination of the Upper and Lower Bounds of Labels
Oracle Label Security provides functions that determine the least upper bound or the greatest lower bound of two or more labels. - Merging Labels with the MERGE_LABEL Function
TheMERGE_LABEL
function merges two labels together.
Parent topic: Working with Labeled Data
Use of Numeric Label Tags in WHERE Clauses
There are different techniques of using numeric label tags in WHERE
clauses of SELECT
statements.
When using labels in the NUMBER
format, you can set up labels so that a list of your label tags distinguishes the different levels. Comparisons of these numeric label tags can be used for ORDER BY
processing, and with the logical operators.
For example, if you have assigned all UNCLASSIFIED
labels to the 1000 range, all SENSITIVE
labels to the 2000 range, and all HIGHLY_SENSITIVE
labels to the 3000 range, then you can list all SENSITIVE
records.
SELECT * FROM emp WHERE hr_label BETWEEN 2000 AND 2999;
To list all SENSITIVE
and UNCLASSIFIED
records, you can enter:
SELECT * FROM emp WHERE hr_label <3000;
To list all HIGHLY_SENSITIVE
records, you can enter:
SELECT * FROM emp WHERE hr_label=3000;
Note:
Remember that such queries have meaning only if the administrator has applied a numeric ordering strategy to the label tags that he or she originally assigned to the labels. In this way, the administrator can provide for convenient dissemination of data. If, however, the label tag values are generated automatically, then there is no intrinsic relationship between the value of the tag and the order of the labels.
Alternatively, you can use dominance relationships to set up an ordering strategy.
Related Topics
Parent topic: Filtration of Data Using Labels
Ordering Labeled Data Rows
The ORDER BY
clause of a SELECT
statement can be used to order rows by the numeric label tag.
Parent topic: Filtration of Data Using Labels
Ordering by Character Representation of Label
The LABEL_TO_CHAR
function orders data rows by the character representation of the label.
Parent topic: Filtration of Data Using Labels
Determination of the Upper and Lower Bounds of Labels
Oracle Label Security provides functions that determine the least upper bound or the greatest lower bound of two or more labels.
Two single-row functions operate on each row returned by a query. They return one result for each row.
Note:
In all functions that take multiple labels, the labels must all belong to the same policy.
- Finding Least Upper Bound with LEAST_UBOUND
TheOLS_LEAST_UBOUND
(OLS_LUBD
) function returns a character string label that is the least upper bound oflabel1
andlabel2:
. - Finding Greatest Lower Bound with GREATEST_LBOUND
TheOLS_GREATEST_LBOUND
(OLS_GLBD
) standalone function determines the lowest label of the data that can be involved in an operation, given two different labels.
Parent topic: Filtration of Data Using Labels
Finding Least Upper Bound with LEAST_UBOUND
The OLS_LEAST_UBOUND
(OLS_LUBD
) function returns a character string label that is the least upper bound of label1
and label2:
.
HIGHLY_SENSITIVE:ALPHA
and SENSITIVE:BETA
is HIGHLY_SENSITIVE:ALPHA,BETA.
Parent topic: Determination of the Upper and Lower Bounds of Labels
Finding Greatest Lower Bound with GREATEST_LBOUND
The OLS_GREATEST_LBOUND
(OLS_GLBD
) standalone function determines the lowest label of the data that can be involved in an operation, given two different labels.
label1
and label2.
The greatest lower bound is the lowest level, the intersection of the compartments in the labels and the groups in the labels. For example, the greatest lower bound of HIGHLY_SENSITIVE:ALPHA
and SENSITIVE
is SENSITIVE.
Parent topic: Determination of the Upper and Lower Bounds of Labels
Merging Labels with the MERGE_LABEL Function
The MERGE_LABEL
function merges two labels together.
Parent topic: Filtration of Data Using Labels
Inserting Labeled Data
You can insert labeled data in a variety of situations.
- About Inserting Labeled Data
When you insert data into a table protected by an Oracle Label Security policy, you must supply a numeric label value tag. - Inserting Labels Using CHAR_TO_LABEL
To insert a row label, you can specify the label character string and then transform it into a label using theCHAR_TO_LABEL
function. - Inserting Labels Using Numeric Label Tag Values
You can insert data using the numeric label tag value of a label, rather than using theCHAR_TO_LABEL
function. - Inserting Data Without Specifying a Label
There are two situations in which you do not need to specify a label inINSERT
statements. - Inserting Data When the Policy Label Column Is Hidden
If the label column is hidden, then the existence of the column is transparent to the insertion of data. - Inserting Labels Using TO_DATA_LABEL
TheTO_DATA_LABEL
function can generate new labels dynamically.
Parent topic: Working with Labeled Data
About Inserting Labeled Data
When you insert data into a table protected by an Oracle Label Security policy, you must supply a numeric label value tag.
Usually, you can insert this value in the INSERT
statement itself.
To do this, you must explicitly specify the tag for the desired label or explicitly convert the character string representation of the label into the correct tag. Note that this does not mean generating new label tags, but referencing the correct tag. When Oracle Label Security is using Oracle Internet Directory, the only permissible labels (and corresponding tags) are those pre-defined by the administrator and already in Oracle Internet Directory.
The only times an INSERT
statement may omit a label value are:
-
If the
LABEL_DEFAULT
enforcement option was specified when the policy was applied, or -
If no enforcement options were specified when the policy was applied and
LABEL_DEFAULT
was specified when the policy was created -
If the statement applying the policy named a labeling function.
In the first two cases, the user's session default row label is used as the inserted row's label. In the third case, the inserted row's label is created by that labeling function.
Parent topic: Inserting Labeled Data
Inserting Labels Using CHAR_TO_LABEL
To insert a row label, you can specify the label character string and then transform it into a label using the CHAR_TO_LABEL
function.
CHAR_TO_LABEL
function automatically creates a valid data label.
Parent topic: Inserting Labeled Data
Inserting Labels Using Numeric Label Tag Values
You can insert data using the numeric label tag value of a label, rather than using the CHAR_TO_LABEL
function.
Parent topic: Inserting Labeled Data
Inserting Data Without Specifying a Label
There are two situations in which you do not need to specify a label in INSERT
statements.
LABEL_DEFAULT
is set, or if there is a labeling function applied to the table, then you do not need to specify a label in your INSERT
statements. The label will be provided automatically.
Parent topic: Inserting Labeled Data
Inserting Data When the Policy Label Column Is Hidden
If the label column is hidden, then the existence of the column is transparent to the insertion of data.
INSERT
statements can be written that do not explicitly list the table columns and do not include a value for the label column. The session's row label is used to label the data, or a labeling function is used if one was specified when the policy was applied to the table or schema. You can insert into a table without explicitly naming the columns, as long as you specify a value for each non-hidden column in the table. The following example shows how to insert a row into a table.
Parent topic: Inserting Labeled Data
Inserting Labels Using TO_DATA_LABEL
The TO_DATA_LABEL
function can generate new labels dynamically.
olsadmintool
commands. Therefore, when Oracle Label Security is directory-enabled, this function, TO_DATA_LABEL
, is not available and will generate an error message if used.
Parent topic: Inserting Labeled Data
Changing Session and Row Labels
During a session, a user can change labels based on the authorizations an administrator sets.
Related Topics
Parent topic: Working with Labeled Data