Multilevel Security For Relational Databases
Multilevel Security For Relational Databases
Security for
Relational
Databases
Osama S. Faragallah
El-Sayad M. El-Rabaie • Fathi E. Abd El-Samie
Ahmed I. Sallam • Hala S. El-Sayed
Multilevel
Security for
Relational
Databases
OTHEr TITLES FrOM AUErBACH PUBLICATIONS AND CrC PrESS
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been
made to publish reliable data and information, but the author and publisher cannot assume responsibility for the
validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the
copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to
publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let
us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted,
or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, includ-
ing photocopying, microfilming, and recording, or in any information storage or retrieval system, without written
permission from the publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com
(http://www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers,
MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety
of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment
has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for
identification and explanation without intent to infringe.
Visit the Taylor & Francis Web site at
http://www.taylorandfrancis.com
P r e fa c e xi
About the Authors xiii
C h a p t e r 1 C o n c e p t s o f D ata b a s e S e c u r i t y 1
1.1 Database Concepts 1
1.2 Relational Database Security Concepts 5
1.3 Access Control in Relational Databases 7
1.3.1 Discretionary Access Control 7
1.3.2 Mandatory Access Control 10
1.3.3 Role-Based Access Control 12
1.4 Work Objectives 13
1.5 Book Organization 15
C h a p t e r 2 B a s i c C o n c e p t of M u lt i l e v e l D ata b a s e
Securit y 17
2.1 Introduction 17
2.2 Multilevel Database Relations 18
2.3 Polyinstantiation 19
2.3.1 Invisible Polyinstantiation 20
2.3.2 Visible Polyinstantiation 21
2.3.3 Types of Polyinstantiation 22
2.3.4 Architectural Considerations in Supporting
Polyinstantiation 23
2.4 Multilevel Database Security Models 24
2.4.1 SeaView Model 24
2.4.2 Jajodia–Sandhu Model 26
2.4.3 Smith–Winslett Model 27
v
vi C o n t en t s
o f MLS / D BMS M o d e l s
C h a p t e r 3 I mp l e m e n tat i o n 35
3.1 Introduction 35
3.2 SeaView Model 35
3.2.1 Selected Operation Procedure 35
3.2.2 Insert Operation Procedure 36
3.2.3 Update Operation Procedure 38
3.2.4 Delete Operation Procedure 38
3.3 Jajodia–Sandhu Model 40
3.3.1 Select Operation Procedure 40
3.3.2 Insert Operation Procedure 41
3.3.3 Update Operation Procedure 42
3.3.4 Delete Operation Procedure 43
3.4 Smith–Winslett Model 43
3.4.1 Select Operation Procedure 43
3.4.2 Insert Operation Procedure 44
3.4.3 Update Operation Procedure 46
3.4.4 Delete Operation Procedure 46
3.5 Multilevel Relational (MLR) Model 47
3.5.1 Select Operation Procedure 47
3.5.2 Insert Operation Procedure 48
3.5.3 Update Operation Procedure 50
3.5.4 Delete Operation Procedure 50
3.5.5 Uplevel Operation Procedure 52
3.6 Belief-Consistent Multilevel Secure Relational
Data Model 53
3.6.1 Basic Procedures for Operations 53
3.6.1.1 Xview (Label) Procedure 53
3.6.1.2 Pl (Label) Procedure 55
3.6.1.3 Sl (Label) Procedure 56
3.6.1.4 Ib (Label) Procedure 57
3.6.2 Select Operation Procedure 57
3.6.3 Insert Operation Procedure 57
3.6.4 Verify Operation Procedure 59
3.6.5 Update Operation Procedure 60
3.6.6 Delete Operation Procedure 62
C o n t en t s vii
C h a p t e r 4 F u n d a m e n ta l s o f I n f o r m at i o n E n c r y p t i o n 65
4.1 Introduction 65
4.2 Basic Concepts of Cryptography 65
4.2.1 Goals of Cryptography 65
4.2.2 Principles of Encryption 66
4.3 Classification of Encryption Algorithms 67
4.3.1 Classification according to Encryption
Structure 67
4.3.2 Classification according to Keys 68
4.3.3 Classification according to Percentage of
Encrypted Data 70
4.4 Cryptanalysis 70
4.5 Conventional Symmetric Block Ciphers 71
4.5.1 Data Encryption Standard (DES) 71
4.5.2 Double DES 72
4.5.3 Triple DES 74
4.5.4 International Data Encryption Algorithm
(IDEA) 74
4.5.5 Blowfish 75
4.5.6 RC5 Algorithm 75
4.5.6.1 RC5 Encryption Algorithm 75
4.5.6.2 RC5 Decryption Algorithm 76
4.5.6.3 RC5 Key Expansion 77
4.5.7 RC6 Algorithm 78
4.5.7.1 RC6 Encryption Algorithm 78
4.5.7.2 RC6 Decryption Algorithm 79
4.5.8 The Advanced Encryption Standard (AES) 81
4.6 Modes of Operation 83
4.6.1 The ECB Mode 83
4.6.2 The CBC Mode 85
4.6.3 The CFB Mode 85
4.6.4 The OFB Mode 86
C h a p t e r 5 E n c r y p t i o n - B a s e d M u lt i l e v e l M o d e l for
DBMS 89
5.1 Introduction 89
5.2 The Encryption-Based Multilevel Database Model 90
5.3 Manipulation 92
5.3.1 The INSERT Statement 92
5.3.2 The DELETE Statement 93
5.3.3 The SELECT Statement 94
5.3.4 The UPDATE Statement 96
5.3.5 The UPLEVEL Statement 97
viii C o n t en t s
C h a p t e r 6 F o r m a l A n a ly s i s f o r E n c r y p t i o n - B a s e d
M u lt i l e v e l M o d e l f o r D BMS 113
6.1 Introduction 113
6.2 The Encryption-Based Multilevel Model for
DBMS Definition 114
6.2.1 MLR Model Definition 114
6.2.2 Encryption-Based Multilevel Model for
DBMS Definition 115
6.3 Integrity Properties 117
6.3.1 Entity Integrity 117
6.3.2 Polyinstantiation Integrity 118
6.3.3 Data-Borrow Integrity 118
6.3.4 Foreign Key Integrity 118
6.3.5 Referential Integrity 119
6.4 Manipulation 119
6.4.1 The INSERT Statement 120
6.4.2 The DELETE Statement 120
6.4.3 The SELECT Statement 121
6.4.4 The UPDATE Statement 122
6.4.5 The UPLEVEL Statement 123
6.5 Soundness 124
6.5.1 Case 1: In the INSERT Operation 125
6.5.2 Case 2: In the DELETE Operation 125
6.5.3 Case 3: In the UPDATE Operation 126
6.5.4 Case 4: In the UPLEVEL Operation 126
C o n t en t s ix
References 269
Preface
xi
x ii P refac e
x iii
xiv A b o u t t he Au t h o rs
1
2 Securit y f o r Rel ati o n a l Data ba se s
SELECT [A1,A2,...,An]
FROM R
WHERE P
INSERT
INTO R [A1,A2,...,An]
VALUES [a1,a2,...,an]
UPDATE R
SET [A1=a1,A2=a2,...,An=an]
WHERE P
DELETE
FROM R
WHERE P
In recent years, the need for securing relational databases has been
increased because of increased database attacks. Most companies
and organizations store their sensitive data in their own relational
databases. In recent years, attackers have been able to target large
relational databases that belong to large companies or large banks.
In the past, relational database attacks were common, but were fewer
than attacks on networks. Now, due to the increasing access of rela-
tional databases by many people, the chances of relational database
attacks have increased. The reason for these attacks is to obtain
money by getting sensitive information like credit card numbers or
Social Security numbers. Thus, it is important to protect relational
databases against these risks, and this is where database security
comes into place.
Relational database security can be defined as a system that
protects the confidentiality, integrity, and availability of the
database [6]. Unauthorized access to a relational database indicates
a loss of confidentiality, unauthorized modification to the available
data indicates a loss of integrity, and lack of access to relational data-
base services indicates a loss of availability. Loss of one or more of
these basic facets will have a bad impact on the security of the rela-
tional database.
The protection of the confidentiality, integrity, and availabil-
ity of the relational database will be illustrated in more detail as
follows:
• Confidentiality can be defined as a process for preventing
unauthorized access to the sensitive data that is stored in the
relational database. It can be ensured by applying encryption
to the data stored in the relational database. Encryption is a
process in which the information is encrypted in a way that
only authorized users can manage. The different levels for
encryption are described as follows:
• Data in transit means that an attacker can get access to the
sensitive information by observing the network between
the sender and the receiver.
• Data at rest means that an attacker can attack the infor-
mation stored in the relational database.
6 Securit y f o r Rel ati o n a l Data ba se s
GRANT privileges
[ON relation]
TO users
[WITH GRANT OPTION]
For example:
GRANT SELECT
ON Employees
TO A
REVOKE privileges
[ON relation]
FROM users
For example:
REVOKE SELECT
ON Employees
FROM A
Multilevel security was the solution. MLS allows the data in different
security classification levels to be accessed by users that have different
security clearance levels.
The Bell and LaPadula model was the basic model that introduced
the concept of MLS [13]. This model depends on definitions of objects
and subjects. An object like relation, a tuple, or an attribute is a passive
entity. A subject like user or program is an active process that needs to
have a privilege on objects. Every object is assigned to a security level
(classification), and every subject is assigned to a security level (clear-
ance). Security levels are defined as labels. A label contains two compo-
nents: a hierarchical component and a group of unordered categories.
The hierarchical component presents the security levels of the data.
For example, a company might define the security levels of its sensitive
data as top secret, secret, confidential, or unclassified. The unordered
categories are used to define the sensitivity of the leveled data.
Multilevel security is based on the Bell and LaPadula model
and formalized by two rules. LaPadula rules are described as
follows [14]:
The star property allows a lower security level subject to write data
to a higher security level object. This can result in overwriting and
therefore modifying of higher security level objects by lower security
level subjects. Thus, MLS enforces a stronger star property to restrict
each subject to write at his own security level:
• Strong star property: A subject is allowed to write to an object
if the subject’s security clearance level is equal to the object’s
security classification level.
2.1 Introduction
17
18 Securit y f o r Rel ati o n a l Data ba se s
2.3 Polyinstantiation
Multilevel
Database
In the secure data views (SeaView) model, security levels are assigned
to each data element in the attributes of the tuples in the relation, as
shown in Table 2.7. In the SeaView model, data are stored in a set of
single-level fragments and the multilevel relations are implemented as
views over these single-level relations [24].
Multil e v el Data ba se Securit y 25
EMPLOYEE
Ahmed U
B
EMPLOYEE DEPARTMENT
Ahmed U Accounting U
C
EMPLOYEE SALARY
Ahmed U 7,000 U
D
EMPLOYEE DEPARTMENT
Ahmed U Sales S
E
EMPLOYEE SALARY
Ahmed U 10,000 S
26 Securit y f o r Rel ati o n a l Data ba se s
the database at his own security level and also can access the contents
of the database at lower levels. The user also has access to the beliefs
of users at lower levels. Users can define their beliefs through the new
verify mechanism. The users at each security level can decide what
information is accepted. The great advantage of the BCMLS model is
the fact that the accepted information does not need to be replicated
or borrowed.
8
7
6
Response Time (s)
5
4
3
2
1
0
0 500 1000 1500 2000
Number of Tuples
SeaView Jajodia-Sandhu Smith-Winslett
MLR Belief-Consistent
Figure 2.4 The impact of varying the number of tuples on the performance of a multilevel
database.
32 Securit y f o r Rel ati o n a l Data ba se s
6
Response Time (s)
0
2 3 4 5 6
Number of Attributes
SeaView Jajodia-Sandhu Smith-Winslett
MLR Belief-Consistent
Figure 2.5 The impact of varying the number of attributes on the performance of a multilevel
database.
2.5
2
Response Time (s)
1.5
0.5
0
2 3 4 5 6
Number of Classification Levels
SeaView Jajodia-Sandhu Smith-Winslett
MLR Belief-Consistent
Figure 2.6 The impact of varying the number of classification levels on the performance of a
multilevel database.
2.6 Summary
3.1 Introduction
SELECT [A1,A2,...,An]
FROM R
WHERE P
35
36 Securit y f o r Rel ati o n a l Data ba se s
• Step 2: make a logical view over the stored single security level
relations by performing join between vertical single security
class level relations and union between horizontal single-level
relations.
• Step 3: get all tuples from the logical view that have security
levels below or equal to the security class level of the subject
that runs the selection operation.
Figure 3.1 illustrates the flow chart for the selection operation in the
SeaView model.
INSERT
INTO R [A1,A2,...,An]
VALUES [a1,a2,...,an]
No
Get next row Row class <= user class
Yes
Display Row
End
Figure 3.1 Flow chart for selection operation in the SeaView model.
Imp l em en tati o n o f M LS / D BM S M o d el s 37
Set i = 1
Ai ∈ R [Ai]*
i=i+1
No Yes
Ai = null Ai = ai
Ci = L(user)
End
Figure 3.2 Flow chart for insertion operation in SeaView and Jajodia–Sandhu models.
38 Securit y f o r Rel ati o n a l Data ba se s
UPDATE R
SET [A1 = a1, A2 = a2,...,An = an]
WHERE P
• Step 1: get the security level of the subject that runs the update
operation.
• Step 2: get all tuples that satisfy update condition P in the
update statement and have a security level equal to or below
the security level of the user.
• Step 3: for each tuple in the tuples in step 2, if the security
level of a primary key is equal to the security level of the user,
the tuple in the single-level relation that contains the attri-
butes in the set clause will be updated.
• Step 4: for each tuple in the tuples in step 2, if the security level
of a primary key is lower than the security level of the user, the
tuple in the single-level relation that contains the attributes in
the set clause will be polyinstantiated at the security level of the
user.
Figure 3.3 illustrates the flow chart for the update operation in the
SeaView model.
DELETE
FROM R
WHERE P
Imp l em en tati o n o f M LS / D BM S M o d el s 39
Set i = 1
CPK = L(user)
i=i+1
Yes No
Yes No
Polyinstantiate t(Ai)
End
Figure 3.3 Flow chart for update operation in SeaView and Jajodia–Sandhu models.
• Step 1: get the security level of the subject that runs the
delete operation.
• Step 2: delete all tuples from single-level relations that satisfy
delete condition P in the delete statement and have a security
level equal to the security level of the user.
Figure 3.4 illustrates the flow chart for the delete operation in the
SeaView model.
40 Securit y f o r Rel ati o n a l Data ba se s
Set i = 1
i=i+1
No
CPK = L(user)
Yes
Delete t(Ai)
End
Figure 3.4 Flow chart for delete operation in SeaView and Jajodia–Sandhu models.
SELECT [A1,A2,...,An]
FROM R
WHERE P
• Step 3: get all tuples, from the logical view, that have a secu-
rity level below or equal to the security level of the subject that
runs the select operation.
Figure 3.5 illustrates the flow chart for a selection operation in the
Jajodia–Sandhu model.
INSERT
INTO R [A1,A2,...,An]
VALUES [a1,a2,...,an]
No
Get next row Row class <= user class
Yes
Display Row
End
• Step 1: get the security level of the subject that runs the insert
operation.
• Step 2: if the attribute is included in the attribute list in the
insert statement, this attribute will be set to its value from the
values list in the insert statement.
• Step 3: the security level of all attributes will be equal to the
security level of the subject that runs the insert operation.
• Step 4: insert into the single-level relation, with the security
level equal to the security level of the user, values that are
included in the values list of the insert statement and corre-
spond to the attributes of these single-level relations.
Figure 3.2 illustrates the flow chart for the insertion operation in the
Jajodia–Sandhu model.
UPDATE R
SET [A1 = a1,A2 = a2,...,An = an]
WHERE P
• Step 1: get the security level of the subject that runs the update
operation.
• Step 2: get all tuples that satisfy update condition P in the
update statement and have security levels equal to or below
the security level of the user.
Imp l em en tati o n o f M LS / D BM S M o d el s 43
Set i = 1
i=i+1
No
ti [TC]= L(user)
Yes
Display ti
End
Figure 3.6 Flow chart for select operation in Smith–Winslett and MLR models.
Set i = 1
Ai ∈ R [Ai]*
i=i+1
No Yes
Ai = null Ai = ai
CPK = L(user)
End
Set i = 1
i=i+1
No
ti [TC]= L(user)
Yes
Update ti
End
Figure 3.9 illustrates the flow chart for the delete operation in the
Smith–Winslett model.
SELECT [A1,A2,...,An]
FROM R
WHERE P
Set i = 1
i=i+1
No
ti [TC]= L(user)
Yes
Delete ti
End
INSERT
INTO R [A1,A2,...,An]
VALUES [a1,a2,...,an]
Imp l em en tati o n o f M LS / D BM S M o d el s 49
Set i = 1
Ai ∈ R [Ai]*
i=i+1
No Yes
Ai = null Ai = ai
Ci = L(user)
End
Figure 3.10 Flow chart for insertion operation in MLR and belief-consistent models.
50 Securit y f o r Rel ati o n a l Data ba se s
UPDATE R
SET [A1 = a1,A2 = a2,...,An = an]
WHERE P
• Step 1: get the security level of the subject that runs the update
operation.
• Step 2: if no attribute of the primary key is in the SET clause,
update all tuples in multilevel relations that satisfy the update
condition P in the update statement and have a security level
equal to the security level of the user. Also, all borrowed
tuples by higher level users that satisfy update condition P in
the update statement will be updated.
• Step 3: if some attribute of the primary key is in the SET
clause, update all tuples in multilevel relations that satisfy
update condition P in the update statement and have a secu-
rity level equal to the security level of the user. Delete all
borrowed tuples by higher level users that satisfy update con-
dition P in the update statement.
Figure 3.11 illustrates the flow chart for the update operation in the
MLR model.
DELETE
FROM R
WHERE P
Imp l em en tati o n o f M LS / D BM S M o d el s 51
Set i = 1
ti [PK] ∈ [Ai]*
No Yes
Yes No
Update t´i
Delete ti
End
Set i = 1
ti [TC] = L(user)
Yes No
i=i+1 Delete ti
ti [TC] ≻ L(user) and
ti [CPK] = L(user)
Yes No
Mark to be deleted
by high user
End
UPLEVEL R
GET [A1,A2,...,An] FROM [C1,C2,...,Cn]
WHERE P
Set i = 1
ti [TC] ≤ L(user)
No Yes
i=i+1
t[PK] = ti [PK],
t[CPK] = ti [CPK]
Set j = 1
ti[Aj] ∈ [Ai]*
Yes No j=j+1
End
Figure 3.14 illustrates the flow chart for the Xview (label) procedure
in the belief-consistent model.
Set i = 1
i=i+1 I ≤ L(user)
Yes No
End
Figure 3.14 Flow chart for Xview (label) procedure in a belief-consistent model.
56 Securit y f o r Rel ati o n a l Data ba se s
End
End
Set i = 1
i=i+1 i ≤ L (user)
Yes No
Label = Label/number of
class levels
End
Set i = 1
i=i+1 Xview(ti[TC]) ≠ 0
Yes No
Set j = 1
j=j+1
End
Figure 3.18 Flow chart for select operation in the belief-consistent model.
the values list in the insert statement; else the value of this
attribute will be null.
• Step 3: the security level of all attributes will be equal to the
security level of the subject that runs the insert operation.
• Step 4: insert a new tuple with attribute values and a security
level into the multilevel relation.
Figure 3.10 illustrates the flow chart for insertion operation in the
belief-consistent model.
Set i = 1
i=i+1 Set j = 1
Set K = 1
j=j+1
Ck = L(user)
No Yes
End
Figure 3.19 Flow chart for verify operation in the belief-consistent model.
Figure 3.20 illustrates the flow chart for the update operation in the
belief-consistent model.
62 Securit y f o r Rel ati o n a l Data ba se s
Set i = 1
Set j = 1
j=j+1
Insert tj in Array[tj]
Count (Array[tj]) = 0
Yes No
Choose tj
End
Figure 3.20 Flow chart for update operation in the belief-consistent model.
level L runs a command to delete tuples from MLS relation R: for all
t ∈ R, if t satisfies P and Pl is equal to the security class level of the
user L, the delete operation is implemented as follows [35]:
• Step 1: get the security level of the subject that runs the delete
operation.
• Step 2: if Sl (Xview(Tuple Class)) is NULL, the tuple will be
deleted.
• Step 3: if Sl (Xview(Tuple Class)) is not NULL, unverify the
tuple for the current user and set the flag for higher level users.
• Step 4: unverify all tuples with the same primary key and its
security level as the deleted tuple having Ib(tc) = l (belief: false).
Figure 3.21 illustrates the flow chart for the delete operation in the
belief-consistent model.
Set i = 1
Set j = 1
i=i+1 j=j+l
Yes
End
Figure 3.21 Flow chart for delete operation in the belief-consistent model.
64 Securit y f o r Rel ati o n a l Data ba se s
3.8 Summary
4.1 Introduction
65
66 Securit y f o r Rel ati o n a l Data ba se s
The basic idea of encryption is to modify the message in such a way that
only a legal recipient can reconstruct its content [37,38]. A discrete-valued
cryptosystem can be characterized by:
Ke Kd
P = DK d (C ) (4.2)
K
K
Secret Secure
Key Channel
Cryptanalyst X
Kd
Ke
Key pair
source
Most people have chosen to call the first group simply symmetric
key cryptosystems, and the popular name for the second group is just
public key cryptosystems.
4.4 Cryptanalysis
The DES is the most well-known symmetric key block cipher and it
has enjoyed widespread use internationally [53].
The DES is a block cipher, which encrypts data in 64-bit blocks.
A 64-bit block of the plaintext comes at one end of the algorithm and
a 64-bit block of ciphertext goes out at the other end of the algorithm.
The same algorithm and the same key with 56 bits are used in the
encryption and decryption processes except for minor differences in
the key schedule. The key is a 64-bit number. In every 8 bits, 1 bit
(the least significant bit) is used for parity checking and can be ignored.
The DES is based on four basic operations: expansion, permutation,
XOR, and substitution. The data to be encrypted are first divided into
72 Securit y f o r Rel ati o n a l Data ba se s
32 1 2 3 4 5 6 7 8 9 10 11 12 32
48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 48
64-bit blocks and fed into an initial permutation (IP) stage, in which
each block is divided into two sub-blocks, each with 32-bit length.
The right sub-block is fed into a Feistel function (f-function), which
is depicted in Figure 4.4. It operates on half a block (32 bits) at a time
and contains four stages as shown in Figure 4.5.
1. Expansion. The half-block with 32 bits is expanded to 48 bits,
using the permutation of the expansion, defined as E in the
diagram, by duplicating half of the bits. The output contains
eight 6-bit [8 × 6 = 48 bits] pieces, each consisting of a copy of
four corresponding input bits and a copy of the immediately
adjacent bit from each of the input pieces to either side.
2. Key mixing. A subkey is combined with the result of the first
step using an XOR operation. A key schedule mechanism is
used to derive 16 subkeys with 48 bits from the main key.
3. Substitution. First the block is divided into eight 6-bit pieces
and, after that, processed by the substitution boxes (S-boxes).
The six input bits of each one of the eight S-boxes are replaced
with four output bits using a nonlinear transformation, pro-
vided in the form of a look-up table. The S-boxes present the
basis of the security of the DES. Without them, the cipher
would be breakable.
4. Permutation. The 32 S-boxes’ outputs will be rearranged using
a fixed permutation. The P-box is designed so that, after expan-
sion, each group of S-box output bits is spread across six differ-
ent S-boxes in the next round.
Plaintext 64 bits
IP
F
For 16 rounds
FP
Ciphertext 64 bits
S S S S S S S S
a block using the first encryption key and then encrypt the resulting
ciphertext with the second encryption key. The decryption is a process
conducted in reverse.
The resulting ciphertext block should be very difficult to be
decrypted. Instead of 256 attempts, it requires 2128 attempts to find the
key and 2112 attempts to break the encryption. In 1981, Merkle and
Hellman declared the “meet-in-the-middle attack,” which proved the
74 Securit y f o r Rel ati o n a l Data ba se s
The IDEA cipher was first presented by Lai and Massey in 1990 under
the name of proposed encryption standard (PES). After Biham and
Shamir presented differential cryptanalysis, the authors named it the
improved proposed encryption standard (IPES). The IPES name was
changed to international data encryption algorithm (IDEA) in 1992.
F un da m en ta l s o f In f o rm ati o n En c ry p ti o n 75
4.5.5 Blowfish
The iterated block RC5 was introduced by Rivest, Shamir, and Adleman
in 1994 [58]. The main feature of the RC5 is the heavy use of data-
dependent rotations. RC5 has a variable word size, w, a variable number
of rounds, r, and a variable secret key with b bytes. It is represented as
RC5 w/r/b. The nominal value of w is 32 bits, and RC5 encrypts blocks
of two words. The RC5 is composed of encryption, decryption, and key
expansion. The expanded key contains t = 2 × (r + 1) words. The primi-
tive operations of the RC5 are illustrated in Table 4.3. Generally, RC5
is a fast symmetric block cipher that is suitable for hardware and soft-
ware implementations with low memory requirements. It provides high
security when good parameters are chosen.
Ai–1 Bi–1
<<< <<<
+ S2i
+ S2i+1
Ai Bi
End
B = B-S [1];
A = A-S [0];
4.5.6.3 RC5 Key Expansion Key expansion expands the user’s secret
key, K, to fill the expanded key array S, which makes S similar to an
array of t = 2(r + 1) random binary words. Two magic constants, Pw
and Qw, are used in this process. These constants are defined as
( )
Pw = Odd ( e − 2 ) 2w (4.3)
( )
Qw = Odd ( φ − 1) 2w (4.4)
where
e = 2.718281828459....(base of natural logarithms)
ϕ = 1.618033988749....(golden ratio)
and Odd(x) is the odd integer nearest to x
For w = 16 and 32, these constants are given in hexadecimals:
P 16 = b7e1; Q16 = 9e37
P 32 = b7e15163; Q 32 = 9e3779b9
S [0] = Pw;
For i = 1 to t-1 do
S [i] = S [i-1] + Qw;
End
The last step is to mix the user secret key in three passes over the
arrays S and L as follows:
i = j = 0;
A = B = 0;
Do 3*max (t, c) times:
78 Securit y f o r Rel ati o n a l Data ba se s
The RC6 block cipher is a modified version of RC5, which uses four
working registers instead of two, as well as integer multiplication as an
additional primitive operation. The integer multiplication process greatly
enhances the diffusion achieved per round, which leads to greater secu-
rity, fewer rounds, and increased throughput. The key schedule of RC6-
w/r/b is similar to the key schedule of RC5-w/r/b. The only difference
is that for RC6-w/r/b, more words are derived from the user-supplied
key for use during encryption and decryption. The user supplies a key
of b bytes, where 0 ≤ b ≤ 255. From this key, 2r + 4 words (w bits each)
are derived and stored in the array S[0, …, 2r + 3]. This array is used in
both encryption and decryption [59]. Generally, RC6 consists of two
Feistel networks whose data are mixed via data-dependent rotations.
The operations in a single round of RC6 contain two applications of the
squaring function f (x) = x (2x + 1) mod 232, two fixed 32-bit rotations,
two data-dependent 32-bit rotations, two XORs, and two additions
modulo 232. The steps of RC6 encryption and decryption are summa-
rized next and the block diagrams or RC6 encryption and decryption
are shown in Figures 4.7 and 4.8, respectively.
B = B + S [0];
D = D + S [1];
For i = 1 to r do
{t = (B × (2B + 1)) <<< lg w;
u = (D × (2D + 1)) <<< lg w;
F un da m en ta l s o f In f o rm ati o n En c ry p ti o n 79
A B C D
+ S[0] + S[1]
<<< f <<< f
lg w lg w
<<<
<<<
+ S[2r+2] + S[2r+3]
A B C D
A B C D
– S[2r+2] – S[2r+3]
– S[2i] – S[2i+1]
>>>
<<< f <<< f
lg w lg w
– S[0] – S[1]
A B C D
C = C − S [2r + 3];
A = A − S [2r + 2];
for i = r downto 1 do
{(A, B, C, D) = (D, A, B, C);
u = (D × (2D + 1)) <<< lg w;
t = (B × (2B + 1)) <<< lg w;
C = ((C − S[2i + 1]) >>> t) ⊕ u;
A = ((A − S[2i]) >>> u) ⊕ t;}
End
D = D − S [1];
B = B − S [0];
F un da m en ta l s o f In f o rm ati o n En c ry p ti o n 81
b1 b2 b3 b4 d1 d2 d3 d4
b5 b6 b7 b8 SubBytes d5 d6 d7 d8
and the fourth rows are shifted by offsets of two and three bytes,
respectively. For the block of size 128 bits and 192 bits, the shifting
pattern is the same [40].
In the case of the 256-bit blocks, the first row is unchanged and
the shifting for second, third, and fourth rows is 1 byte, 3 bytes, and
4 bytes, respectively, as shown in Figure 4.10.
In the MixColumns step, the four bytes of each column of the
state are combined using an invertible linear transformation. The
MixColumns function takes four bytes as input and outputs four
bytes, where each input byte affects all the four output bytes. With
ShiftRows, MixColumns provides diffusion in the cipher system.
Each column is treated as a polynomial over GF(28) and is then multi-
plied with a fixed polynomial c(x) = 3x3 + x2 + x + 2. The MixColumns
step can also be viewed as a multiplication by a particular matrix, as
shown in Figure 4.11 [36,37].
In the AddRoundKey step, the subkey is combined with the state.
For each round, a subkey is derived from the main key using the
algorithm key schedule. Each subkey has the same size as the state.
b1 b2 b3 b4 b1 b2 b3 b4
b5 b6 b7 b8 ShiftRows b6 b7 b8 b5
b1 b2 b3 b4 d1 d2 d3 d4
b5 b6 b7 b8 MixColumns d5 d6 d7 d8
b1 b2 b3 b4 d1 d2 d3 d4
b5 b6 b7 b8 AddRoundKey d5 d6 d7 d8
k1 k2 k3 k4
k5 k6 k7 k8
The subkey is added by combining each byte of the state with the
corresponding byte of the subkey using a bitwise XOR [36,37].
The AddRoundKey step is shown in Figure 4.12. We will apply the
AES with a fixed block size of 128 bits and a key size of 128 bits.
Cj = EK (Pj ) (4.5)
Pj = DK (C j ) (4.6)
The CBC mode uses an IV of size equal to the size of each block of
pixels. In this mode, each block of plaintext is XORed with the previ-
ous ciphertext block before being encrypted. This way, each ciphertext
block is dependent on all plaintext blocks up to that point. In decryp-
tion, the same XOR operation is repeated so that its effect is cancelled.
This mechanism is shown in Figure 4.14.
The main disadvantage of the CBC mode is that an error in (or attack
upon) one ciphertext block impacts two plaintext blocks upon decryp-
tion. On the other hand, if we have an image that has blocks of the
same input data, these blocks are encrypted to totally different cipher-
text data. So, the CBC mode is a better approach in encrypting images
in the spatial domain, especially when these images contain large areas
of the same activity. In the CBC mode, the encryption algorithm is
Cj = EK (Cj−1 ⊕ Pj) (4.7)
and the decryption algorithm is
Pj = DK (Cj ) ⊕ Cj−1, j = 1, 2, 3, … (4.8)
C 0 = IV (4.9)
P1 P2 P3
C0 = IV
C1 C2 C3
C0 = IV EK I1 EK I2 EK I3
P1 P2 P3
C1 C2 C3
bits of the encrypted IV and the corresponding bits of the first block
of the image. The result is the encrypted version of the first block.
For the encryption of each of the next plaintext blocks, the previous
ciphertext block is encrypted and the output is XORed with the cur-
rent plaintext block to create the current ciphertext block. The XOR
operation conceals plaintext patterns.
Common to the CBC mode, changing the IV to the same plaintext
block results in different outputs. Though the IV need not be secret,
some applications would see this as desirable [36,37]. Figure 4.15
shows the CFB mode. The encryption algorithm is
Cj = Pj ⊕ Ij (4.10)
Pj = Cj ⊕ Ij (4.11)
C 0 = IV (4.13)
I0 = IV EK I1 EK I2 EK I3
P1 P2 P3
C1 C2 C3
I0 = IV (4.17)
5
E n cryp ti on -B ased
M ultile v el M o d el
for DBMS
5.1 Introduction
89
90 Securit y f o r Rel ati o n a l Data ba se s
• It causes the part of the memory that holds the decrypted data
to be blocked so that it can be accessed only from the database
engine instance.
• It supports multilevel security to the data so that the user
can see only the data in his level and a lower security level.
Supporting multilevel security in this model overcomes the
problem of caching because it generates a security layer that
manages the data access in the memory.
5.3 Manipulation
Set i = 1
i=i+1 Ai ∈ R [Ai]*
No Yes
Ai = null
Ci = L(user)
K = KCi
Ai = E (K, ai)
TC = L (user)
End
Figure 5.1 Flow chart for insertion operation in the encryption-based multilevel database model.
(A. Rask, D. Rubin, and B. Neumann. 2005. Implementing row- and cell-level security in classi-
fied databases using SQL server. Available at http://technet.microsoft.com/en-us/library/cc966395.
aspx; accessed April 2011.)
Figure 5.2 illustrates the flow chart for the delete operation in the
encryption-based multilevel database model.
Ci = L(user)
K = KCi
Set i = 1
Yes
ti[TC] = L(user)
No
Yes No
ti satisfy P
Yes
Mark to be deleted
Detele ti
No by high user
End
Figure 5.2 Flow chart for the delete operation in the encryption-based multilevel database
model. (Y. Elovici et al. 2004. Proceedings of International Conference SDM, 28–40.)
Ci = L(user)
K = KCi
Set i = 1
i=i+1
ti[TC] = L(user)
No
Yes
No
ti satisfy P
Yes
Display ti
End
Figure 5.3 Flow chart for the select operation in the encryption-based multilevel database
model. (X.-D. Zuo, F.-M. Liu, and C.-B. Ma. 2007. Proceedings of the Sixth International Conference on
Machine Learning and Cybernetics, Hong Kong, 2158–2163.)
Ci = L(user)
K = KCi
Set i = 1
No
ti satisfy P
Yes
ti [PK] ∈ [Ai]*
No Yes
Yes No
Update t’i
Display t’i
End
Figure 5.4 Flow chart for the update operation in the encryption-based multilevel database
model. (N. Kaur, R. Singh, and H. S. Saini. 2009. Proceedings of IEEE International Advance Computing
Conference (IACC 2009) Patiala, India, 1400–1404.)
Ci = L(user)
K = KCi
Set i = 1
ti [TC] ≤ L(user)
No Yes
i=i+1
Set j = 1
ti[Aj] ∈ [Ai]*
Yes No j=j+1
End
Figure 5.5 Flow chart for the uplevel operation in the encryption-based multilevel database
model. (R. Haraty and N. Bekaii. 2006. Journal of Computer Science 2 (1): 19–28.)
10 0 Securit y f o r Rel ati o n a l Data ba se s
The timesheet database consists of four relations and was created and
populated to facilitate our performance study. Timesheet system rela-
tions used in the implementation are described as follows:
• The employee relation provides information about employees:
• Employee(EMPID, Code, Name, Department, Type,
Contract, Shift, Religion, Job, Position, Address, City).
• The departure relation is used to store the departure notice of
each employee when he leaves the site of the work:
• Departure(EMPID, DepartureDate, ReturnDate,
DepartureType)
• The timesheet relation is used to store the timesheet of each
employee every day:
• TimeSheet(EMPID, Date, TimeSheet, OverTime,
Remarks)
• The annual rights relation is used to store the rights of each
employee every year:
• AnnualRights(EMPID, Year, Description, Inc, ADays,
GDays)
Multil e v el M o d el f o r D BM S 101
1.40
1.30
1.20
1.10
Response Time (m)
1.00
0.90
0.80
0.70
0.60
0.50
0 0.5 1 1.5 2
Number of Tuples Millions
Figure 5.6 The impact of changing the number of tuples on the performance of the encryption
algorithms in a multilevel database in the selection query. (P. Dave. 2008. Available at http://dotnet-
slackers.com/articles/sql/IntroductionToSQLServerEncryptionAndSymmetricKeyEncryptionTutorial.
aspx, accessed May 2011.)
Figure 5.7 The ER diagram for the timesheet system used in the implementation.
50
Number of attributes = 3
45 Number of security levels = 4
40
35
Response Time (minutes)
30
25
20
15
10
0
0 0.5 1 1.5 2
Number of Tuples Millions
SeaView Jajodia-Sandhu Smith-Winslett
MLR Belief-Consistent MLS-Encryption
Figure 5.8 Impact of changing the number of tuples in the selection query. (M. Garuba. 2003.
PhD thesis, Department of Mathematics, Royal Holloway, University of London, Egham, Surrey.
Available at http://digirep.rhul.ac.uk/items/f076f347-2036-6bd0-98c8-e1d2dc9cf4ab/1/, accessed
April 2011.)
10 4 Securit y f o r Rel ati o n a l Data ba se s
45
Number of tuples = million
Number of security levels = 4
40
35
Response Time (minutes)
30
25
20
15
10
0
2 3 4 5 6
Number of Attributes
SeaView Jajodia-Sandhu Smith-Winslett
MLR Belief-Consistent MLS-Encryption
Figure 5.9 Impact of changing the number of attributes in the selection query. (M. Garuba,
E. Appiah, and L. Burge. 2004. Proceedings of the International Conference on Information Technology:
Coding and Computing (ITCC’04), 566–570.)
Multil e v el M o d el f o r D BM S 10 5
40
Number of attributes = 3
Number of tuples = million
35
30
Response Time (minutes)
25
20
15
10
0
2 3 4 5 6
Number of Classification Levels
SeaView Jajodia-Sandhu Smith-Winslett
MLR Belief-Consistent MLS-Encryption
Figure 5.10 Impact of changing the number of security levels in the selection query. (Z. Rashid,
A. Basit, and Z. Anwar. 2010. Proceedings of 6th International Conference on Emerging Technologies
(ICET), 337–342.)
50 Number of attributes = 3
45 Number of security levels = 4
40
Response Time (minutes)
35
30
25
20
15
10
0
0 0.5 1 1.5 2
Number of Tuples Millions
SeaView Jajodia-Sandhu Smith-Winslett
MLR Belief-Consistent MLS-Encryption
Figure 5.11 Impact of changing the number of tuples in a join query. (V. M. Doshi et al. 1996.
Proceedings of IEEE Transactions on Knowledge and Data Engineering 8 (1): 46–55.)
Multil e v el M o d el f o r D BM S 10 7
40
Response Time (minutes)
35
30
25
20
15
10
0
2 3 4 5 6
Number of Attributes
SeaView Jajodia-Sandhu Smith-Winslett
MLR Belief-Consistent MLS-Encryption
Figure 5.12 Impact of changing the number of attributes in a join query. (L. Pan. 2008.
Proceedings of International Symposium on Electronic Commerce and Security, 518–522.)
10 8 Securit y f o r Rel ati o n a l Data ba se s
50 Number of attributes = 3
45 Number of tuples = million
40
Response Time (minutes)
35
30
25
20
15
10
0
2 3 4 5 6
Number of Classification Levels
SeaView Jajodia-Sandhu Smith-Winslett
MLR Belief-Consistent MLS-Encryption
Figure 5.13 Impact of varying the number of security levels in a join query. (L. Pan. 2008.
Proceedings of International Symposium on Electronic Commerce and Security, 518–522.)
From Figure 5.13 the response times grow for all models as the n
umber
of the security levels is increased. Also, supporting encryption in the
encryption-based multilevel database model improves the performance
of a multilevel database because the database size is decreased due to
removing the extra attributes used for the class levels.
14
Number of attributes = 3
Number of security levels = 4
12
10
Response Time (minutes)
0
0 0.25 0.5 0.75 1
Number of Tuples Millions
SeaView Jajodia-Sandhu Smith-Winslett
MLR Belief-Consistent MLS-Encryption
Figure 5.14 Impact of varying the number of tuples in an update query. (L. Pan. 2008. Proceedings
of International Symposium on Electronic Commerce and Security, 518–522.)
Upd
ate Employee set salary = salary+100 where
department = ‘Sales’
Table 5.4 Reduction in Database Size in Proposed Model Compared to Original MLR Model and
Other MLS Models
ENCRYPTION-
BELIEF- BASED
MODEL/ ORIGINAL JAJODIA– SMITH– CONSISTENT MULTILEVEL
CRITERIA MLR SEAVIEW SANDHU WINSLETT MLS DATABASE
Actual 106 129 116 98 110 91
database size
in megabytes
Reduction in Reduced Reduced Reduced Reduced Reduced by
database size by 15% by 30% by 22% by 8% 18%
in our proposed
model
Multil e v el M o d el f o r D BM S 111
5.6 Summary
6.1 Introduction
This chapter will present the formal analysis for data manipulation
language (DML) operations like SELECT, INSERT, UPDATE, and
DELETE for the encryption-based multilevel model for relational
database management systems. Also, this chapter will give the
soundness, completeness, and the security mathematical proof for the
DML operations of the encryption-based multilevel database model.
The mathematical proofs show that the DML operations transform
any database in the correct state to another database in the correct
state, which indicates the power of the encryption-based multilevel
database model [75].
This model achieves good quality because it satisfies integrity
properties such as entity integrity, polyinstantiation integrity, data
borrow integrity, foreign key integrity, and referential integrity of the
multilevel database.
The work presented in this chapter offers two major contributions
to the field:
• Redefining the mathematical model for the DML operations
for the encryption-based multilevel model
• Proving the soundness, completeness, and security of the
DML operations for the encryption-based multilevel model
113
114 Securit y f o r Rel ati o n a l Data ba se s
• R(A1, C1, A2, C2, …, An, Cn, TC), where Ai is the attribute
that stores the data, Ci is the attribute that stores the secu-
rity c lassification level of the attribute Ai, and TC is the attri-
bute that stores the security classification level of the tuple.
The domain of the value of the attribute Ci is defined by a
set {Li, …, Hi} where the Li is the lowest security classifica-
tion level and the Hi is the highest security classification level.
The domain of the TC is defined as U in=1 ({ Li ,... , H i }), where
U stands for the set of union.
requirement ensures that all the foreign key attributes FK should have
the same security classification level in the tuple t ∈ r.
= t 22 [ AK 2 ], then t 21 [ AK 2 ] = t 22 [ AK 2 ].
6.4 Manipulation
R is the relation name and [A1, A 2, ..., A n] are the attribute names.
KCi is the symmetric encryption key associated to the s ecurity level of
the user. E(K, ai) is the encryption of data value ai by an encryption
key. Each INSERT data manipulation can insert, at most, one tuple
into the relation R. The inserted tuple t is constructed as follows:
For 1≤i≤n
If (Ai ∈ R[Ai]*)
{
Ci = L(user)
K = KCi
t[Ai] = E(K,ai)
}
Else
{
t[Ai] = null
}
t[TC] = L
i = i+1
DELETE FROM R
WHERE P
Ci = L(user)
K = KCi
For 1≤i≤n
IF (ti[TC]= L(user)
{
ti(temp) = D(K, E(K, ti))
If (ti(temp) = p)
{
Delete ti
}
i = i +1
}
Else IF (ti[TC] ≻ L(user))
{
Mark to be deleted by high user.
i = i+1
}
Else
{
i = i+1
}
Ci = L(user)
K = KCi
For 1≤i≤n
IF (ti[TC] = L(user))
{
ti(temp) = D(K,E(K,ti))
If (ti(temp) = p)
{
Display ti
}
i = i+1
}
Else
{
i = i+1
}
where R is the relation name, [A1,A 2,...,A n] are the attribute names,
and P is a predicate expression that may include conditions involving
classification attributes. ti(temp) is a temporary tuple for the decrypted
data during the execution of the delete statement. D(K,E(K,ti)) is
the decryption of the encrypted data value in the tuple ti by a sym-
metric encryption key.
Ci = L(user)
K = KCi
For 1≤i≤n
IF (ti[TC] = L(user))
{
ti(temp) = D(K, E(K, ti))
f o rm a l a n a lysis f o r D M L o p er ati o ns 12 3
If (ti(temp) = p)
{
IF (ti[TC]≻L(user))
{
Mark to be deleted by high user.
i = i+1
}
Else
{
ti[Ai] = E(K, ai)
Update ti
}
i = i +1
}
Else
{
i = i+1
}
UPLEVEL R GET [A1, A2, ..., An] FROM [C1, C2, ..., Cn]
WHERE P
Ci = L(user)
K = KCi
For 1≤i≤n
IF (ti[TC] = L(user))
{
ti(temp) = D(K, E(K, ti))
12 4 Securit y f o r Rel ati o n a l Data ba se s
For 1≤j≤n
{
IF (ti(temp)[Aj]∈[Aj]*)
{
ti[Aj]=E(K,ti(temp)[Aj])
}
Else
{
ti[Aj]= null
}
j = j +1
}
Tuple t will be inserted
}
Else
{
i = i+1
}
6.5 Soundness
The entity integrity, the foreign key integrity, and the referential
integrity properties should be satisfied in the INSERT operation.
Polyinstantiation integrity is satisfied because of the following:
• There is no polyinstantiated tuple t″ in the original relation
instance r with t ′′[ EC1 ( A1 )] = t [ EC1 ( A1 )] ∧ t ′′[TC ] = L, since
inserting the tuple t is permitted only if there is no t′ ∈ r such
that t'[A1] = t[A1] ∧ t'[TC] = L.
• There is no polyinstantiated tuple t″ in the original relation
instance r with t ′′[ EC1 ( A1 )] = t [ EC1 ( A1 )] ∧ t ′′[TC ] > L.
Data-borrow integrity is satisfied because of the following:
• There is no data attribute t[Ai](1 ≤ i ≤ n) in the tuple t with
t[Ci] < t[TC].
The entity integrity, the foreign key integrity, and the referential
integrity properties should be satisfied in the UPDATE operation.
Polyinstantiation integrity is satisfied because of the following:
• There is no polyinstantiated tuple t′ in the original relation
instance r with t ′[ EC1 ( A1 )] = t [ EC1 ( A1 )]∧ t′[TC] > L ∧ t′[Ci] =
L(2 ≤ i ≤ n).
• There is no polyinstantiated tuple t″ with t″ [ EC1 ( A1 )] =
t [ EC1 ( A1 )] ∧ t″[TC] > L ∧ t″[Ci] = L(2 ≤ i ≤ n).
Data-borrow integrity is satisfied because of the following:
• There is no polyinstantiated tuple t′ in the original relation
instance r with t ′[ EC1 ( A1 )] = t [ EC1 ( A1 )] ∧ t′[TC] > L ∧ t′[Ci] =
L(2 ≤ i ≤ n).
The polyinstantiation integrity, the foreign key integrity, and the refer-
ential integrity properties should be satisfied in the UPDATE operation.
Entity integrity is satisfied because of the following:
• There is no tuple polyinstantiated tuple t′ in the original
relation instance r with t ′[ EC1 ( A1 )] = t [ EC1 ( A1 )].
Data-borrow integrity is satisfied because of the following:
• There is no polyinstantiated tuple t′ in the original relation
instance r with t ′[ EC1 ( A1 )] = t [ EC1 ( A1 )] ∧ t′[TC] > L ∧ t′[Ci] =
L(2 ≤ i ≤ n).
6.6 Completeness
Proof of Theorem 6.6.1: From Lemmas 6.6.1 and 6.6.2, the sequences
of the data manipulation operational statements transform any legal
database state to another legal database state.
6.7 Security
Insert
Delete Encryption MLR
Success/
Select System Data
Failure
Proof of Lemma 6.7.2: The user can change the database states by an
INSERT, DELETE, UPDATE, or UPLEVEL operation.
Proof of Theorem 6.7.1: From Lemma 6.7.1 and Lemma 6.7.2, for
any security classification level L, since S = SV(L) ∪ SH(L), SV(L) ∩
f o rm a l a n a lysis f o r D M L o p er ati o ns 131
6.8 Summary
7.1 Introduction
13 3
13 4 Securit y f o r Rel ati o n a l Data ba se s
A schedule: OH,1, ….., OH,K ; OL,1 , ….., OL,m ; OH,K+1 , ….., OH,n ; CH
Invisible area of TH
TH Suspends TL Resumes TH
No
Tj in Execution
Yes
The scheduler executes Ti
Yes
L(Ti) > L(Tj)
No
No
L(Ti) = L(Tj)
Yes
(W-set?? Tj ∩
R-set?? Ti ≠ φ) &
Block Ti
(W-set?? Tj ∩
W-set?? Ti ≠ φ)
No Yes
End
Figure 7.2 The flow chart for the enhanced secure multiversion concurrency control model.
Figure 7.3 ER diagram for the timesheet system used in the implementation.
500
450
400
350
Response Time (ms)
300
250
200
150
100
0
0 20 40 60 80 100
Arrival Rate
Figure 7.4 The impact of varying the arrival rates on the response times of the enhanced secure
multiversion concurrency control model and the Rajwinder Singh model.
Multil e v el Rel ati o n a l Data ba se s 14 3
500
450
400
350
Response Time (ms)
300
250
200
150
100
50
0
0 20 40 60 80 100
Arrival Rate
Figure 7.5 The impact of varying the arrival rates on the response times of the enhanced secure
multiversion concurrency control model and the Rajwinder Singh model per security level.
the Rajwinder Singh model is the same at the low arrival rates. This is
because the conflict area is low. As the arrival rate increases, the
enhanced secure multiversion concurrency control model has better
performance than the performance of the Rajwinder Singh model.
This improvement in the performance is due to the reduction of the
denying time of high classification level transactions and improves
their response time.
In Figure 7.5, the response times of the enhanced secure multiver-
sion concurrency control model and the Rajwinder Singh model are
measured by calculating the response times at each classification level
by using various arrival rates.
7.6 Summary
8.1 Introduction
147
14 8 Securit y f o r Rel ati o n a l Data ba se s
defined to the data. The tuple classification is the security level for all
the tuples in the relation.
In Table 8.1, the three tuples present the same data but the
polyinstantiation integrity policy divides the information according
to the various classification levels. Thus, this model stores more
data in the multilevel relational database, resulting in data
redundancy.
The MLR security model [100] presents the “data borrow”
concept and stores pointers in the higher level data (not the real
data) to o vercome the data redundancy problem. There is another
problem: We still need to save three tuples to present the single real
datum.
The BCMLS model [100] prevents the data redundancy problem
if the data redundancy of the attributes has the same classification
level, as shown in Table 8.1. The tuples can be saved as in Table 8.2
in BCMLS. If we have data as in Table 8.3, the BCMLS model
will need to save three tuples and the data redundancy cannot be
decreased.
• The problem of the null value inference: The inference when
dealing with the data is the second problem that faces the
multilevel security model. For example, if we have some of
the data as shown in Table 8.4(a), if the user with U classi-
fication level needs to execute select query, the result may be
null values, as described in Table 8.4(b). The null values could
cause some inference risks [101].
Class 2 Class 3
Class
Data
Since the user with a lower classification level cannot read the
higher classification level data, the instance view at the U classifica-
tion level contains less data than the view at the S classification level.
The instance view at classification level Lj, which is i{(Pi, Lq) | Pi ∈ P,
Lq ≤ Lj and Lq Lj ∈ L} is related to the Class({PK}, {ui}) if the property
{PK} is a subgroup of the property {Pi }. A user with U classification
level can access Class({PK}, {ui}) if the user U ∈ {ui}.
15 2 Securit y f o r Rel ati o n a l Data ba se s
The SQL-like command for the select operation has the following form:
SELECT [Ai]*
FROM R
WHERE P
Set i = 1
i=i+1
Get Classi ({P}, {u})
No
U ∈ Classi {u}
Yes
Set K = 1
K=K+1
No
InstanceK ∈ Classi
Yes
Set j = 1
j=j+1
Get PLj
No
L(user) ≥ PLj
Yes
Display PLj
End
Figure 8.2 The SELECT operation procedure in IBMSM. (E. Fernandez, E. Gudes, and
H. Song. 1989. Proceedings of the IEEE Symposium on Security and Privacy, 110–115.)
15 4 Securit y f o r Rel ati o n a l Data ba se s
The SQL-like command for the insert operation has the following
form:
INSERT
INTO R [Ai]*
VALUES [ai]*
The SQL-like command for the update operation has the following
form:
UPDATE R
SET Ai = ai,[Ai=ai]*
WHERE P
Set i = 1
i=i+1
Get Classi ({P}, {u})
No
U ∈ Classi {u}
Yes
Set j = 1
j=j+1
Get PLj
PLj ∈ R[Ai]*
No Yes
End
Figure 8.3 The INSERT operation procedure in IBMSM. (E. Fernandez, E. Gudes, and H. Song.
1994. International Journal of IEEE Transactions on Knowledge and Data Engineering 6 (2):
275–292.)
15 6 Securit y f o r Rel ati o n a l Data ba se s
Set i = 1
i=i+1
Get Classi ({P}, {u})
No
U ∈ Classi {u}
Yes
Set K = 1
K=K+1
No
InstanceK ∈ Classi
Yes
Set j = 1
j=j+1
Get PLj
No
L(user) ≥ PLj
Yes
Update PLj
End
Figure 8.4 The UPDATE operation procedure in IBMSM. (E. Fernandez et al. 1994. International
Journal of IEEE Transactions on Knowledge and Data Engineering 6 (2): 275–292.)
Ins ta n c e- Ba sed Multil e v el Securit y M o d el 15 7
The SQL-like command for the delete operation has the following
form:
DELETE
FROM R
WHERE P
Step 1: get the classification level of the user that executes the
delete operation L(User).
Step 2: get the class views that belong to this user.
Step 3: get all the instance views that belong to the class views of
the user and satisfy the update condition P.
Step 4: for each instance, in the instance views, delete the
property that has class level equal to the class level of the
user.
Set i = 1
i=i+1
Get Classi ({P}, {u})
No
U ∈ Classi {u}
Yes
Set K = 1
K=K+1
No
InstanceK ∈ Classi
Yes
Set j = 1
j=j+1
Get PLj
No
L(user) ≥ PLj
Yes
Detele PLj
End
Figure 8.5 The DELETE operation procedure in IBMSM. (J. Parsons and J. Su. 2006. Proceedings
of Design Science Research in Information Systems and Technology (DESRIST), Claremont, CA,
107–130.)
Ins ta n c e- Ba sed Multil e v el Securit y M o d el 15 9
8.9 Summary
9.1 Introduction
This chapter will present the source code of the prototype that was
used throughout this book. The tools that are used in the implementa-
tion of the prototype are described as follows:
• Microsoft SQL server 2008 R2. SQL server is a relational
database management system (RDBMS) from Microsoft
that is designed for the enterprise environment. SQL Server
runs on T-SQL (Transact-SQL), a set of programming
extensions from Sybase and Microsoft that add several
features to standard SQL, including transaction control,
exception and error handling, row processing, and declared
variables.
• Microsoft Visual Studio C#. Microsoft Visual Studio is an
integrated development environment (IDE) from Microsoft.
It is used to develop console and graphical user interface
applications. The C# language is a simple, modern, general-
purpose, object-oriented programming language.
This chapter will present the screen shots of the prototype and
the source code of the Microsoft SQL server 2008 R2 and the
Microsoft Visual Studio C# that were used in the implementation of
the prototype.
The screen in Figure 9.1 is used for making the user log in to the
database by selecting the SQL server and entering his user name and
his password. At this screen the prototype will verify the credentials
of the user and will determine the user’s security classification level
(Figure 9.2).
161
16 2 Securit y f o r Rel ati o n a l Data ba se s
After successfully logging in, the user will get the query form. This
screen is used to help the user in executing his SQL query statement
and it contains the following:
• Execution button: used for executing the SQL query statement
• Selective radio button: used for selecting the multilevel data-
base security model
T he S o ur c e C o d e 16 3
The source code of the Microsoft SQL server will be divided into
four parts:
• Create some tables that define the security classification levels
of the data in the multilevel relational database.
16 4 Securit y f o r Rel ati o n a l Data ba se s
Figure 9.4 The entity relationship diagram of the data security classification levels tables.
GO
CREATE TABLE [dbo].[tblMarking](
[CategoryID] [int] NOT NULL,
[MarkingRoleName] [nvarchar](50) NOT NULL,
[MarkingString] [nvarchar](50) NULL,
[Description] [nvarchar](50) NULL,
[RoleType] [nvarchar](50) NULL,
[InternallyGenerated] [nvarchar](50) NULL,
CONSTRAINT [PK_tblMarking] PRIMARY KEY CLUSTERED
(
[CategoryID] ASC,
[MarkingRoleName] ASC
)WI
TH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_
PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[tblMarkingHierarchy](
[ParentCategoryID] [int] NOT NULL,
[ParentMarkingRoleName] [nvarchar](50) NOT NULL,
[ChildCategoryID] [int] NOT NULL,
[ChildMarkingRoleName] [nvarchar](50) NOT NULL,
CON
STRAINT [PK_tblMarkingHierarchy] PRIMARY KEY
CLUSTERED
(
[ParentCategoryID] ASC,
[ParentMarkingRoleName] ASC,
[ChildCategoryID] ASC,
[ChildMarkingRoleName] ASC
)WI
TH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_
PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[tblUniqueLabel](
[ID] [int] NOT NULL,
[Label] [nvarchar](50) NULL,
[KeyName] [nvarchar](50) NULL,
[CertName] [nvarchar](50) NULL,
CONSTRAINT [PK_tblUniqueLabel] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WI
TH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_
PAGE_LOCKS = ON) ON [PRIMARY]
16 6 Securit y f o r Rel ati o n a l Data ba se s
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[tblUniquelabelMarking](
[KeyMappingID] [int] NOT NULL,
[CategoryID] [int] NOT NULL,
[MarkingRoleName] [nvarchar](50) NOT NULL,
CON
STRAINT [PK_tblUniquelabelMarking] PRIMARY KEY
CLUSTERED
(
[KeyMappingID] ASC,
[CategoryID] ASC,
[MarkingRoleName] ASC
)WI
TH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_
PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
USE [MLSDB]
CRE
ATE USER [SUser] FOR LOGIN [SUser] WITH DEFAULT_
SCHEMA = [dbo]
GO
USE [MLSDB]
CRE
ATE USER [TSUser] FOR LOGIN [TSUser] WITH DEFAULT_
SCHEMA = [dbo]
GO
USE [MLSDB]
CREATE ROLE [U] AUTHORIZATION [dbo]
GO
USE [MLSDB]
CREATE ROLE [C] AUTHORIZATION [dbo]
GO
USE [MLSDB]
CREATE ROLE [S] AUTHORIZATION [dbo]
GO
USE [MLSDB]
CREATE ROLE [TS] AUTHORIZATION [dbo]
GO
The base table is called Employee and its source code for the creation
is described as follows:
The modifications to the base table to form the SeaView model are
described as follows:
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[D2-c](
[Name] [nvarchar](50) NULL,
[CName] [int] NOT NULL,
[Department] [nvarchar](50) NULL,
[CDept] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[D2-s](
[Name] [nvarchar](50) NULL,
[CName] [int] NOT NULL,
[Department] [nvarchar](50) NULL,
[CDept] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[D2-ts](
[Name] [nvarchar](50) NULL,
[CName] [int] NOT NULL,
[Department] [nvarchar](50) NULL,
[CDept] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[D2-u](
[Name] [nvarchar](50) NULL,
[CName] [int] NOT NULL,
[Department] [nvarchar](50) NULL,
[CDept] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[D3-c](
[Name] [nvarchar](50) NULL,
[CName] [int] NOT NULL,
[Salary] [smallmoney] NULL,
[CSalary] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[D3-s](
[Name] [nvarchar](50) NULL,
[CName] [int] NOT NULL,
[Salary] [smallmoney] NULL,
[CSalary] [int] NOT NULL
) ON [PRIMARY]
GO
T he S o ur c e C o d e 171
The modifications to the base table to form the MLR model are
described as follows:
[CName] ASC,
[CDept] ASC,
[CSalary] ASC,
[TC] ASC
)WI
TH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_
PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
The following SQL functions are used in the views of each model of
the multilevel relational database models:
an
d u.principal_id = m.
member_principal_id
and u.name = CURRENT_USER
return @Label
END
GO
Cre
ate FUNCTION [dbo].[GetTCLabel](@CID int,@CName
int,@CDept int,@CSalary int)
RETURNS int
AS
BEGIN
declare @TC int
select @TC = LabelID from dbo.SortLabels()
whe
re Sort in (select min(Sort) from dbo.SortLabels()
where LabelID in (@CID,@CName,@CDept,@CSalary))
return @TC
END
GO
CREATE FUNCTION [dbo].[GetlBCLabe](@label int)
RETURNS nvarchar(10)
AS
BEGIN
declare @NewLabel nvarchar(10)
declare @ULabel nvarchar(1)
declare @CLabel nvarchar(1)
declare @SLabel nvarchar(1)
declare @TLabel nvarchar(1)
set @NewLabel = ‘’
set @ULabel = ‘’
set @CLabel = ‘’
set @SLabel = ‘’
set @TLabel = ‘’
set @ULabel = Cast(@label% 4 as nvarchar(1))
set @label = @label/4
set @CLabel = Cast(@label% 4 as nvarchar(1))
set @label = @label/4
set @SLabel = Cast(@label% 4 as nvarchar(1))
set @label = @label/4
set @TLabel = Cast(@label% 4 as nvarchar(1))
if @ULabel = ‘1’
set @NewLabel = @NewLabel+’-U’
else if @ULabel = ‘2’
set @NewLabel = @NewLabel+’U’
if @CLabel = ‘1’
set @NewLabel = @NewLabel+’-C’
17 6 Securit y f o r Rel ati o n a l Data ba se s
— s
et @ViewLabel = @ViewLabel+SUBSTRING(@BreakedLabel,
@Counter,1)
SET @Counter = @Counter + 1
END
set @NewLabel = dbo.GetlBCLabe(@NumericLabel)
return @NewLabel
END
GO
create FUNCTION [dbo].[BreaklLabe](@label int)
RETURNS nvarchar(10)
AS
BEGIN
declare @NewLabel nvarchar(10)
declare @ULabel int
declare @CLabel int
declare @SLabel int
declare @TLabel int
set @ULabel = @label% 4
set @label = @label/4
set @CLabel = @label% 4
set @label = @label/4
set @SLabel = @label% 4
set @label = @label/4
set @TLabel = @label% 4
set@NewLabel = Cast(@ULabel As nvarchar(1))
+Cast(@CLabel As nvarchar(1)) +Cast(@SLabel As
nvarchar(1))+Cast(@TLabel As nvarchar(1))
return @NewLabel
END
GO
The source code of the view for each model of the multilevel rela-
tional database models is described as follows:
GO
CREATE VIEW [dbo].[vwEmployee]
AS
SEL ECT dbo.GetColumnData(dbo.Employee.Name, dbo.
Employee.CName) AS Name, dbo.GetColumnLabel
(dbo.Employee.CName) AS ClassName,
dbo.GetColumnData(dbo.Employee.Department,
dbo.Employee.CDept) AS Department, dbo.
GetColumnLabel(dbo.Employee.CDept) AS ClassDept,
dbo.GetColumnData(dbo.Employee.Salary,
dbo.Employee.CSalary) AS Salary, dbo.
GetColumnLabel(dbo.Employee.CSalary) AS
ClassSalary,
dbo.GetColumnLabel(dbo.Employee.TC) AS TC
FROM dbo.Employee INNER JOIN
dbo.vwVisibleLabels ON dbo.Employee.TC
= dbo.vwVisibleLabels.ID
GO
CREATE VIEW [dbo].[VBCEmployee]
AS
SEL ECT Name, dbo.GetBCUserView(CName) AS C _ Name,
Department, dbo.GetBCUserView(CDept) AS C _ Department,
Salary, dbo.GetBCUserView(CSalary) AS C _ Salary,
dbo.GetBCUserView(TC) AS C_Tuple
FROM dbo.BCEmployee
WHERE (dbo.GetBCUserView(TC) <> ‘’)
GO
CREATE VIEW [dbo].[UserVisibleSmithEmployee]
AS
SEL ECT dbo.SmithEmployee.name, dbo.SmithEmployee.
CName, dbo.SmithEmployee.Department, dbo.
SmithEmployee.Salary, dbo.SmithEmployee.TC
FROM dbo.SmithEmployee INNER JOIN
dbo.vwVisibleLabels ON dbo.GetLabelID
(dbo.SmithEmployee.TC) = dbo.
vwVisibleLabels.ID
GO
CREATE VIEW [dbo].[UserVisibleSeaViewEmployee]
AS
SEL ECT dbo.SeaViewEmployee.name, dbo.SeaViewEmployee.
CName, dbo.SeaViewEmployee.Department, dbo.
SeaViewEmployee.CDept, dbo.SeaViewEmployee.Salary,
dbo.SeaViewEmployee.CSalary, dbo.
SeaViewEmployee.TC
FROM dbo.SeaViewEmployee INNER JOIN
18 0 Securit y f o r Rel ati o n a l Data ba se s
dbo
.vwVisibleLabels ON dbo.GetLabelID
(dbo.SeaViewEmployee.TC) = dbo.
vwVisibleLabels.ID
GO
CREATE VIEW [dbo].[UserVisibleJSEmployee]
AS
SEL ECT dbo.JSEmployee.name, dbo.JSEmployee.CName, dbo.
JSEmployee.Department, dbo.JSEmployee.Salary, dbo.
JSEmployee.TC
FROM dbo.JSEmployee INNER JOIN
dbo.vwVisibleLabels ON dbo.GetLabelID(dbo.
JSEmployee.TC) = dbo.vwVisibleLabels.ID
GO
CREATE VIEW [dbo].[SmithEmployee]
AS
SEL ECT name, dbo.[GetCLabel](CName) CName, Department,
Salary,dbo.[GetCLabel](CName) TC
FROM dbo.[Smith-Employee]
GO
CREATE VIEW [dbo].[SeaViewEmployee]
AS
SEL ECT dbo.[D2-u].name, dbo.[GetCLabel](dbo.[D2-u].CName)
CName, dbo.[D2-u].Department, dbo.[GetCLabel]
(dbo.[D2-u].CDept) CDept, dbo.[D3-u].Salary,
dbo.[GetCLabel](dbo.[D3-u].CSalary)
CSalary, dbo.[GetCLabel]([dbo].
[GetTCLabel](4, dbo.[D2-u].CName, dbo.
[D2-u].CDept, dbo.[D3-u].CSalary)) TC
FROM dbo.[D2-u] JOIN
dbo.[D3-u] ON dbo.[D2-u].Name = dbo.
[D3-u].Name
UNION
SEL ECT dbo.[D2-u].name, dbo.[GetCLabel](dbo.[D2-u].CName)
CName, dbo.[D2-u].Department, dbo.[GetCLabel](dbo.
[D2-u].CDept) CDept, dbo.[D3-c].Salary,
dbo.[GetCLabel](dbo.[D3-c].CSalary)
CSalary, dbo.[GetCLabel]([dbo].
[GetTCLabel](4, dbo.[D2-u].CName, dbo.
[D2-u].CDept, dbo.[D3-c].CSalary)) TC
FROM dbo.[D2-u] JOIN
dbo
.[D3-c] ON dbo.[D2-u].Name = dbo.[D3-c].Name
UNION
SEL
ECT dbo.[D2-u].name, dbo.[GetCLabel](dbo.[D2-u].CName)
CName, dbo.[D2-u].Department, dbo.[GetCLabel]
(dbo.[D2-u].CDept) CDept, dbo.[D3-s].Salary,
T he S o ur c e C o d e 181
dbo.[GetCLabel](dbo.[D3-s].CSalary)
CSalary, dbo.[GetCLabel]([dbo].
[GetTCLabel](4, dbo.[D2-u].CName, dbo.
[D2-u].CDept, dbo.[D3-s].CSalary)) TC
FROM dbo.[D2-u] JOIN
dbo.[D3-s] ON dbo.[D2-u].Name = dbo.[D3-s].Name
UNION
SEL
ECT dbo.[D2-u].name, dbo.[GetCLabel](dbo.[D2-u].CName)
CName, dbo.[D2-u].Department, dbo.[GetCLabel](dbo.
[D2-u].CDept) CDept, dbo.[D3-ts].Salary,
dbo.[GetCLabel](dbo.[D3-ts].CSalary)
CSalary, dbo.[GetCLabel]([dbo].
[GetTCLabel](4, dbo.[D2-u].CName, dbo.
[D2-u].CDept, dbo.[D3-ts].CSalary)) TC
FROM dbo.[D2-u] JOIN
dbo.[D3-ts] ON dbo.[D2-u].Name = dbo.
[D3-ts].Name
UNION
SEL
ECT dbo.[D2-c].name, dbo.[GetCLabel](dbo.[D2-c].CName)
CName, dbo.[D2-c].Department, dbo.[GetCLabel](dbo.
[D2-c].CDept) CDept, dbo.[D3-u].Salary,
dbo.[GetCLabel](dbo.[D3-u].CSalary)
CSalary, dbo.[GetCLabel]([dbo].
[GetTCLabel](4, dbo.[D2-c].CName, dbo.
[D2-c].CDept, dbo.[D3-u].CSalary)) TC
FROM dbo.[D2-c] JOIN
dbo.[D3-u] ON dbo.[D2-c].Name = dbo.
[D3-u].Name
UNION
SEL
ECT dbo.[D2-c].name, dbo.[GetCLabel](dbo.[D2-c].CName)
CName, dbo.[D2-c].Department, dbo.[GetCLabel](dbo.
[D2-c].CDept) CDept, dbo.[D3-c].Salary,
dbo.[GetCLabel](dbo.[D3-c].CSalary)
CSalary, dbo.[GetCLabel]([dbo].
[GetTCLabel](4, dbo.[D2-c].CName, dbo.
[D2-c].CDept, dbo.[D3-c].CSalary)) TC
FROM dbo.[D2-c] JOIN
dbo.[D3-c] ON dbo.[D2-c].Name = dbo.
[D3-c].Name
UNION
SEL
ECT dbo.[D2-c].name, dbo.[GetCLabel](dbo.[D2-c].CName)
CName, dbo.[D2-c].Department, dbo.[GetCLabel]
(dbo.[D2-c].CDept) CDept, dbo.[D3-s].Salary,
dbo.[GetCLabel](dbo.[D3-s].CSalary)
CSalary, dbo.[GetCLabel]([dbo].
18 2 Securit y f o r Rel ati o n a l Data ba se s
UNION
SEL ECT dbo.[D2-s].name, dbo.[GetCLabel](dbo.[D2-s].CName)
CName, dbo.[D2-s].Department, dbo.[GetCLabel](dbo.
[D2-s].CDept) CDept, dbo.[D3-ts].Salary,
dbo.[GetCLabel](dbo.[D3-ts].CSalary)
CSalary, dbo.[GetCLabel]([dbo].
[GetTCLabel](4, dbo.[D2-s].CName, dbo.
[D2-s].CDept, dbo.[D3-ts].CSalary)) TC
FROM dbo.[D2-s] JOIN
dbo.[D3-ts] ON dbo.[D2-s].Name = dbo.
[D3-ts].Name
UNION
SEL ECT dbo.[D2-ts].name, dbo.[GetCLabel](dbo.[D2-ts].CName)
CName, dbo.[D2-ts].Department, dbo.[GetCLabel](dbo.
[D2-ts].CDept) CDept, dbo.[D3-u].Salary,
dbo.[GetCLabel](dbo.[D3-u].CSalary)
CSalary, dbo.[GetCLabel]([dbo].
[GetTCLabel](4, dbo.[D2-ts].CName, dbo.
[D2-ts].CDept, dbo.[D3-u].CSalary)) TC
FROM dbo.[D2-ts] JOIN
dbo.[D3-u] ON dbo.[D2-ts].Name = dbo.
[D3-u].Name
UNION
SEL ECT dbo.[D2-ts].name, dbo.[GetCLabel](dbo.[D2-ts].CName)
CName, dbo.[D2-ts].Department, dbo.[GetCLabel](dbo.
[D2-ts].CDept) CDept, dbo.[D3-c].Salary,
dbo.[GetCLabel](dbo.[D3-c].CSalary)
CSalary, dbo.[GetCLabel]([dbo].
[GetTCLabel](4, dbo.[D2-ts].CName, dbo.
[D2-ts].CDept, dbo.[D3-c].CSalary)) TC
FROM dbo.[D2-ts] JOIN
dbo.[D3-c] ON dbo.[D2-ts].Name = dbo.
[D3-c].Name
UNION
SEL
ECT dbo.[D2-ts].name, dbo.[GetCLabel](dbo.[D2-ts].CName)
CName, dbo.[D2-ts].Department, dbo.[GetCLabel](dbo.
[D2-ts].CDept) CDept, dbo.[D3-s].Salary,
dbo.[GetCLabel](dbo.[D3-s].CSalary) CSalary,
dbo.[GetCLabel]([dbo].[GetTCLabel](4, dbo.
[D2-ts].CName, dbo.[D2-ts].CDept, dbo.
[D3-s].CSalary)) TC
FROM dbo.[D2-ts] JOIN
dbo.[D3-s] ON dbo.[D2-ts].Name = dbo.
[D3-s].Name
18 4 Securit y f o r Rel ati o n a l Data ba se s
UNION
SEL ECT dbo.[D2-ts].name, dbo.[GetCLabel](dbo.[D2-ts].CName)
CName, dbo.[D2-ts].Department, dbo.[GetCLabel](dbo.
[D2-ts].CDept) CDept, dbo.[D3-ts].Salary,
dbo.[GetCLabel](dbo.[D3-ts].CSalary)
CSalary, dbo.[GetCLabel]([dbo].
[GetTCLabel](4, dbo.[D2-ts].CName, dbo.
[D2-ts].CDept, dbo.[D3-ts].CSalary)) TC
FROM dbo.[D2-ts] JOIN
dbo.[D3-ts] ON dbo.[D2-ts].Name = dbo.
[D3-ts].Name
GO
CREATE VIEW [dbo].[JSEmployee]
AS
SEL
ECT name, dbo.[GetCLabel](CName) CName, Department,
dbo.[GetCLabel](CDept) CDept, Salary,
dbo.[GetCLabel](CSalary) CSalary, dbo.
[GetCLabel]([dbo].[GetTCLabel](4,
CName, CDept, CSalary)) TC
FROM dbo.Du
UNION
SEL
ECT name, dbo.[GetCLabel](CName) CName, Department,
dbo.[GetCLabel](CDept) CDept, Salary,
dbo.[GetCLabel](CSalary) CSalary, dbo.
[GetCLabel]([dbo].[GetTCLabel]
(4, CName, CDept, CSalary)) TC
FROM dbo.Dc
UNION
SEL
ECT name, dbo.[GetCLabel](CName) CName, Department,
dbo.[GetCLabel](CDept) CDept, Salary,
dbo.[GetCLabel](CSalary) CSalary, dbo.
[GetCLabel]([dbo].[GetTCLabel](4,
CName, CDept, CSalary)) TC
FROM dbo.Ds
UNION
SEL
ECT name, dbo.[GetCLabel](CName) CName, Department,
dbo.[GetCLabel](CDept) CDept, Salary,
dbo.[GetCLabel](CSalary) CSalary, dbo.
[GetCLabel]([dbo].[GetTCLabel](4,
CName, CDept, CSalary)) TC
FROM dbo.Dts
GO
CREATE VIEW [dbo].[VwEmployee-Encryption]
T he S o ur c e C o d e 18 5
AS
SEL ECT CONVERT(nvarchar(MAX), DecryptByKey(dbo.
[Employee-Encryption].Name)) AS Name,
CONVERT(nvarchar(MAX), DecryptByKey(dbo.[Employee-
Encryption].Department)) AS Department,
CONVERT(nvarchar(MAX), DecryptByKey(dbo.
[Employee-Encryption].Salary)) AS
Salary, dbo.[Employee-Encryption].TC
FROM dbo.[Employee-Encryption] INNER JOIN
dbo.vwVisibleLabels ON dbo.[Employee-
Encryption].TC = dbo.vwVisibleLabels.ID
The source code of the Microsoft visual studio C# will be divided into
five parts:
• Create classes that help the window forms in performing the
database operations and parsing the SQL query statement.
• Create login form to authenticate the user and to identify his
security classification level.
• Create queries form to generate multiple query forms inside
at the same session.
• Create query form to be used in writing the SQL query state-
ment for each model from the multilevel database security
models.
• Create concurrency control form to be used in simulating
the concurrency control in the multilevel database security
models.
• DBOperations class
using System;
using System.Data;
using System.Data.SqlClient;
///<summary>
///Summary description for Class1
///</summary>
18 6 Securit y f o r Rel ati o n a l Data ba se s
namespace GlobalClasses
{
public class DBOperations
{
public DBOperations()
{
}
//
//Date:6/4/2008
//purpose:to Check user name and password of user
public static void SqlConn(string Server, string
User, string Pass) {globals.ServerConnStr
= “Data Source = “ + Server + “;Initial
Catalog = MLSDB;User Id = “ + User +
“;Password = “ + Pass + “;”;}
//
//Date:25/10/2008
//p
urpose:to get data from database by excuting SQL
satment.
public static DataSet GetData(string SqlStr)
{
DataSet ds = new DataSet();
string SqlConnStr = globals.ServerConnStr;
Sql
Connection SqlConn = new
SqlConnection(SqlConnStr);
SqlConn.Open();
SqlCommand SqlCmd = new SqlCommand(SqlStr,
SqlConn);
SqlDataAdapter Adpt = new SqlDataAdapter(SqlCmd);
Adpt.Fill(ds);
SqlConn.Close();
return ds;
}
//
//Date:21/7/2009
//p
urpose:to fill data table in dataset by excuting
SQL statement.
public static void FillDataSet(ref DataSet DS,
string DT, string SqlStr)
{
string SqlConnStr = globals.ServerConnStr;
SqlConnection SqlConn = new
SqlConnection(SqlConnStr);
SqlConn.Open();
T he S o ur c e C o d e 18 7
• Globals class
using System;
using System.Configuration ;
using System.Collections ;
18 8 Securit y f o r Rel ati o n a l Data ba se s
using System.IO;
using GlobalClasses;
///Summary description for Class1
///</summary>
namespace GlobalClasses
{
public class globals
{
public static string ServerName;
public static string Password;
public static string UserName;
public static string ServerConnStr;
public static string UserLabel;
public static int UserLabelID;
public static string Scrub(string text)
{return text.Replace(“ ”, “”);}
pub
lic static string[] KeyWords = new
string[8];//”select”, “insert”,
“update”,”Delete”, “Where”, “from”, “Set”,
“Values”
public enum SqlStatment
{
select,
Insert,
update,
Delete
}
}
}
• MLSDB class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace GlobalClasses
{
public class MLSDB
{
public static string DMLSTR(String SQLSTR)
{
T he S o ur c e C o d e 18 9
ToUpper().IndexOf(“WHERE”) - (SQLSTR.
ToUpper().IndexOf(“TRUE”) + 4));
}
else if(SQLSTR.ToUpper().
Contains(“FALSE”))
{
DML= SQLSTR.Substring(SQLSTR.ToUpper().
IndexOf(“FALSE”) + 5, SQLSTR.
ToUpper().IndexOf(“WHERE”) - (SQLSTR.
ToUpper().IndexOf(“FALSE”) + 5));
}
}
else if (SQLSTR.ToUpper().Contains(“DELETE”))
{
if (SQLSTR.ToUpper().Contains(“WHERE”))
{
DML= SQLSTR.Substring(SQLSTR.ToUpper().
IndexOf(“FROM”) + 4, SQLSTR.
ToUpper().IndexOf(“WHERE”) - (SQLSTR.
ToUpper().IndexOf(“FROM”) + 4));
}
else
{
DML= SQLSTR.Substring(SQLSTR.
ToUpper().IndexOf(“FROM”) + 4);
}
}
return DML;
}
pub
lic static string AttributeSTR(String
SQLSTR)
{
string DML = “”;
if (SQLSTR.ToUpper().Contains(“SELECT”))
{
DML= SQLSTR.Substring(SQLSTR.
ToUpper().IndexOf(“SELECT”) + 6,
SQLSTR.ToUpper().IndexOf(“FROM”)
- (SQLSTR.ToUpper().
IndexOf(“SELECT”) + 6));
}
else if (SQLSTR.ToUpper().Contains(“UPDATE”))
{
if (SQLSTR.ToUpper().
Contains(“WHERE”))
T he S o ur c e C o d e 191
{
DML= SQLSTR.Substring(SQLSTR.ToUpper().
IndexOf(“SET”) + 3, SQLSTR.ToUpper().
IndexOf(“WHERE”) - (SQLSTR.ToUpper().
IndexOf(“SET”) + 3));
}
else
{
DML= SQLSTR.Substring(SQLSTR.
ToUpper().IndexOf(“SET”) + 3);
}
}
els
e if (SQLSTR.ToUpper().
Contains(“UPLEVEL”))
{
if (SQLSTR.ToUpper().Contains(“WHERE”))
{
DML= SQLSTR.Substring(SQLSTR.ToUpper().
IndexOf(“GET”) + 3, SQLSTR.ToUpper().
IndexOf(“WHERE”) - (SQLSTR.ToUpper().
IndexOf(“GET”) + 3));
}
else
{
DML= SQLSTR.Substring(SQLSTR.
ToUpper().IndexOf(“SET”) + 3);
}
}
else if (SQLSTR.ToUpper().Contains(“VERIFY”))
{
if (SQLSTR.ToUpper().Contains(“TRUE”))
{
DML = “TRUE”;
}
else
{
DML = “FALSE”;
}
}
else if (SQLSTR.ToUpper().Contains(“INSERT”))
{
DML= SQLSTR.Substring(SQLSTR.
ToUpper().IndexOf(“VALUES”) + 6);
}
else if (SQLSTR.ToUpper().Contains(“DELETE”))
19 2 Securit y f o r Rel ati o n a l Data ba se s
{
if (SQLSTR.ToUpper().Contains(“WHERE”))
{
DML= SQLSTR.Substring(SQLSTR.
ToUpper().IndexOf(“WHERE”) + 5);
}
else
{
DML = “”;
}
}
return DML;
}
public static string PredicateSTR(String SQLSTR)
{
string DML = “”;
if (SQLSTR.ToUpper().Contains(“WHERE”))
{
DML= SQLSTR.Substring(SQLSTR.
ToUpper().IndexOf(“WHERE”) + 5);
}
else
{
DML = “”;
}
return DML;
}
public static int GetUserLabelID()
{
int UserLabel = 0;
str
ing SqlStr = “select [dbo].
GetLabelID([dbo].[GetUserLabel]()) “;
Use
rLabel = int.Parse(DBOperations.
GetData(SqlStr).Tables 0].Rows[0][0].
ToString());
return UserLabel;
}
public static string GetUserLabel()
{
string UserLabel = “”;
string SqlStr = “select [dbo].[GetUserLabel]() “;
Use
rLabel = DBOperations.GetData(SqlStr).
Tables 0].Rows[0][0].ToString();
return UserLabel;
}
T he S o ur c e C o d e 19 3
{
UserLabel = UserLabel + “S”;
}
if (TSChar = = “1”)
{
UserLabel = UserLabel + “-T”;
}
else if (TSChar = = “2”)
{
UserLabel = UserLabel + “T”;
}
return UserLabel;
}
pub
lic static int GetBCLabelNumeric(string
UserLabel)
{
int UserLabelID = 0 ;
UserLabel = BreakBCLabel(UserLabel);
Use
rLabelID = int.Parse(UserLabel.Substring
(0, 1)) + (int.Parse(UserLabel.Substring
(1, 1)) * 4) + (int.Parse(UserLabel.
Substring(2, 1)) * 16) + (int.
Parse(UserLabel.Substring(3, 1)) * 64);
return UserLabelID;
}
public static string GetBCUserView(string Label)
{
string labelView = “”;
int NumericLabel = 0;
Label = BreakBCLabel(Label);
int UserLabelID = globals.UserLabelID ;
for (int i = 0; i < UserLabelID; i++)
{
Num
ericLabel = NumericLabel +
(int.Parse(Label.Substring(i, 1)) *
Convert.ToInt32 (Math.Pow(4, i)));
}
labelView = GetBCLabel(NumericLabel);
return labelView;
}
pub
lic static string BreakBCLabel(string
UserLabel)
{
string UserLabelID = “0”;
string Unumric = “0”;
T he S o ur c e C o d e 19 5
{
Snumric = “2”;
}
else
{
if (UserLabel.Substring(UserLabel.
IndexOf(‘S’) - 1, 1) = = “-”)
{
Snumric = “1”;
}
else
{
Snumric = “2”;
}
}
}
if (UserLabel.Contains(‘T’))
{
if (UserLabel.IndexOf(‘T’) = = 0)
{
TSnumric = “2”;
}
else
{
if (UserLabel.Substring
(UserLabel.IndexOf(‘T’) - 1, 1)
= = “-”)
{
TSnumric = “1”;
}
else
{
TSnumric = “2”;
}
}
}
Use
rLabelID = Unumric + Cnumric + Snumric +
TSnumric;
return UserLabelID;
}
pub
lic static string GetBCprimarylevel
(int NumericLabel)
{
string Label = GetBCLabel(NumericLabel);
T he S o ur c e C o d e 19 7
this.SuspendLayout();
//
//label1
//
this.label1.AutoSize = true;
thi
s.label1.Location = new System.Drawing.
Point(26, 28);
this.label1.Name = “label1”;
this.label1.Size = new System.Drawing.Size(69, 13);
this.label1.TabIndex = 0;
this.label1.Text = “Server Name”;
thi
s.label1.Click + = new System.
EventHandler(this.label1_Click);
//
//TxtServer
//
thi
s.TxtServer.Location = new System.Drawing.
Point(101, 25);
this.TxtServer.Name = “TxtServer”;
thi
s.TxtServer.Size = new System.Drawing.
Size(154, 20);
this.TxtServer.TabIndex = 1;
//
//TxtUser
//
thi
s.TxtUser.Location = new System.Drawing.
Point(101, 50);
this.TxtUser.Name = “TxtUser”;
thi
s.TxtUser.Size = new System.Drawing.
Size(154, 20);
this.TxtUser.TabIndex = 3;
//
//label2
//
this.label2.AutoSize = true;
thi
s.label2.Location = new System.Drawing.
Point(38, 53);
this.label2.Name = “label2”;
thi
s.label2.Size = new System.Drawing.
Size(59, 13);
this.label2.TabIndex = 2;
this.label2.Text = “User Name”;
//
//TxtPassword
//
T he S o ur c e C o d e 2 01
thi
s.TxtPassword.Location = new System.
Drawing.Point(101, 75);
this.TxtPassword.Name = “TxtPassword”;
this.TxtPassword.PasswordChar = ‘*’;
thi
s.TxtPassword.Size = new System.Drawing.
Size(154, 20);
this.TxtPassword.TabIndex = 5;
//
//label3
//
this.label3.AutoSize = true;
thi
s.label3.Location = new System.Drawing.
Point(38, 78);
this.label3.Name = “label3”;
thi
s.label3.Size = new System.Drawing.
Size(53, 13);
this.label3.TabIndex = 4;
this.label3.Text = “Password”;
//
//button1
//
thi
s.button1.Location = new System.Drawing.
Point(101, 118);
this.button1.Name = “button1”;
thi
s.button1.Size = new System.Drawing.
Size(75, 23);
this.button1.TabIndex = 6;
this.button1.Text = “Connect”;
this.button1.UseVisualStyleBackColor = true;
thi
s.button1.Click + = new System.
EventHandler(this.button1_Click);
//
//button2
//
thi
s.button2.Location = new System.Drawing.
Point(180, 118);
this.button2.Name = “button2”;
thi
s.button2.Size = new System.Drawing.
Size(75, 23);
this.button2.TabIndex = 7;
this.button2.Text = “button2”;
this.button2.UseVisualStyleBackColor = true;
this.button2.Visible = false;
thi
s.button2.Click + = new System.
EventHandler(this.button2_Click);
202 Securit y f o r Rel ati o n a l Data ba se s
//
//Log_In
//
this.AcceptButton = this.button1;
thi
s.AutoScaleDimensions = new System.Drawing.
SizeF(6F, 13F);
thi
s.AutoScaleMode = System.Windows.Forms.
AutoScaleMode.Font;
thi
s.ClientSize = new System.Drawing.
Size(292, 153);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.TxtPassword);
this.Controls.Add(this.label3);
this.Controls.Add(this.TxtUser);
this.Controls.Add(this.label2);
this.Controls.Add(this.TxtServer);
this.Controls.Add(this.label1);
thi
s.FormBorderStyle = System.Windows.Forms.
FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = “Log_In”;
thi
s.StartPosition = System.Windows.Forms.
FormStartPosition.CenterScreen;
this.Text = “Log In”;
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox TxtServer;
private System.Windows.Forms.TextBox TxtUser;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox TxtPassword;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
T he S o ur c e C o d e 203
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MLS
{
public partial class Log_In : Form
{
public Log_In()
{
InitializeComponent();
}
pri
vate void label1_Click(object sender,
EventArgs e)
{
}
pri
vate void button1_Click(object sender,
EventArgs e)
{
Glo
balClasses.globals.ServerName = TxtServer.
Text;
GlobalClasses.globals.UserName = TxtUser.Text;
Glo
balClasses.globals.Password = TxtPassword.
Text;
GlobalClasses.DBOperations.SqlConn(TxtServer.
Text, TxtUser.Text, TxtPassword.Text);
try
{
SqlConnection SqlConn = new
SqlConnection(GlobalClasses.
globals.ServerConnStr);
SqlConn.Open();
SqlConn.Close();
Query FRM = new Query();
FRM.Show();
GlobalClasses.globals.UserLabelID
= GlobalClasses.MLSDB.
GetUserLabelID();
GlobalClasses.globals.UserLabel
= GlobalClasses.MLSDB.
GetUserLabel();
204 Securit y f o r Rel ati o n a l Data ba se s
this.Hide();
}
catch (SqlException sqlEX)
{
MessageBox.Show(sqlEX.Message);
}
}
pri
vate void button2_Click(object sender,
EventArgs e)
{
DataSet ds = new DataSet();
str
ing SqlConnStr = “Data Source =.;Initial
Catalog = test;Integrated Security = SSPI;”;
Sql
Connection SqlConn = new
SqlConnection(SqlConnStr);
SqlConn.Open();
string SqlStr = “select * from Table 1”;
Sql
Command SqlCmd = new SqlCommand(SqlStr,
SqlConn);
SqlDataAdapter Adpt = new SqlDataAdapter(SqlCmd);
Adpt.Fill(ds);
SqlConn.Close();
for (int i = 1; i < = 5; i++)
{
foreach (DataRow DBrow in
ds.Tables 0].Rows)
{
str
ing SqlConnStr1 = “Data Source =.;
Initial Catalog = “ + DBrow[0].
ToString() + “;Integrated Security
= SSPI;”;
SqlConnection mSqlConnection1 = new
SqlConnection(SqlConnStr1);
//the primary key column resides at
index 4
string str1 = “insert into [“ +
DBrow[1].ToString() + “] select *
from
[“ + DBrow[1].ToString() + “]”;
mSqlConnection1.Open();
SqlCommand mSqlCommand1 = new
SqlCommand(str1,
mSqlConnection1);
mSqlCommand1.CommandTimeout = 200;
mSqlCommand1.ExecuteNonQuery();
T he S o ur c e C o d e 205
mSqlConnection1.Close();
}
}
}
pub
lic void dropprimaryKey(string tableName,
string cnnString)
{
SqlDataReader mReader;
Sql
Connection mSqlConnection = new
SqlConnection();
SqlCommand mSqlCommand = new SqlCommand();
string cnString = cnnString;
mSqlConnection = new SqlConnection(cnString);
mSqlConnection.Open();
//s
p_pkeys is SQL Server default stored
procedure
//you pass it only table Name, it will return
//primary key column
mSq
lCommand = new SqlCommand(“sp_pkeys”,
mSqlConnection);
mSq
lCommand.CommandType = CommandType.
StoredProcedure;
mSqlCommand.Parameters.Add(“@table_name”,
SqlDbType.NVarChar).Value = tableName;
mReader = mSqlCommand.ExecuteReader();
while (mReader.Read())
{
try
{
Sql
Connection mSqlConnection1 = new
SqlConnection(cnnString);
//t
he primary key column resides at
index 4
str
ing str1 = “ALTER TABLE [“ +
tableName + “] DROP CONSTRAINT
[“ + mReader[5].ToString() + “]”;
mSqlConnection1.Open();
Sql
Command mSqlCommand1 = new
SqlCommand(str1, mSqlConnection1);
mSqlCommand1.ExecuteNonQuery();
mSqlConnection1.Close();
}
206 Securit y f o r Rel ati o n a l Data ba se s
catch {}
}
}
}
}
thi
s.menuStrip = new System.Windows.Forms.
MenuStrip();
thi
s.fileMenu = new System.Windows.Forms.
ToolStripMenuItem();
thi
s.newToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.openToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.toolStripSeparator3 = new System.Windows.
Forms.ToolStripSeparator();
thi
s.saveToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.saveAsToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.toolStripSeparator4 = new System.Windows.
Forms.ToolStripSeparator();
thi
s.printToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.printPreviewToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
thi
s.printSetupToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.toolStripSeparator5 = new System.Windows.
Forms.ToolStripSeparator();
thi
s.exitToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.editMenu = new System.Windows.Forms.
ToolStripMenuItem();
thi
s.undoToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.redoToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.toolStripSeparator6 = new System.Windows.
Forms.ToolStripSeparator();
thi
s.cutToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.copyToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.pasteToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.toolStripSeparator7 = new System.Windows.
Forms.ToolStripSeparator();
thi
s.selectAllToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
208 Securit y f o r Rel ati o n a l Data ba se s
thi
s.viewMenu = new System.Windows.Forms.
ToolStripMenuItem();
thi
s.toolBarToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.statusBarToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.toolsMenu = new System.Windows.Forms.
ToolStripMenuItem();
thi
s.optionsToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.windowsMenu = new System.Windows.Forms.
ToolStripMenuItem();
thi
s.newWindowToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.cascadeToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.tileVerticalToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
thi
s.tileHorizontalToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
thi
s.closeAllToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.arrangeIconsToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
thi
s.helpMenu = new System.Windows.Forms.
ToolStripMenuItem();
thi
s.contentsToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.indexToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.searchToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.toolStripSeparator8 = new System.Windows.
Forms.ToolStripSeparator();
thi
s.aboutToolStripMenuItem = new System.
Windows.Forms.ToolStripMenuItem();
thi
s.statusStrip = new System.Windows.Forms.
StatusStrip();
thi
s.toolStripStatusLabel = new System.
Windows.Forms.ToolStripStatusLabel();
thi
s.toolTip = new System.Windows.Forms.
ToolTip(this.components);
thi
s.newToolStripButton = new System.Windows.
Forms.ToolStripButton();
T he S o ur c e C o d e 209
thi
s.openToolStripButton = new System.Windows.
Forms.ToolStripButton();
thi
s.saveToolStripButton = new System.Windows.
Forms.ToolStripButton();
thi
s.toolStripSeparator1 = new System.Windows.
Forms.ToolStripSeparator();
thi
s.printToolStripButton = new System.
Windows.Forms.ToolStripButton();
thi
s.printPreviewToolStripButton = new System.
Windows.Forms.ToolStripButton();
thi
s.toolStripSeparator2 = new System.Windows.
Forms.ToolStripSeparator();
thi
s.helpToolStripButton = new System.Windows.
Forms.ToolStripButton();
thi
s.toolStrip = new System.Windows.Forms.
ToolStrip();
this.menuStrip.SuspendLayout();
this.statusStrip.SuspendLayout();
this.toolStrip.SuspendLayout();
this.SuspendLayout();
//
//menuStrip
//
this.menuStrip.Items.AddRange(new System.
Windows.Forms.ToolStripItem[] {
this.fileMenu,
this.editMenu,
this.viewMenu,
this.toolsMenu,
this.windowsMenu,
this.helpMenu});
thi
s.menuStrip.Location = new System.Drawing.
Point(0, 0);
thi
s.menuStrip.MdiWindowListItem = this.
windowsMenu;
this.menuStrip.Name = “menuStrip”;
thi
s.menuStrip.Size = new System.Drawing.
Size(632, 24);
this.menuStrip.TabIndex = 0;
this.menuStrip.Text = “MenuStrip”;
this.menuStrip.Visible = false;
//
//fileMenu
//
210 Securit y f o r Rel ati o n a l Data ba se s
this.fileMenu.DropDownItems.AddRange(new
System.Windows.Forms.ToolStripItem[] {
this.newToolStripMenuItem,
this.openToolStripMenuItem,
this.toolStripSeparator3,
this.saveToolStripMenuItem,
this.saveAsToolStripMenuItem,
this.toolStripSeparator4,
this.printToolStripMenuItem,
this.printPreviewToolStripMenuItem,
this.printSetupToolStripMenuItem,
this.toolStripSeparator5,
this.exitToolStripMenuItem});
thi
s.fileMenu.ImageTransparentColor = System.
Drawing.SystemColors.ActiveBorder;
this.fileMenu.Name = “fileMenu”;
thi
s.fileMenu.Size = new System.Drawing.
Size(37, 20);
this.fileMenu.Text = “&File”;
//
//newToolStripMenuItem
//
thi
s.newToolStripMenuItem.Image = ((System.
Drawing.Image)(resources.
GetObject(“newToolStripMenuItem.Image”)));
this.newToolStripMenuItem.
ImageTransparentColor = System.Drawing.
Color.Black;
this.newToolStripMenuItem.Name =
“newToolStripMenuItem”;
this.newToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.
Windows.Forms.Keys.Control | System.
Windows.Forms.Keys.N)));
thi
s.newToolStripMenuItem.Size = new System.
Drawing.Size(146, 22);
this.newToolStripMenuItem.Text = “&New”;
thi
s.newToolStripMenuItem.Click + = new
System.EventHandler(this.ShowNewForm);
//
//openToolStripMenuItem
//
thi
s.openToolStripMenuItem.Image = ((System.
Drawing.Image)(resources.GetObject(“openToo
lStripMenuItem.Image”)));
T he S o ur c e C o d e 211
this.openToolStripMenuItem.
ImageTransparentColor = System.Drawing.
Color.Black;
this.openToolStripMenuItem.Name =
“openToolStripMenuItem”;
this.openToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.
Windows.Forms.Keys.Control | System.
Windows.Forms.Keys.O)));
thi
s.openToolStripMenuItem.Size = new System.
Drawing.Size(146, 22);
this.openToolStripMenuItem.Text = “&Open”;
thi
s.openToolStripMenuItem.Click + = new
System.EventHandler(this.OpenFile);
//
//toolStripSeparator3
//
this.toolStripSeparator3.Name =
“toolStripSeparator3”;
thi
s.toolStripSeparator3.Size = new System.
Drawing.Size(143, 6);
//
//saveToolStripMenuItem
//
thi
s.saveToolStripMenuItem.Image = ((System.
Drawing.Image)(resources.GetObject(“saveToo
lStripMenuItem.Image”)));
this.saveToolStripMenuItem.
ImageTransparentColor = System.Drawing.
Color.Black;
this.saveToolStripMenuItem.Name =
“saveToolStripMenuItem”;
this.saveToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.
Windows.Forms.Keys.Control | System.
Windows.Forms.Keys.S)));
thi
s.saveToolStripMenuItem.Size = new System.
Drawing.Size(146, 22);
this.saveToolStripMenuItem.Text = “&Save”;
//
//saveAsToolStripMenuItem
//
this.saveAsToolStripMenuItem.Name =
“saveAsToolStripMenuItem”;
212 Securit y f o r Rel ati o n a l Data ba se s
thi
s.saveAsToolStripMenuItem.Size = new
System.Drawing.Size(146, 22);
thi
s.saveAsToolStripMenuItem.Text = “Save
&As”;
thi
s.saveAsToolStripMenuItem.Click + = new
System.EventHandler(this.
SaveAsToolStripMenuItem_Click);
//
//toolStripSeparator4
//
this.toolStripSeparator4.Name =
“toolStripSeparator4”;
thi
s.toolStripSeparator4.Size = new System.
Drawing.Size(143, 6);
//
//printToolStripMenuItem
//
thi
s.printToolStripMenuItem.Image = ((System.
Drawing.Image)(resources.GetObject(“printTo
olStripMenuItem.Image”)));
this.printToolStripMenuItem.
ImageTransparentColor = System.Drawing.
Color.Black;
this.printToolStripMenuItem.Name =
“printToolStripMenuItem”;
this.printToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.
Windows.Forms.Keys.Control |
System.Windows.Forms.Keys.P)));
thi
s.printToolStripMenuItem.Size = new System.
Drawing.Size(146, 22);
this.printToolStripMenuItem.Text = “&Print”;
//
//printPreviewToolStripMenuItem
//
this.printPreviewToolStripMenuItem.Image =
((System.Drawing.Image)(resources.GetObject
(“printPreviewToolStripMenuItem.Image”)));
this.printPreviewToolStripMenuItem.
ImageTransparentColor = System.Drawing.
Color.Black;
this.printPreviewToolStripMenuItem.Name =
“printPreviewToolStripMenuItem”;
T he S o ur c e C o d e 213
thi
s.printPreviewToolStripMenuItem.Size = new
System.Drawing.Size(146, 22);
this.printPreviewToolStripMenuItem.Text =
“Print Pre&view”;
//
//printSetupToolStripMenuItem
//
this.printSetupToolStripMenuItem.Name =
“printSetupToolStripMenuItem”;
thi
s.printSetupToolStripMenuItem.Size = new
System.Drawing.Size(146, 22);
thi
s.printSetupToolStripMenuItem.Text = “Print
Setup”;
//
//toolStripSeparator5
//
this.toolStripSeparator5.Name =
“toolStripSeparator5”;
thi
s.toolStripSeparator5.Size = new System.
Drawing.Size(143, 6);
//
//exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name =
“exitToolStripMenuItem”;
thi
s.exitToolStripMenuItem.Size = new System.
Drawing.Size(146, 22);
this.exitToolStripMenuItem.Text = “E&xit”;
thi
s.exitToolStripMenuItem.Click + = new
System.EventHandler(this.
ExitToolsStripMenuItem_Click);
//
//editMenu
//
this.editMenu.DropDownItems.AddRange(new
System.Windows.Forms.ToolStripItem[] {
this.undoToolStripMenuItem,
this.redoToolStripMenuItem,
this.toolStripSeparator6,
this.cutToolStripMenuItem,
this.copyToolStripMenuItem,
this.pasteToolStripMenuItem,
this.toolStripSeparator7,
this.selectAllToolStripMenuItem});
214 Securit y f o r Rel ati o n a l Data ba se s
this.editMenu.Name = “editMenu”;
this.editMenu.Size = new System.Drawing.
Size(39, 20);
this.editMenu.Text = “&Edit”;
//
//undoToolStripMenuItem
//
this.undoToolStripMenuItem.Image = ((System.
Drawing.Image)(resources.GetObject(“undoToo
lStripMenuItem.Image”)));
this.undoToolStripMenuItem.ImageTransparentColor
= System.Drawing.Color.Black;
this.undoToolStripMenuItem.Name =
“undoToolStripMenuItem”;
this.undoToolStripMenuItem.ShortcutKeys
= ((System.Windows.Forms.Keys)((System.
Windows.Forms.Keys.Control | System.
Windows.Forms.Keys.Z)));
this.undoToolStripMenuItem.Size = new System.
Drawing.Size(164, 22);
this.undoToolStripMenuItem.Text = “&Undo”;
this.undoToolStripMenuItem.Click + = new
System.EventHandler(this.
undoToolStripMenuItem_Click);
//
//redoToolStripMenuItem
//
this.redoToolStripMenuItem.Image = ((System.
Drawing.Image)(resources.GetObject(“redoToo
lStripMenuItem.Image”)));
this.redoToolStripMenuItem.ImageTransparentColor
= System.Drawing.Color.Black;
this.redoToolStripMenuItem.Name =
“redoToolStripMenuItem”;
this.redoToolStripMenuItem.ShortcutKeys
= ((System.Windows.Forms.Keys)((System.
Windows.Forms.Keys.Control | System.
Windows.Forms.Keys.Y)));
this.redoToolStripMenuItem.Size = new System.
Drawing.Size(164, 22);
this.redoToolStripMenuItem.Text = “&Redo”;
//
//toolStripSeparator6
//
T he S o ur c e C o d e 215
this.toolStripSeparator6.Name =
“toolStripSeparator6”;
thi
s.toolStripSeparator6.Size = new System.
Drawing.Size(161, 6);
//
//cutToolStripMenuItem
//
thi
s.cutToolStripMenuItem.Image = ((System.
Drawing.Image)(resources.
GetObject(“cutToolStripMenuItem.Image”)));
this.cutToolStripMenuItem.
ImageTransparentColor = System.Drawing.
Color.Black;
this.cutToolStripMenuItem.Name =
“cutToolStripMenuItem”;
this.cutToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.
Windows.Forms.Keys.Control | System.
Windows.Forms.Keys.X)));
thi
s.cutToolStripMenuItem.Size = new System.
Drawing.Size(164, 22);
this.cutToolStripMenuItem.Text = “Cu&t”;
thi
s.cutToolStripMenuItem.Click + = new
System.EventHandler(this.
CutToolStripMenuItem_Click);
//
//copyToolStripMenuItem
//
thi
s.copyToolStripMenuItem.Image = ((System.
Drawing.Image)(resources.GetObject(“copyToo
lStripMenuItem.Image”)));
this.copyToolStripMenuItem.
ImageTransparentColor = System.Drawing.
Color.Black;
this.copyToolStripMenuItem.Name =
“copyToolStripMenuItem”;
this.copyToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.
Windows.Forms.Keys.Control |
System.Windows.Forms.Keys.C)));
thi
s.copyToolStripMenuItem.Size = new System.
Drawing.Size(164, 22);
this.copyToolStripMenuItem.Text = “&Copy”;
216 Securit y f o r Rel ati o n a l Data ba se s
thi
s.copyToolStripMenuItem.Click + = new
System.EventHandler(this.
CopyToolStripMenuItem_Click);
//
//pasteToolStripMenuItem
//
thi
s.pasteToolStripMenuItem.Image = ((System.
Drawing.Image)(resources.GetObject(“pasteTo
olStripMenuItem.Image”)));
this.pasteToolStripMenuItem.
ImageTransparentColor = System.Drawing.
Color.Black;
this.pasteToolStripMenuItem.Name =
“pasteToolStripMenuItem”;
this.pasteToolStripMenuItem.ShortcutKeys
= ((System.Windows.Forms.Keys)((System.
Windows.Forms.Keys.Control | System.
Windows.Forms.Keys.V)));
thi
s.pasteToolStripMenuItem.Size = new System.
Drawing.Size(164, 22);
this.pasteToolStripMenuItem.Text = “&Paste”;
thi
s.pasteToolStripMenuItem.Click + = new
System.EventHandler(this.
PasteToolStripMenuItem_Click);
//
//toolStripSeparator7
//
this.toolStripSeparator7.Name =
“toolStripSeparator7”;
thi
s.toolStripSeparator7.Size = new System.
Drawing.Size(161, 6);
//
//selectAllToolStripMenuItem
//
this.selectAllToolStripMenuItem.Name =
“selectAllToolStripMenuItem”;
this.selectAllToolStripMenuItem.ShortcutKeys
= ((System.Windows.Forms.Keys)((System.
Windows.Forms.Keys.Control | System.
Windows.Forms.Keys.A)));
thi
s.selectAllToolStripMenuItem.Size = new
System.Drawing.Size(164, 22);
thi
s.selectAllToolStripMenuItem.Text = “Select
&All”;
T he S o ur c e C o d e 217
//
//viewMenu
//
this.viewMenu.DropDownItems.AddRange(new
System.Windows.Forms.ToolStripItem[] {
this.toolBarToolStripMenuItem,
this.statusBarToolStripMenuItem});
this.viewMenu.Name = “viewMenu”;
thi
s.viewMenu.Size = new System.Drawing.
Size(44, 20);
this.viewMenu.Text = “&View”;
//
//toolBarToolStripMenuItem
//
this.toolBarToolStripMenuItem.Checked = true;
this.toolBarToolStripMenuItem.CheckOnClick
= true;
this.toolBarToolStripMenuItem.CheckState =
System.Windows.Forms.CheckState.Checked;
this.toolBarToolStripMenuItem.Name =
“toolBarToolStripMenuItem”;
thi
s.toolBarToolStripMenuItem.Size = new
System.Drawing.Size(126, 22);
this.toolBarToolStripMenuItem.Text =
“&Toolbar”;
thi
s.toolBarToolStripMenuItem.Click + = new
System.EventHandler(this.
ToolBarToolStripMenuItem_Click);
//
//statusBarToolStripMenuItem
//
this.statusBarToolStripMenuItem.Checked
= true;
this.statusBarToolStripMenuItem.CheckOnClick
= true;
this.statusBarToolStripMenuItem.CheckState =
System.Windows.Forms.CheckState.Checked;
this.statusBarToolStripMenuItem.Name =
“statusBarToolStripMenuItem”;
thi
s.statusBarToolStripMenuItem.Size = new
System.Drawing.Size(126, 22);
this.statusBarToolStripMenuItem.Text
= “&Status Bar”;
218 Securit y f o r Rel ati o n a l Data ba se s
thi
s.statusBarToolStripMenuItem.Click + = new
System.EventHandler(this.
StatusBarToolStripMenuItem_Click);
//
//toolsMenu
//
this.toolsMenu.DropDownItems.AddRange(new
System.Windows.Forms.ToolStripItem[] {
this.optionsToolStripMenuItem});
this.toolsMenu.Name = “toolsMenu”;
thi
s.toolsMenu.Size = new System.Drawing.
Size(48, 20);
this.toolsMenu.Text = “&Tools”;
//
//optionsToolStripMenuItem
//
this.optionsToolStripMenuItem.Name
= “optionsToolStripMenuItem”;
thi
s.optionsToolStripMenuItem.Size = new
System.Drawing.Size(116, 22);
this.optionsToolStripMenuItem.Text
= “&Options”;
//
//windowsMenu
//
this.windowsMenu.DropDownItems.AddRange
(new System.Windows.Forms.ToolStripItem[] {
this.newWindowToolStripMenuItem,
this.cascadeToolStripMenuItem,
this.tileVerticalToolStripMenuItem,
this.tileHorizontalToolStripMenuItem,
this.closeAllToolStripMenuItem,
this.arrangeIconsToolStripMenuItem});
this.windowsMenu.Name = “windowsMenu”;
thi
s.windowsMenu.Size = new System.Drawing.
Size(68, 20);
this.windowsMenu.Text = “&Windows”;
//
//newWindowToolStripMenuItem
//
this.newWindowToolStripMenuItem.Name =
“newWindowToolStripMenuItem”;
thi
s.newWindowToolStripMenuItem.Size = new
System.Drawing.Size(151, 22);
T he S o ur c e C o d e 219
this.newWindowToolStripMenuItem.Text = “&New
Window”;
this.newWindowToolStripMenuItem.Click + = new
System.EventHandler(this.ShowNewForm);
//
//cascadeToolStripMenuItem
//
this.cascadeToolStripMenuItem.Name =
“cascadeToolStripMenuItem”;
this.cascadeToolStripMenuItem.Size = new
System.Drawing.Size(151, 22);
this.cascadeToolStripMenuItem.Text =
“&Cascade”;
this.cascadeToolStripMenuItem.Click + = new
System.EventHandler(this.
CascadeToolStripMenuItem_Click);
//
//tileVerticalToolStripMenuItem
//
this.tileVerticalToolStripMenuItem.Name
= “tileVerticalToolStripMenuItem”;
this.tileVerticalToolStripMenuItem.Size = new
System.Drawing.Size(151, 22);
this.tileVerticalToolStripMenuItem.Text
= “Tile &Vertical”;
this.tileVerticalToolStripMenuItem.Click +
= new System.EventHandler(this.
TileVerticalToolStripMenuItem_Click);
//
//tileHorizontalToolStripMenuItem
//
this.tileHorizontalToolStripMenuItem.Name
= “tileHorizontalToolStripMenuItem”;
this.tileHorizontalToolStripMenuItem.Size
= new System.Drawing.Size(151, 22);
this.tileHorizontalToolStripMenuItem.Text
= “Tile &Horizontal”;
this.tileHorizontalToolStripMenuItem.Click +
= new System.EventHandler
(this.TileHorizontalToolStripMenuItem _ Click);
//
//closeAllToolStripMenuItem
//
220 Securit y f o r Rel ati o n a l Data ba se s
this.closeAllToolStripMenuItem.Name
= “closeAllToolStripMenuItem”;
thi
s.closeAllToolStripMenuItem.Size = new
System.Drawing.Size(151, 22);
thi
s.closeAllToolStripMenuItem.Text = “C&lose
All”;
thi
s.closeAllToolStripMenuItem.Click + = new
System.EventHandler(this.
CloseAllToolStripMenuItem_Click);
//
//arrangeIconsToolStripMenuItem
//
this.arrangeIconsToolStripMenuItem.Name
= “arrangeIconsToolStripMenuItem”;
thi
s.arrangeIconsToolStripMenuItem.Size = new
System.Drawing.Size(151, 22);
this.arrangeIconsToolStripMenuItem.Text
= “&Arrange Icons”;
this.arrangeIconsToolStripMenuItem.Click +
= new System.EventHandler(this.
ArrangeIconsToolStripMenuItem_Click);
//
//helpMenu
//
this.helpMenu.DropDownItems.AddRange
(new System.Windows.Forms.ToolStripItem[] {
this.contentsToolStripMenuItem,
this.indexToolStripMenuItem,
this.searchToolStripMenuItem,
this.toolStripSeparator8,
this.aboutToolStripMenuItem});
this.helpMenu.Name = “helpMenu”;
thi
s.helpMenu.Size = new System.Drawing.
Size(44, 20);
this.helpMenu.Text = “&Help”;
//
//contentsToolStripMenuItem
//
this.contentsToolStripMenuItem.Name =
“contentsToolStripMenuItem”;
this.contentsToolStripMenuItem.ShortcutKeys
= ((System.Windows.Forms.Keys)((System.
Windows.Forms.Keys.Control | System.
Windows.Forms.Keys.F1)));
T he S o ur c e C o d e 2 21
this.contentsToolStripMenuItem.Size = new
System.Drawing.Size(168, 22);
this.contentsToolStripMenuItem.Text = “&Contents”;
//
//indexToolStripMenuItem
//
this.indexToolStripMenuItem.Image = ((System.
Drawing.Image)(resources.GetObject(“indexTo
olStripMenuItem.Image”)));
this.indexToolStripMenuItem.ImageTransparentColor
= System.Drawing.Color.Black;
this.indexToolStripMenuItem.Name
= “indexToolStripMenuItem”;
this.indexToolStripMenuItem.Size = new System.
Drawing.Size(168, 22);
this.indexToolStripMenuItem.Text = “&Index”;
//
//searchToolStripMenuItem
//
this.searchToolStripMenuItem.Image = ((System.
Drawing.Image)(resources.GetObject(“searchT
oolStripMenuItem.Image”)));
this.searchToolStripMenuItem.
ImageTransparentColor = System.Drawing.
Color.Black;
this.searchToolStripMenuItem.Name =
“searchToolStripMenuItem”;
this.searchToolStripMenuItem.Size = new
System.Drawing.Size(168, 22);
this.searchToolStripMenuItem.Text = “&Search”;
//
//toolStripSeparator8
//
this.toolStripSeparator8.Name =
“toolStripSeparator8”;
this.toolStripSeparator8.Size = new System.
Drawing.Size(165, 6);
//
//aboutToolStripMenuItem
//
this.aboutToolStripMenuItem.Name =
“aboutToolStripMenuItem”;
this.aboutToolStripMenuItem.Size = new System.
Drawing.Size(168, 22);
222 Securit y f o r Rel ati o n a l Data ba se s
this.aboutToolStripMenuItem.Text
= “&About......”;
//
//statusStrip
//
this.statusStrip.Items.AddRange(new System.
Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel});
thi
s.statusStrip.Location = new System.
Drawing.Point(0, 430);
this.statusStrip.Name = “statusStrip”;
this.statusStrip.RightToLeft
= System.Windows.Forms.RightToLeft.Yes;
thi
s.statusStrip.Size = new System.Drawing.
Size(632, 23);
this.statusStrip.TabIndex = 2;
this.statusStrip.Text = “StatusStrip”;
//
//toolStripStatusLabel
//
thi
s.toolStripStatusLabel.Font = new System.
Drawing.Font(“Arial”, 12F, System.Drawing.
FontStyle.Italic);
this.toolStripStatusLabel.Name
= “toolStripStatusLabel”;
thi
s.toolStripStatusLabel.Size = new System.
Drawing.Size(52, 18);
this.toolStripStatusLabel.Text = “Status”;
//
//newToolStripButton
//
thi
s.newToolStripButton.Image = ((System.
Drawing.Image)(resources.
GetObject(“newToolStripButton.Image”)));
this.newToolStripButton.ImageTransparentColor
= System.Drawing.Color.Black;
this.newToolStripButton.Name
= “newToolStripButton”;
thi
s.newToolStripButton.Size = new System.
Drawing.Size(86, 22);
this.newToolStripButton.Text = “New Query”;
thi
s.newToolStripButton.Click + = new System.
EventHandler(this.ShowNewForm);
//
//openToolStripButton
T he S o ur c e C o d e 223
//
this.openToolStripButton.DisplayStyle
= System.Windows.Forms.
ToolStripItemDisplayStyle.Image;
thi
s.openToolStripButton.Image = ((System.
Drawing.Image)(resources.
GetObject(“openToolStripButton.Image”)));
this.openToolStripButton.ImageTransparentColor
= System.Drawing.Color.Black;
this.openToolStripButton.Name
= “openToolStripButton”;
thi
s.openToolStripButton.Size = new System.
Drawing.Size(23, 22);
this.openToolStripButton.Text = “Open”;
this.openToolStripButton.Visible = false;
thi
s.openToolStripButton.Click + = new System.
EventHandler(this.OpenFile);
//
//saveToolStripButton
//
this.saveToolStripButton.DisplayStyle
= System.Windows.Forms.
ToolStripItemDisplayStyle.Image;
thi
s.saveToolStripButton.Image = ((System.
Drawing.Image)(resources.
GetObject(“saveToolStripButton.Image”)));
this.saveToolStripButton.ImageTransparentColor
= System.Drawing.Color.Black;
this.saveToolStripButton.Name
= “saveToolStripButton”;
thi
s.saveToolStripButton.Size = new System.
Drawing.Size(23, 22);
this.saveToolStripButton.Text = “Save”;
this.saveToolStripButton.Visible = false;
thi
s.saveToolStripButton.Click + = new System.
EventHandler(this.saveToolStripButton _
Click);
//
//toolStripSeparator1
//
this.toolStripSeparator1.Name =
“toolStripSeparator1”;
thi
s.toolStripSeparator1.Size = new System.
Drawing.Size(6, 25);
//
224 Securit y f o r Rel ati o n a l Data ba se s
//printToolStripButton
//
thi
s.printToolStripButton.DisplayStyle = System.
Windows.Forms.ToolStripItemDisplayStyle.
Image;
thi
s.printToolStripButton.Image = ((System.
Drawing.Image)(resources.
GetObject(“printToolStripButton.Image”)));
this.printToolStripButton.
ImageTransparentColor = System.Drawing.
Color.Black;
this.printToolStripButton.Name
= “printToolStripButton”;
thi
s.printToolStripButton.Size = new System.
Drawing.Size(23, 22);
this.printToolStripButton.Text = “Print”;
this.printToolStripButton.Visible = false;
//
//printPreviewToolStripButton
//
this.printPreviewToolStripButton.DisplayStyle
= System.Windows.Forms.
ToolStripItemDisplayStyle.Image;
this.printPreviewToolStripButton.Image =
((System.Drawing.Image)(resources.GetObject
(“printPreviewToolStripButton.Image”)));
this.printPreviewToolStripButton.
ImageTransparentColor = System.Drawing.
Color.Black;
this.printPreviewToolStripButton.Name
= “printPreviewToolStripButton”;
thi
s.printPreviewToolStripButton.Size = new
System.Drawing.Size(23, 22);
thi
s.printPreviewToolStripButton.Text = “Print
Preview”;
this.printPreviewToolStripButton.Visible
= false;
//
//toolStripSeparator2
//
this.toolStripSeparator2.Name =
“toolStripSeparator2”;
thi
s.toolStripSeparator2.Size = new System.
Drawing.Size(6, 25);
T he S o ur c e C o d e 225
//
//helpToolStripButton
//
this.helpToolStripButton.DisplayStyle
= System.Windows.Forms.
ToolStripItemDisplayStyle.Image;
thi
s.helpToolStripButton.Image = ((System.
Drawing.Image)(resources.
GetObject(“helpToolStripButton.Image”)));
this.helpToolStripButton.ImageTransparentColor
= System.Drawing.Color.Black;
this.helpToolStripButton.Name
= “helpToolStripButton”;
thi
s.helpToolStripButton.Size = new System.
Drawing.Size(23, 22);
this.helpToolStripButton.Text = “Help”;
this.helpToolStripButton.Visible = false;
//
//toolStrip
//
this.toolStrip.Items.AddRange(new System.
Windows.Forms.ToolStripItem[] {
this.newToolStripButton,
this.openToolStripButton,
this.saveToolStripButton,
this.toolStripSeparator1,
this.toolStripSeparator2,
this.printToolStripButton,
this.printPreviewToolStripButton,
this.helpToolStripButton});
thi
s.toolStrip.Location = new System.Drawing.
Point(0, 0);
this.toolStrip.Name = “toolStrip”;
thi
s.toolStrip.Size = new System.Drawing.
Size(632, 25);
this.toolStrip.TabIndex = 1;
this.toolStrip.Text = “ToolStrip”;
//
//Query
//
thi
s.AutoScaleDimensions = new System.Drawing.
SizeF(6F, 13F);
thi
s.AutoScaleMode = System.Windows.Forms.
AutoScaleMode.Font;
226 Securit y f o r Rel ati o n a l Data ba se s
thi
s.ClientSize = new System.
Drawing.Size(632, 453);
this.Controls.Add(this.statusStrip);
this.Controls.Add(this.toolStrip);
this.Controls.Add(this.menuStrip);
this.IsMdiContainer = true;
this.MainMenuStrip = this.menuStrip;
this.Name = “Query”;
this.Text = “Query”;
thi
s.WindowState = System.Windows.Forms.
FormWindowState.Maximized;
thi
s.Load + = new System.EventHandler
(this.Query_Load);
thi
s.FormClosing + = new System.Windows.Forms.
FormClosingEventHandler(this.Query_
FormClosing);
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
this.statusStrip.ResumeLayout(false);
this.statusStrip.PerformLayout();
this.toolStrip.ResumeLayout(false);
this.toolStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip
menuStrip;
private System.Windows.Forms.StatusStrip
statusStrip;
private System.Windows.Forms.
ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.
ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.
ToolStripSeparator toolStripSeparator5;
private System.Windows.Forms.
ToolStripSeparator toolStripSeparator6;
private System.Windows.Forms.ToolStripMenuItem
printSetupToolStripMenuItem;
private System.Windows.Forms.
ToolStripSeparator toolStripSeparator7;
private System.Windows.Forms.
ToolStripSeparator toolStripSeparator8;
T he S o ur c e C o d e 227
private System.Windows.Forms.
ToolStripStatusLabel toolStripStatusLabel;
private System.Windows.Forms.ToolStripMenuItem
aboutToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
tileHorizontalToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
fileMenu;
private System.Windows.Forms.ToolStripMenuItem
newToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
openToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
saveToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
saveAsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
printToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
printPreviewToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
editMenu;
private System.Windows.Forms.ToolStripMenuItem
undoToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
redoToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
cutToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
copyToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
pasteToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
selectAllToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
viewMenu;
private System.Windows.Forms.ToolStripMenuItem
toolBarToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
statusBarToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
toolsMenu;
228 Securit y f o r Rel ati o n a l Data ba se s
private System.Windows.Forms.ToolStripMenuItem
optionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
windowsMenu;
private System.Windows.Forms.ToolStripMenuItem
newWindowToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
cascadeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
tileVerticalToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
closeAllToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
arrangeIconsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
helpMenu;
private System.Windows.Forms.ToolStripMenuItem
contentsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
indexToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
searchToolStripMenuItem;
private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.ToolStripButton
newToolStripButton;
private System.Windows.Forms.ToolStripButton
openToolStripButton;
private System.Windows.Forms.ToolStripButton
saveToolStripButton;
private System.Windows.Forms.
ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripButton
printToolStripButton;
private System.Windows.Forms.ToolStripButton
printPreviewToolStripButton;
private System.Windows.Forms.
ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripButton
helpToolStripButton;
private System.Windows.Forms.ToolStrip
toolStrip;
}
}
using System;
T he S o ur c e C o d e 229
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MLS
{
public partial class Query : Form
{
private int childFormNumber = 0;
public Query()
{
InitializeComponent();
}
pri
vate void ShowNewForm(object sender,
EventArgs e)
{
QueryForm childForm = new QueryForm();
childForm.MdiParent = this;
childForm.Dock = DockStyle.Fill;
chi
ldForm.Text = “SQL Query”
+ childFormNumber++;
childForm.Show();
}
pri
vate void OpenFile(object sender,
EventArgs e)
{
Ope
nFileDialog openFileDialog = new
OpenFileDialog();
ope
nFileDialog.InitialDirectory = Environment.
GetFolderPath(Environment.SpecialFolder.
Personal);
ope
nFileDialog.Filter = “Text Files (*.txt)|*.
txt|All Files (*.*)|*.*”;
if (
openFileDialog.ShowDialog(this) = =
DialogResult.OK)
{
str
ing FileName = openFileDialog.
FileName;
}
}
230 Securit y f o r Rel ati o n a l Data ba se s
statusStrip.Visible =
statusBarToolStripMenuItem.Checked;
}
pri
vate void CascadeToolStripMenuItem_
Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.Cascade);
}
pri
vate void TileVerticalToolStripMenuItem_
Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileVertical);
}
pri
vate void TileHorizontalToolStripMenuItem_
Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileHorizontal);
}
pri
vate void ArrangeIconsToolStripMenuItem_
Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.ArrangeIcons);
}
pri
vate void CloseAllToolStripMenuItem_
Click(object sender, EventArgs e)
{
foreach (Form childForm in MdiChildren)
{
childForm.Close();
}
}
pri
vate void undoToolStripMenuItem_
Click(object sender, EventArgs e)
{
}
pri
vate void Query_FormClosing(object sender,
FormClosingEventArgs e)
{
Application.Exit();
}
pri
vate void Query_Load(object sender,
EventArgs e)
{
232 Securit y f o r Rel ati o n a l Data ba se s
too
lStripStatusLabel.Text = GlobalClasses.
globals.UserName;
}
pri
vate void saveToolStripButton_Click(object
sender, EventArgs e)
{
}
}
}
System.ComponentModel.ComponentResourceManager
resources = new System.ComponentModel.Compo
nentResourceManager(typeof(QueryForm));
thi
s.richTextBox1 = new System.Windows.Forms.
RichTextBox();
thi
s.toolStrip1 = new System.Windows.Forms.
ToolStrip();
thi
s.toolStripButton1 = new System.Windows.
Forms.ToolStripButton();
thi
s.splitContainer1 = new System.Windows.
Forms.SplitContainer();
thi
s.BCMLSBTN = new System.Windows.Forms.
RadioButton();
thi
s.MLRBTN = new System.Windows.Forms.
RadioButton();
thi
s.SmithBTN = new System.Windows.Forms.
RadioButton();
thi
s.JSBTN = new System.Windows.Forms.
RadioButton();
thi
s.SeaviewBTN = new System.Windows.Forms.
RadioButton();
thi
s.dataGridView1 = new System.Windows.Forms.
DataGridView();
thi
s.EncryptionBTN = new System.Windows.Forms.
RadioButton();
this.toolStrip1.SuspendLayout();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)
(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
//richTextBox1
//
this.richTextBox1.Dock
= System.Windows.Forms.DockStyle.Bottom;
thi
s.richTextBox1.Location = new System.
Drawing.Point(0, 26);
this.richTextBox1.Name = “richTextBox1”;
thi
s.richTextBox1.Size = new System.Drawing.
Size(547, 141);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = “”;
234 Securit y f o r Rel ati o n a l Data ba se s
thi
s.richTextBox1.TextChanged + = new System.
EventHandler(this.richTextBox1 _ TextChanged);
//
//toolStrip1
//
thi
s.toolStrip1.BackColor = System.Drawing.
SystemColors.Control;
this.toolStrip1.Items.AddRange(new System.
Windows.Forms.ToolStripItem[] {
this.toolStripButton1});
thi
s.toolStrip1.Location = new System.Drawing.
Point(0, 0);
this.toolStrip1.Name = “toolStrip1”;
thi
s.toolStrip1.Size = new System.Drawing.
Size(547, 25);
this.toolStrip1.TabIndex = 1;
this.toolStrip1.Text = “toolStrip1”;
thi
s.toolStrip1.ItemClicked + = new System.
Windows.Forms.ToolStripItemClickedEventHand
ler(this.toolStrip1_ItemClicked);
//
//toolStripButton1
//
this.toolStripButton1.Image =
((System.Drawing.Image)(resources.
GetObject(“toolStripButton1.Image”)));
this.toolStripButton1.ImageTransparentColor
= System.Drawing.Color.Magenta;
this.toolStripButton1.Name
= “toolStripButton1”;
thi
s.toolStripButton1.Size = new System.
Drawing.Size(67, 22);
this.toolStripButton1.Text = “Execute”;
thi
s.toolStripButton1.Click + = new System.
EventHandler(this.toolStripButton1_Click);
//
//splitContainer1
//
thi
s.splitContainer1.Dock = System.Windows.
Forms.DockStyle.Fill;
thi
s.splitContainer1.Location = new System.
Drawing.Point(0, 25);
this.splitContainer1.Name = “splitContainer1”;
thi
s.splitContainer1.Orientation = System.
Windows.Forms.Orientation.Horizontal;
T he S o ur c e C o d e 235
//
//splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.
Add(this.EncryptionBTN);
this.splitContainer1.Panel1.Controls.
Add(this.BCMLSBTN);
this.splitContainer1.Panel1.Controls.
Add(this.MLRBTN);
this.splitContainer1.Panel1.Controls.
Add(this.SmithBTN);
this.splitContainer1.Panel1.Controls.
Add(this.JSBTN);
this.splitContainer1.Panel1.Controls.
Add(this.SeaviewBTN);
this.splitContainer1.Panel1.Controls.
Add(this.richTextBox1);
//
//splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.
Add(this.dataGridView1);
thi
s.splitContainer1.Size = new System.
Drawing.Size(547, 425);
this.splitContainer1.SplitterDistance = 167;
this.splitContainer1.TabIndex = 2;
//
//BCMLSBTN
//
this.BCMLSBTN.AutoSize = true;
thi
s.BCMLSBTN.Location = new System.Drawing.
Point(295, 3);
this.BCMLSBTN.Name = “BCMLSBTN”;
thi
s.BCMLSBTN.Size = new System.Drawing.
Size(57, 17);
this.BCMLSBTN.TabIndex = 5;
this.BCMLSBTN.TabStop = true;
this.BCMLSBTN.Text = “BCMLS”;
this.BCMLSBTN.UseVisualStyleBackColor = true;
//
//MLRBTN
//
this.MLRBTN.AutoSize = true;
thi
s.MLRBTN.Location = new System.Drawing.
Point(232, 3);
236 Securit y f o r Rel ati o n a l Data ba se s
this.MLRBTN.Name = “MLRBTN”;
thi
s.MLRBTN.Size = new System.Drawing.
Size(45, 17);
this.MLRBTN.TabIndex = 4;
this.MLRBTN.TabStop = true;
this.MLRBTN.Text = “MLR”;
this.MLRBTN.UseVisualStyleBackColor = true;
//
//SmithBTN
//
this.SmithBTN.AutoSize = true;
thi
s.SmithBTN.Location = new System.Drawing.
Point(129, 3);
this.SmithBTN.Name = “SmithBTN”;
thi
s.SmithBTN.Size = new System.Drawing.
Size(97, 17);
this.SmithBTN.TabIndex = 3;
this.SmithBTN.TabStop = true;
this.SmithBTN.Text = “Smith-Winslett “;
this.SmithBTN.UseVisualStyleBackColor = true;
//
//JSBTN
//
this.JSBTN.AutoSize = true;
thi
s.JSBTN.Location = new System.Drawing.
Point(83, 3);
this.JSBTN.Name = “JSBTN”;
this.JSBTN.Size = new System.Drawing.Size(40, 17);
this.JSBTN.TabIndex = 2;
this.JSBTN.TabStop = true;
this.JSBTN.Text = “J-S”;
this.JSBTN.UseVisualStyleBackColor = true;
//
//SeaviewBTN
//
this.SeaviewBTN.AutoSize = true;
thi
s.SeaviewBTN.Location = new System.Drawing.
Point(12, 3);
this.SeaviewBTN.Name = “SeaviewBTN”;
thi
s.SeaviewBTN.Size = new System.Drawing.
Size(65, 17);
this.SeaviewBTN.TabIndex = 1;
this.SeaviewBTN.TabStop = true;
this.SeaviewBTN.Text = “Seaview”;
T he S o ur c e C o d e 237
this.SeaviewBTN.UseVisualStyleBackColor =
true;
//
//dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
thi
s.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.ColumnHeadersHeightSizeMode
= System.Windows.Forms.
DataGridViewColumnHeadersHeightSizeMode.
AutoSize;
thi
s.dataGridView1.Dock = System.Windows.
Forms.DockStyle.Fill;
thi
s.dataGridView1.Location = new System.
Drawing.Point(0, 0);
this.dataGridView1.Name = “dataGridView1”;
this.dataGridView1.ReadOnly = true;
thi
s.dataGridView1.Size = new System.Drawing.
Size(547, 254);
this.dataGridView1.TabIndex = 0;
//
//EncryptionBTN
//
this.EncryptionBTN.AutoSize = true;
thi
s.EncryptionBTN.Location = new System.
Drawing.Point(358, 3);
this.EncryptionBTN.Name = “EncryptionBTN”;
thi
s.EncryptionBTN.Size = new System.Drawing.
Size(100, 17);
this.EncryptionBTN.TabIndex = 6;
this.EncryptionBTN.TabStop = true;
this.EncryptionBTN.Text = “MLR-Encryption”;
this.EncryptionBTN.UseVisualStyleBackColor
= true;
//
//QueryForm
//
thi
s.AutoScaleDimensions = new System.Drawing.
SizeF(6F, 13F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
thi
s.ClientSize = new System.Drawing.
Size(547, 450);
this.Controls.Add(this.splitContainer1);
238 Securit y f o r Rel ati o n a l Data ba se s
this.Controls.Add(this.toolStrip1);
thi
s.FormBorderStyle = System.Windows.Forms.
FormBorderStyle.Fixed3D;
this.Name = “QueryForm”;
this.Text = “Query”;
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.splitContainer1.Panel1.
ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.
ResumeLayout(false);
this.splitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)
(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.RichTextBox
richTextBox1;
private System.Windows.Forms.ToolStrip
toolStrip1;
private System.Windows.Forms.ToolStripButton
toolStripButton1;
private System.Windows.Forms.SplitContainer
splitContainer1;
private System.Windows.Forms.DataGridView
dataGridView1;
private System.Windows.Forms.RadioButton
SeaviewBTN;
private System.Windows.Forms.RadioButton
JSBTN;
private System.Windows.Forms.RadioButton
SmithBTN;
private System.Windows.Forms.RadioButton
MLRBTN;
private System.Windows.Forms.RadioButton
BCMLSBTN;
private System.Windows.Forms.RadioButton
EncryptionBTN;
}
}
using System;
T he S o ur c e C o d e 239
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GlobalClasses;
using System.Data.SqlClient;
using System.Collections;
namespace MLS
{
public partial class QueryForm : Form
{
public QueryForm()
{
InitializeComponent();
}
pri
vate void richTextBox1_TextChanged(object
sender, EventArgs e)
{
}
pri
vate void toolStripButton1_Click(object
sender, EventArgs e)
{
try
{
DateTime dt = DateTime.Now;
string SqlStr = “”;
if (richTextBox1.Text.ToUpper().
Contains(“SELECT”))
{
string oldSTR = MLSDB.
DMLSTR(richTextBox1.Text).Trim().
ToUpper();
string newSTR = “”; ;
if (SeaviewBTN.Checked)
{
newSTR =
“UserVisibleSeaView” +
MLSDB.DMLSTR(richTextBox1.
Text).Trim().ToUpper();
}
else if (JSBTN.Checked)
24 0 Securit y f o r Rel ati o n a l Data ba se s
{
new
STR = “UserVisibleJS” +
MLSDB.DMLSTR(richTextBox1.
Text).Trim().ToUpper();
}
else if (SmithBTN.Checked)
{
new
STR = “UserVisibleSmith”
+ MLSDB.
DMLSTR(richTextBox1.Text).
Trim().ToUpper();
}
else if (MLRBTN.Checked)
{
new
STR = “VW” + MLSDB.
DMLSTR(richTextBox1.
Text).Trim().ToUpper();
}
else if (EncryptionBTN.Checked)
{
new
STR = “[Vw” + MLSDB.
DMLSTR(richTextBox1.
Text).Trim().ToUpper()
+ “-Encryption]”;
}
if (BCMLSBTN.Checked)
{
new
STR = “VBC” + MLSDB.
DMLSTR(richTextBox1.
Text).Trim().ToUpper();
}
BindingSource bindingSource1 = new
BindingSource();
Sql
Str = richTextBox1.Text.ToUpper().
Replace(oldSTR, newSTR);
if (EncryptionBTN.Checked)
{
Sql
Str = “exec dbo.usp_
EnableCellVisibility;”
+ SqlStr;
}
bindingSource1.DataSource =
GlobalClasses.DBOperations.
GetData(SqlStr).Tables 0];
T he S o ur c e C o d e 2 41
dataGridView1.DataSource =
bindingSource1;
}
els
e if (richTextBox1.Text.
ToUpper().Contains(“INSERT”))
{
str
ing name = GlobalClasses.MLSDB.
GetInsertValue(MLSDB.
AttributeSTR(richTextBox1.Text))
[0].ToString();
str
ing Dept = GlobalClasses.MLSDB.
GetInsertValue(MLSDB.
AttributeSTR(richTextBox1.Text))
[1].ToString();
str
ing Salary = GlobalClasses.MLSDB.
GetInsertValue(MLSDB.
AttributeSTR(richTextBox1.Text))
[2].ToString();
str
ing Class = GlobalClasses.
globals.UserLabelID.ToString();
str
ing Label =
GlobalClasses.globals.UserLabel;
if (SeaviewBTN.Checked)
{
str
ing D2Str = “insert into
dbo.[D2-” + GlobalClasses.
globals.UserLabel + “]
values(“ + name + “,” +
Class + “,” + Dept + “,”
+ Class + “)”;
str
ing D3Str = “insert into
dbo.[D3-” + GlobalClasses.
globals.UserLabel + “]
values(“ + name + “,” +
Class + “,” + Salary +
“,” + Class + “)”;
GlobalClasses.DBOperations.
SetData(D2Str);
GlobalClasses.DBOperations.
SetData(D3Str);
}
else if (JSBTN.Checked)
{
string DStr = “insert into
dbo.[D” + GlobalClasses.
242 Securit y f o r Rel ati o n a l Data ba se s
globals.UserLabel + “]
values(“ + name + “,” +
Class + “,” + Dept + “,”
+ Class +”,” + Salary +
“,” + Class+ “)”;
GlobalClasses.DBOperations.
SetData(DStr);
}
else if (SmithBTN.Checked)
{
str
ing DStr = “insert into dbo.
[Smith-Employee] values(“ + name
+ “,” + Class + “,” + Dept + “,”
+ Salary + “,” + Class + “)”;
GlobalClasses.DBOperations.
SetData(DStr);
}
if (MLRBTN.Checked)
{
str
ing DStr = “insert into dbo.
[Employee] values(“ + name + “,”
+ Class + “,” + Dept + “,” +
Class + “,” + Salary + “,” +
Class + “,” + Class + “)”;
GlobalClasses.DBOperations.
SetData(DStr);
}
if (EncryptionBTN.Checked)
{
str
ing DStr = “exec dbo.
usp _ EnableCellVisibility;
insert into dbo.[Employee]
values(ENCRYPTBYKEY(KEY _
GUID(‘” + Label +
“SymmetricKey’),’” + name
+ “’),” +
“ENCRYPTBYKEY(KEY _ GUID(‘”
+ Label +
“SymmetricKey’),’” + Dept
+ “’),” +
“ENCRYPTBYKEY(KEY _ GUID(‘”
+ Label +
“SymmetricKey’),’” +
Salary + “’),” + Class+
“)”;
T he S o ur c e C o d e 24 3
GlobalClasses.DBOperations.
SetData(DStr);
}
if (BCMLSBTN.Checked)
{
string BCClass = MLSDB.
GetBCLabelNumeric
(globals.UserLabel.
ToUpper()).ToString();
string DStr = “insert into
dbo.[BCEmployee]
values(“ + name + “,” +
BCClass + “,” + Dept +
“,” + BCClass + “,” +
Salary + “,” + BCClass +
“,” + BCClass + “,0)”;
GlobalClasses.DBOperations.
SetData(DStr);
}
}
else if (richTextBox1.Text.
ToUpper().Contains(“UPDATE”))
{
string SelectSTR = “”;
ArrayList AttributeARR
= GlobalClasses.MLSDB.
GetAttribute(MLSDB.
AttributeSTR(richTextBox1.Text));
string PredicateSTR = MLSDB.
PredicateSTR(richTextBox1.Text);
if (SeaviewBTN.Checked)
{
string select = “”;
string updatePredicate = “”;
string UpdateStr = “”;
if (PredicateSTR.Split
(‘ = ‘)[0].Trim().ToUpper()
= = “DEPARTMENT” ||
PredicateSTR.Split(“in”.
ToCharArray(),2)[0].Trim().
ToUpper() = =
“DEPARTMENT”)
{
24 4 Securit y f o r Rel ati o n a l Data ba se s
sel
ect = “select name from
dbo.[D2-” + GlobalClasses.
globals.UserLabel + “]
where “ + PredicateSTR;
}
els
e if (PredicateSTR.
Split(‘ = ‘)[0].Trim().
ToUpper() = = “SALARY” ||
PredicateSTR.Split(“in”.
ToCharArray(),2)[0].Trim().
ToUpper() = = “SALARY”)
{
sel
ect = “select name from
dbo.[D3-” + GlobalClasses.
globals.UserLabel + “]
where “ + PredicateSTR;
}
foreach (DataRow DR in
GlobalClasses.
DBOperations.
GetData(select).
Tables 0].Rows)
{
updatePredicate =
updatePredicate +”’” +
DR[“name”].ToString() +
“’,”;
}
updatePredicate
= updatePredicate.
Remove(updatePredicate.
Length - 1);
updatePredicate = “(“+
updatePredicate +”)”;
foreach (string s in
AttributeARR)
{
if (s.Split(‘ = ‘)[0].
Trim().ToUpper() = =
“DEPARTMENT”)
{
Upd
ateStr = “Update dbo.
[D2-” +
GlobalClasses.
globals.UserLabel +
T he S o ur c e C o d e 24 5
“] set “ + s + “
where name in “ +
updatePredicate;
}
else if (s.Split(‘ = ‘)[0].
Trim().ToUpper() = =
“SALARY”)
{
UpdateStr = “Update dbo.
[D3-” +
GlobalClasses.
globals.UserLabel +
“] set “ + s + “
where name in “ +
updatePredicate;
}
GlobalClasses.DBOperations.
SetData(UpdateStr);
}
}
if (JSBTN.Checked)
{
string UpdateStr = “”;
UpdateStr = “Update dbo.
[D” + GlobalClasses.
globals.UserLabel + “]
set “ + MLSDB.
AttributeSTR
(richTextBox1.Text) + “
where “ + PredicateSTR;
GlobalClasses.DBOperations.
SetData(UpdateStr);
}
if (SmithBTN.Checked)
{
string UpdateStr = “”;
if (MLSDB.PredicateSTR
(richTextBox1.Text) = =
“”)
{
UpdateStr = “Update dbo.
[Smith-Employee] set “ +
MLSDB.AttributeSTR
(richTextBox1.Text) + “
where TC = “ +
24 6 Securit y f o r Rel ati o n a l Data ba se s
GlobalClasses.globals.
UserLabelID.ToString();
}
else
{
UpdateStr = “Update dbo.
[Smith-Employee] set “ +
MLSDB.AttributeSTR
(richTextBox1.Text) + “
where “ + PredicateSTR +
“ and TC = “ +
GlobalClasses.globals.
UserLabelID.ToString();
}
GlobalClasses.DBOperations.
SetData(UpdateStr);
}
else if (MLRBTN.Checked)
{
if (MLSDB.PredicateSTR
(richTextBox1.Text) = =
“”)
{
SqlStr = richTextBox1.Text
+ “ where TC = “ +
GlobalClasses.globals.
UserLabelID.ToString();
SelectSTR = “Select * “ + “
From VW” + MLSDB.DMLSTR
(richTextBox1.Text).
Trim() + “ where TC <>
‘” + GlobalClasses.
globals.UserLabel+”’”;
}
else
{
SqlStr = richTextBox1.Text
+ “ and TC = “ +
GlobalClasses.globals.
UserLabelID.ToString();
Sel
ectSTR = “Select * “ + “ From vw” + MLSDB.
DMLSTR(richTextBox1.Text).Trim() + “ where
“ + MLSDB.PredicateSTR(richTextBox1.Text) +
“ and TC <> ‘” + GlobalClasses.globals.
UserLabel+”’”;
T he S o ur c e C o d e 2 47
}
GlobalClasses.DBOperations.
SetData(SqlStr);
foreach (DataRow DR in
GlobalClasses.
DBOperations.
GetData(SelectSTR).
Tables 0].Rows)
{
foreach (string s in
GlobalClasses.MLSDB.
GetAttribute(MLSDB.
AttributeSTR
(richTextBox1.Text)))
{
DR.SetField(s.Split
(‘ = ‘)[0].Trim(),
s.Split(‘ = ‘)[1].
Trim());
DR.SetField(“C” +
s.Split(‘ = ‘)[0].
Trim(),
GlobalClasses.
globals.UserLabelID);
}
DR.SetField(“TC”,
GlobalClasses.globals.
UserLabelID);
string ColumnSTR = “”;
string ColumnValuesSTR = “”;
foreach (DataColumn DC in
DR.Table.Columns)
{
ColumnSTR + =
DC.ColumnName + “,”;
}
ColumnSTR = ColumnSTR.
Remove(ColumnSTR.Length
- 1);
foreach (object value in
DR.ItemArray)
{
if (value is string)
{
24 8 Securit y f o r Rel ati o n a l Data ba se s
if (
!value.ToString().
Contains(“’”))
{
ColumnValuesSTR + =
“’” + value.
ToString() + “’,”;
}
else
{
ColumnValuesSTR + =
value.ToString() +
“,”;
}
}
else
{
ColumnValuesSTR + =
value.ToString() +
“,”;
}
}
ColumnValuesSTR =
ColumnValuesSTR.
Remove(ColumnValuesSTR.
Length - 1);
string InsertSTR = “insert
into “ + MLSDB.
DMLSTR(richTextBox1.
Text).Trim() + “(“ +
ColumnSTR + “) values (“
+ ColumnValuesSTR + “)”;
GlobalClasses.DBOperations.
SetData(InsertSTR);
}
}
else if (EncryptionBTN.
Checked)
{
string Predicate = MLSDB.
PredicateSTR
(richTextBox1.Text);
if (Predicate = = “”)
{
SqlStr = richTextBox1.Text
+ “ where TC = “ +
T he S o ur c e C o d e 24 9
GlobalClasses.globals.
UserLabelID.ToString();
Sel
ectSTR = “exec dbo.
usp_EnableCellVisibility;
Select * “ + “ From [VW”
+ MLSDB.
DMLSTR(richTextBox1.
Text).Trim() +
“-Encryption] where TC
<> “ + GlobalClasses.
globals.UserLabelID;
}
else
{
str
ing newPredicate = “
CONVERT(nvarchar
(MAX), DecryptByKey
(“+Predicate.
Split(“in”.
ToCharArray(), 2)[0].
Trim()+”)) “;
SqlStr = “exec dbo.usp_
EnableCellVisibility;” +
richTextBox1.Text.
Replace(Predicate.
Split(“in”.
ToCharArray(), 2)[0].
Trim(), newPredicate) +
“ and TC = “ +
GlobalClasses.globals.
UserLabelID.ToString();
SqlStr = SqlStr.
Replace(MLSDB.
DMLSTR(richTextBox1.
Text).Trim(), “dbo.
[“+MLSDB.
DMLSTR(richTextBox1.
Text).Trim() +
“-Encryption]”);
//+ MLSDB.GetAttribute
(MLSDB.AttributeSTR
(richTextBox1.Text))[0].
ToString()
SelectSTR = “exec dbo.
usp_
250 Securit y f o r Rel ati o n a l Data ba se s
EnableCellVisibility;
Select * “ + “ From [VW”
+ MLSDB.
DMLSTR(richTextBox1.
Text).Trim() +
“-Encryption] where “ +
MLSDB.PredicateSTR
(richTextBox1.Text) + “
and TC <> “ +
GlobalClasses.globals.
UserLabelID;
}
GlobalClasses.DBOperations.
SetData(SqlStr);
foreach (DataRow DR in
GlobalClasses.
DBOperations.
GetData(SelectSTR).
Tables 0].Rows)
{
foreach (string s in
GlobalClasses.MLSDB.
GetAttribute(MLSDB.
AttributeSTR
(richTextBox1.Text)))
{
DR.SetField(s.Split(‘ =
‘)[0].Trim(),
s.Split(‘ = ‘)[1].
Trim());
}
DR.SetField(“TC”,
GlobalClasses.globals.
UserLabelID);
string ColumnSTR = “”;
string ColumnValuesSTR =
“”;
foreach (DataColumn DC in
DR.Table.Columns)
{
ColumnSTR + =
DC.ColumnName + “,”;
}
T he S o ur c e C o d e 2 51
ColumnSTR = ColumnSTR.
Remove(ColumnSTR.Length
- 1);
foreach (object value in
DR.ItemArray)
{
if (value is string)
{
if (!value.ToString().
Contains(“’”))
{
ColumnValuesSTR + =
“ENCRYPTBYKEY(KEY_
GUID(‘” + globals.
UserLabel +
“SymmetricKey’),’”
+ value.ToString()
+ “’),”;
}
else
{
ColumnValuesSTR + =
“ENCRYPTBYKEY(KEY_
GUID(‘” + globals.
UserLabel +
“SymmetricKey’),” +
value.ToString() +
“),”;
}
}
else
{
ColumnValuesSTR + =
value.ToString() +
“,”;
}
}
ColumnValuesSTR =
ColumnValuesSTR.Remove
(ColumnValuesSTR.Length
- 1);
string InsertSTR = “exec
dbo.usp_
EnableCellVisibility;
insert into [“ + MLSDB.
252 Securit y f o r Rel ati o n a l Data ba se s
DMLSTR(richTextBox1.
Text).Trim() +
“-Encryption](“ +
ColumnSTR + “) values
(“ + ColumnValuesSTR +
“)”;
GlobalClasses.DBOperations.
SetData(InsertSTR);
}
}
else if (BCMLSBTN.Checked)
{
int TC = 0;
if (MLSDB.PredicateSTR
(richTextBox1.Text) = =
“”)
{
SelectSTR = “Select * From
BC” + MLSDB.DMLSTR
(richTextBox1.Text).
Trim();
}
else
{
SelectSTR = “Select * From
BC” + MLSDB.DMLSTR
(richTextBox1.Text).
Trim() + “ where “ +
MLSDB.PredicateSTR
(richTextBox1.Text);
}
foreach (DataRow DR in
GlobalClasses.
DBOperations.
GetData(SelectSTR).
Tables 0].Rows)
{
TC = Convert.
ToInt32(DR[6]);
if (MLSDB.
GetBCprimarylevel(TC) =
= globals.UserLabel)
{
T he S o ur c e C o d e 253
GlobalClasses.
DBOperations.SetData
(richTextBox1.Text);
}
}
}
}
els
e if (richTextBox1.Text.
ToUpper().Contains(“UPLEVEL”))
{
str
ing Query = richTextBox1.Text.
Replace(“\n”, “ “);
string name = “”;
string Cname = “”;
string Dept = “”;
string CDept = “”;
string Salary = “”;
string CSalary = “”;
int TC = globals.UserLabelID;
string SelectSTR = “”;
for
each (string s in GlobalClasses.
MLSDB.GetAttribute(MLSDB.
AttributeSTR(Query)))
{
string[] stringSeparators
= new string[]
{“FROM”};
str
ing Coulmn =
s.ToUpper().
Split(stringSeparators,
StringSplitOptions.
RemoveEmptyEntries)[0].
Trim().ToUpper();
str
ing CoulmnClass =
s.ToUpper().
Split(stringSeparators,
StringSplitOptions.
RemoveEmptyEntries)[1].
Trim().ToUpper();
if
(Coulmn = =
“DEPARTMENT”)
{
Sel
ectSTR = “Select
Name,CName,Department,
CDept from “ + MLSDB.
25 4 Securit y f o r Rel ati o n a l Data ba se s
DMLSTR(Query).Trim() + “
where “ + MLSDB.
PredicateSTR(Query) + “
and TC = “ + MLSDB.
GetLabelID(CoulmnClass);
Dat
aRow DR = GlobalClasses.
DBOperations.GetData
(SelectSTR).Tables 0].
Rows[0];
nam
e = DR.ItemArray[0].
ToString();
Cna
me = DR.ItemArray[1].
ToString();
Dep
t = DR.ItemArray[2].
ToString();
CDe
pt = DR.ItemArray[3].
ToString();
}
els
e if (Coulmn = =
“SALARY”)
{
Sel
ectSTR = “Select
Name,CName,SALARY,
CSALARY from “ + MLSDB.
DMLSTR(Query).Trim() + “
where “ + MLSDB.
PredicateSTR(Query) + “
and TC = “ + MLSDB.
GetLabelID(CoulmnClass);
Dat
aRow DR = GlobalClasses.
DBOperations.GetData
(SelectSTR).Tables 0].
Rows[0];
nam
e = DR.ItemArray[0].
ToString();
Cna
me = DR.ItemArray[1].
ToString();
Sal
ary = DR.ItemArray[2].
ToString();
CSa
lary = DR.ItemArray[3].
ToString();
}
}
str
ing DStr = “insert into “ +
MLSDB.DMLSTR(Query).Trim() + “
T he S o ur c e C o d e 255
els
e if (richTextBox1.Text.
ToUpper().Contains(“DELETE”))
{
if (SeaviewBTN.Checked)
{
string D2Str = “Delete From
dbo.[D2-” +
GlobalClasses.globals.
UserLabel + “] where “ +
MLSDB.PredicateSTR
(richTextBox1.Text);
string D3Str = “Delete From
dbo.[D3-” +
GlobalClasses.globals.
UserLabel + “] where “ +
MLSDB.PredicateSTR
(richTextBox1.Text);
GlobalClasses.DBOperations.
SetData(D2Str);
GlobalClasses.DBOperations.
SetData(D3Str);
}
else if (JSBTN.Checked)
{
string DStr = “Delete From
dbo.[D” + GlobalClasses.
globals.UserLabel + “]
where “ + MLSDB.
PredicateSTR
(richTextBox1.Text);
GlobalClasses.DBOperations.
SetData(DStr);
}
else if (SmithBTN.Checked)
{
string DStr = “Delete From
dbo.[Smith-Employee]
where “ + MLSDB.
PredicateSTR
(richTextBox1.Text) + “
and TC = “ +
GlobalClasses.globals.
UserLabelID;
GlobalClasses.DBOperations.
SetData(DStr);
T he S o ur c e C o d e 257
}
else if (MLRBTN.Checked)
{
string DStr = “Delete From
“ + MLSDB.
DMLSTR(richTextBox1.
Text).Trim() + “ where “
+ MLSDB.PredicateSTR
(richTextBox1.Text) + “
and TC = “ +
GlobalClasses.globals.
UserLabelID;
GlobalClasses.DBOperations.
SetData(DStr);
}
else if (EncryptionBTN.Checked)
{
string DStr = “Delete From
[“ + MLSDB.DMLSTR
(richTextBox1.Text).
Trim() + “-Encryption]
where “ + MLSDB.
PredicateSTR
(richTextBox1.Text) + “
and TC = “ +
GlobalClasses.globals.
UserLabelID;
GlobalClasses.DBOperations.
SetData(DStr);
}
else if (BCMLSBTN.Checked)
{
str
ing SelectSTR = “select
* from BC” + MLSDB.
DMLSTR(richTextBox1.
Text).Trim().ToUpper() +
“ where “ + MLSDB.
PredicateSTR
(richTextBox1.Text);
Dat
aRow DR = GlobalClasses.
DBOperations.GetData
(SelectSTR).Tables 0].
Rows[0];
258 Securit y f o r Rel ati o n a l Data ba se s
string xkey =
DR.ItemArray[0].
ToString();
intxlbOl = Convert.
ToInt32(DR.ItemArray[1].
ToString());
intxtc = Convert.
ToInt32(DR.ItemArray[6].
ToString());
if (MLSDB.
GetBCSecondarylevel(xtc)
= = “”)
{
string DStr = “Delete From
BC” + MLSDB.DMLSTR
(richTextBox1.Text).
Trim() + “ where “ +
MLSDB.PredicateSTR
(richTextBox1.Text) + “
and TC = “ + xtc.
ToString();
GlobalClasses.DBOperations.
SetData(DStr);
}
else
{
intnewLabel = MLSDB.
UnverifyBCUserbelief
(xtc);
string UpdateSTR = “Update
BC” + MLSDB.DMLSTR
(richTextBox1.Text).
Trim() + “ set CName = “
+ newLabel.ToString() +
“, CDept = “ + newLabel.
ToString() + “, CSalary
= “ + newLabel.
ToString() + “, TC = “ +
newLabel.ToString() + “,
flag = “ + newLabel.
ToString() + “ where “ +
MLSDB.PredicateSTR
(richTextBox1.Text) + “
and TC = “ + xtc.
ToString();
T he S o ur c e C o d e 259
GlobalClasses.DBOperations.
SetData(UpdateSTR);
}
}
}
MessageBox.Show(DateTime.Now.
Subtract(dt).ToString());
}
catch (Exception EX)
{
MessageBox.Show(EX.Message);
}
}
pri
vate void toolStrip1_ItemClicked(object sender,
ToolStripItemClickedEventArgs e)
{
}
}
}
thi
s.richTextBox1.TextChanged + = new System.
EventHandler(this.richTextBox1_
TextChanged);
//
//toolStrip1
//
thi
s.toolStrip1.BackColor = System.Drawing.
SystemColors.Control;
this.toolStrip1.Items.AddRange(new System.
Windows.Forms.ToolStripItem[] {
this.toolStripButton1});
thi
s.toolStrip1.Location = new System.Drawing.
Point(0, 0);
this.toolStrip1.Name = “toolStrip1”;
thi
s.toolStrip1.Size = new System.Drawing.
Size(547, 25);
this.toolStrip1.TabIndex = 1;
this.toolStrip1.Text = “toolStrip1”;
thi
s.toolStrip1.ItemClicked + = new System.
Windows.Forms.ToolStripItemClickedEventHand
ler(this.toolStrip1_ItemClicked);
//
//toolStripButton1
//
thi
s.toolStripButton1.Image = ((System.
Drawing.Image)(resources.
GetObject(“toolStripButton1.Image”)));
this.toolStripButton1.ImageTransparentColor =
System.Drawing.Color.Magenta;
this.toolStripButton1.Name =
“toolStripButton1”;
thi
s.toolStripButton1.Size = new System.
Drawing.Size(67, 22);
this.toolStripButton1.Text = “Execute”;
thi
s.toolStripButton1.Click + = new System.
EventHandler(this.toolStripButton1_Click);
//
//splitContainer1
//
thi
s.splitContainer1.Dock = System.Windows.
Forms.DockStyle.Fill;
thi
s.splitContainer1.Location = new System.
Drawing.Point(0, 25);
this.splitContainer1.Name = “splitContainer1”;
262 Securit y f o r Rel ati o n a l Data ba se s
thi
s.splitContainer1.Orientation = System.
Windows.Forms.Orientation.Horizontal;
//
//splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.
radioButton1);
this.splitContainer1.Panel1.Controls.Add(this.
SeaviewBTN);
this.splitContainer1.Panel1.Controls.Add(this.
richTextBox1);
//
//splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.
dataGridView1);
thi
s.splitContainer1.Size = new System.
Drawing.Size(547, 425);
this.splitContainer1.SplitterDistance = 167;
this.splitContainer1.TabIndex = 2;
//
//radioButton1
//
this.radioButton1.AutoSize = true;
thi
s.radioButton1.Location = new System.
Drawing.Point(302, 3);
this.radioButton1.Name = “radioButton1”;
thi
s.radioButton1.Size = new System.Drawing.
Size(70, 17);
this.radioButton1.TabIndex = 2;
this.radioButton1.TabStop = true;
this.radioButton1.Text = “Proposed”;
this.radioButton1.UseVisualStyleBackColor =
true;
//
//SeaviewBTN
//
this.SeaviewBTN.AutoSize = true;
thi
s.SeaviewBTN.Location = new System.Drawing.
Point(168, 3);
this.SeaviewBTN.Name = “SeaviewBTN”;
thi
s.SeaviewBTN.Size = new System.Drawing.
Size(73, 17);
this.SeaviewBTN.TabIndex = 1;
this.SeaviewBTN.TabStop = true;
T he S o ur c e C o d e 263
this.SeaviewBTN.Text = “Rajwinder”;
this.SeaviewBTN.UseVisualStyleBackColor =
true;
//
//dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows =
false;
this.dataGridView1.ColumnHeadersHeightSizeMode
= System.Windows.Forms.
DataGridViewColumnHeadersHeightSizeMode.
AutoSize;
thi
s.dataGridView1.Dock = System.Windows.
Forms.DockStyle.Fill;
thi
s.dataGridView1.Location = new System.
Drawing.Point(0, 0);
this.dataGridView1.Name = “dataGridView1”;
this.dataGridView1.ReadOnly = true;
thi
s.dataGridView1.Size = new System.Drawing.
Size(547, 254);
this.dataGridView1.TabIndex = 0;
//
//QueryForm
//
thi
s.AutoScaleDimensions = new System.Drawing.
SizeF(6F, 13F);
thi
s.AutoScaleMode = System.Windows.Forms.
AutoScaleMode.Font;
thi
s.ClientSize = new System.Drawing.Size(547,
450);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.toolStrip1);
thi
s.FormBorderStyle = System.Windows.Forms.
FormBorderStyle.Fixed3D;
this.Name = “QueryForm”;
this.Text = “Query”;
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.splitContainer1.Panel1.
ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.
ResumeLayout(false);
this.splitContainer1.ResumeLayout(false);
264 Securit y f o r Rel ati o n a l Data ba se s
((System.ComponentModel.ISupportInitialize)
(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.RichTextBox
richTextBox1;
private System.Windows.Forms.ToolStrip
toolStrip1;
private System.Windows.Forms.ToolStripButton
toolStripButton1;
private System.Windows.Forms.SplitContainer
splitContainer1;
private System.Windows.Forms.DataGridView
dataGridView1;
private System.Windows.Forms.RadioButton
SeaviewBTN;
private System.Windows.Forms.RadioButton
radioButton1;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GlobalClasses;
using System.Data.SqlClient;
using System.Collections;
namespace MLS
{
public partial class QueryForm : Form
{
public QueryForm()
{
InitializeComponent();
}
pri
vate void richTextBox1_TextChanged(object
sender, EventArgs e)
{
}
T he S o ur c e C o d e 265
pri
vate void toolStrip1_ItemClicked(object
sender, ToolStripItemClickedEventArgs e)
{
}
pri
vate void toolStripButton1_Click(object
sender, EventArgs e)
{
if (radioButton1.Checked)
{
SqlConnection HighConnection = new
SqlConnection(“Data Source =.;
Initial Catalog =
ConcurrenCycontrol;Integrated
Security = SSPI “);
HighConnection.Open();
SqlCommand HighCommand =
HighConnection.CreateCommand();
SqlTransaction LowTrans;
SqlTransaction HighTrans;
//Start a local transaction
DateTime datepefor = DateTime.Now;
HighTrans = HighConnection.
BeginTransaction();
HighCommand.Connection =
HighConnection;
HighCommand.Transaction = HighTrans;
HighCommand.CommandText = “select *
from MLS where tc = ‘Low’”;
HighCommand.ExecuteNonQuery();
intcounter = int.
Parse(richTextBox1.Text);
SqlConnection LowConnection = new
SqlConnection(“Data Source =.;
Initial Catalog =
ConcurrenCycontrol;Integrated
Security = SSPI “);
LowConnection.Open();
SqlCommand LowCommand =
LowConnection.CreateCommand();
DateTime datepefor1 = DateTime.Now;
LowTrans = LowConnection.
BeginTransaction();
LowCommand.Connection =
LowConnection;
LowCommand.Transaction = LowTrans;
266 Securit y f o r Rel ati o n a l Data ba se s
LowConnection.Open();
SqlCommand LowCommand =
LowConnection.CreateCommand();
LowTrans = LowConnection.
BeginTransaction();
LowCommand.Connection =
LowConnection;
LowCommand.Transaction = LowTrans;
LowCommand.CommandText = “update MLS
set Salary = Salary where tc =
‘Low’ and Name not in (select top
300 Name from MLS)”;
LowCommand.ExecuteNonQuery();
for (int i = 1; i < = counter; i++)
{
LowCommand.CommandText = “update MLS
set Salary = Salary where tc =
‘Low’ and Name in (select top 300
Name from MLS)”;
LowCommand.ExecuteNonQuery();
}
LowTrans.Commit();
HighTrans.Commit();
MessageBox.Show(DateTime.Now.
Subtract(datepefor).ToString());
}
}
}}
References
269
270 Ref eren c e s
10. Ji-Won Byun and Ninghui Li. 2008. Purpose based access control for
privacy protection in relational database systems. Journal of VLDB 17 (4):
603–619.
11. Cristi Garvey and Amy Wu. ASD—Views. 1988. Proceedings of the IEEE
Conference on Security and Privacy, 85–95.
12. Zhu Hong and Feng Yu-Cai. 2001. Study on mandatory access control
in a secure database management system. Journal of Shanghai University
5 (4): 299–307.
13. Mario Pranjic, KreSimir Fertalj, and Nenad Jukic. 2002. Importance
of semantics in MLS database models. Proceedings of 24th International
Conference on Information Technology Interfaces, 51–56.
14. Hasan M. Jamil and Gillian Dobbie. 2004. On logical foundations of
multilevel secure databases. Journal of Intelligent Information Systems
23 (3): 271–294.
15. Luigi Giuri and Pietro lglio. 1996. A role-based secure database design
tool. Proceedings of the 12th Annual Computer Security Applications
Conference, 203–212.
16. Li-xin Xu, Dong Sun, and Dan Liu. 2010. Study on methods for data
confidentiality and data integrity in relational databases. Proceedings of the
3rd IEEE International Conference on Computer Science and Information
Technology (ICCSIT), 292–295.
17. Walid Rjaibi and Paul Bird. 2004. A multi-purpose implementation of
mandatory access control in relational database management systems.
Proceedings of the 30th VLDB Conference, Toronto, Canada, 1010–1020.
18. Indrakshi Ray and Wei Huang. 2005. Event detection in multilevel
secure active databases. Proceedings of the International Conference ICISS
2005, 177–190.
19. Ravi S. Sandhu and Sushil Jajodia. 1992. Polyinstantiation for cover
stories. Proceedings of Second European Symposium on Research in Computer
Security, Toulouse, France, 307–328.
20. Sushil Jajodia, Ravi S. Sandhu, and Barbara T. Blaustein. 1995. Solutions
to the polyinstantiation problem, in information security. An integrated collec-
tion of essays, ed. M. Abrams, IEEE Computer Society Press, 493–529.
21. Doug Nelson and Chip Paradise. 1991. Using polyinstantiation to
develop an MLS application. Proceedings of the Seventh Annual Computer
Security Applications Conference, 12–22.
22. Mikko T. Siponen. 2002. Database security and the problem of polyin-
stantiation: A moral scrutiny. Australasian Journal of Information Systems
10 (1): 41–49.
23. Andro Galinovi and Vlatka Anton. 2007. Polyinstantiation in rela-
tional databases with multilevel security. Proceedings of the ITI 2007 29th
International Conference on Information Technology Interfaces, 128–132.
24. Mark Heckman and William R. Shockley. 1990. The SeaView security
model. IEEE Transactions on Software Engineering 16 (6): 593–607.
25. Sushil Jajodia and Ravi S. Sandhu. 1991. A novel decomposition of mul-
tilevel relations into single-level relations. IEEE Symposium on Security
and Privacy, Oakland, California, 300–313.
Ref eren c e s 2 71
26. Sushil Jajodia and Ravi Sandhu. 1991. Toward a multilevel secure
relational data model. Proceedings of ACM SIGMOD International
Conference on Management Data, Denver, Colorado, 50–59.
27. Joachim Biskup and Lena Wiese. 2009. Combining consistency and
confidentiality requirements in first-order databases. Proceedings of
International Conference ISC 2009, 121–134.
28. Ravi Sandhu and Fang Chen. 1998. The multilevel relational (MLR) data
model. ACM Transactions on Information and System Security 1 (1): 93–132.
29. Nenad Jukic, Susan V. Vrbsky, Allen Parrish, Brandon Dixon, and
Boris Jukic. A belief-consistent multilevel secure relational data model.
Information Systems 24 (5): 377–402.
30. Teresa F. Lunt, Roger R. Schell, William R. Shockley, Mark Heckman, and
Dan Warren. 1988. A near-term design for the SeaView multilevel database
system. Proceedings of the IEEE Symposium on Security and Privacy, 234–244.
31. Frederic Cuppens and Kioumars Yazdanian. 1992. A natural decom-
position of multi-level relations. Proceedings of the IEEE Symposium on
Security and Privacy, 273–284.
32. Keith F. Brewster. 1996. Trusted database management system inter-
pretation of the trusted computer system evaluation criteria. National
Computer Security Center, NCSC technical report-005, 3 (5): 1–57.
33. Ravi Sandhu and Fang Chen. 1995. The semantics and expressive power
of the MLR data model. Proceedings of IEEE Conference on Security and
Privacy, Oakland, CA, 128–142.
34. Mario Pranjic, Nenad Jukic, and Krcsimir Fertalj. 2003. Implementing
belief-consistent multilevel secure relational data model: Issues and solu-
tions. Proceedings of 25th International Conference Information Technology
Interfaces IT1, 149–154.
35. Nenad A. Jukic and Susan V. Vrbsky. 1997. Asserting beliefs in MLS
relational models. Proceedings of SIGMOD Record 26 (3): 30–35.
36. B. Schneier. 1996. Applied cryptography, 2nd ed. New York: John Wiley
& Sons.
37. L. Kocarev. 2001. Chaos-based cryptography: A brief overview. IEEE
Circulation Systems Magazine 1 (3): 6–21.
38. D. Stinson. 2002. Cryptography: Theory and practice, 2nd ed. Boca Raton,
FL: Chapman & Hall.
39. Y. Mao, G. Chen, and S. Lian. 2004. A novel fast image encryption scheme
based on 3D chaotic Baker maps. International Journal of Bifurcation and
Chaos 14 (10): 3613–3624.
40. S. Li. 2003. Analyses and new designs of digital chaotic ciphers. PhD
thesis, School of Electronics & Information Engineering, Xi’an Jiaotong
University, Xi’an, China.
41. National Bureau of Standards. 1980. Data encryption standard modes
of operation, federal information processing standards publication 81.
U.S. Government Printing Office, Washington, DC.
42. S. Li, G. Chen, and X. Zheng. 2004. Chaos-based encryption for digital
images and videos. In Multimedia security handbook, chap. 4. Boca Raton,
FL: CRC Press.
272 Ref eren c e s
43. Y. Mao and M. Wu. 2006. A joint signal processing and cryptographic
approach to multimedia encryption. IEEE Transactions on Image Processing
15 (7): 2061–2075.
44. Y. Mao. 2003. Research on chaos-based image encryption and water-
marking technology. PhD thesis, Department of Automation, Nanjing
University of Science & Technology, Nanjing, China.
45. J. Daemen and V. Rijmen. 1999. AES proposal: Rijndael. AES algorithm
submission.
46. R. Kusters and M. Tuengerthal. 2009. Universally composable sym-
metric encryption, 2nd IEEE Computer Security Foundations Symposium
(CSF ‘09), 293–307.
47. H. Jin, Z. Liao, D. Zou, and C. Li. 2008. Asymmetrical encryption based
automated trust negotiation model. 2nd IEEE International Conference on
Digital Ecosystems and Technologies (DEST 2008), 363–368.
48. S. G. Lian, J. Sun, and Z. Wang. 2004. A novel image encryption scheme
based on JPEG encoding. Proceedings of 8th International Conference on
Information Visualization, 217–220.
49. M. V. Droogenbroeck and R. Benedett. 2002. Techniques for a selec-
tive encryption of uncompressed and compressed images. Proceedings of
Advanced Concepts for Intelligent Vision Systems (ACIVS), Ghent, Belgium,
90–97, September 9–11.
50. F. Dachselt, K. Kelber, and W. Schwarz. 1997. Chaotic coding and cryp-
toanalysis. Proceedings of IEEE International Symposium on Circuits and
Systems, Hong Kong, 1061–1064, June 9–12.
51. S. Li and X. Zheng. 2002. Cryptanalysis of a chaotic image encryption
method. Proceedings of IEEE International Symposium on Circuits and
Systems (ISCAS) 2:708–711.
52. J. Wei, X. Liao, K. W. Wong, and T. Zhou. 2005. Cryptanalysis of crypto-
system using multiple one-dimensional chaotic maps. Communications in
Nonlinear Science and Numerical Simulation 12: 814–822.
53. L. Kocarev and G. Jakimoski. 2001. Logistic map as a block encryption
algorithm. Physics Letters A 289 (4–5): 199–206.
54. T. Xiang, X. Liao, G. Tang, Y. Chen, and K. W. Wong. 2006. A novel
block cryptosystem based on iterating a chaotic map. Physics Letters A 349
(1–4): 109–115.
55. S. Contini, R. L. Rivest, M. J. B. Robshaw, and Y. L. Yin. 1998. The secu-
rity of the RC6TM block cipher. RSA Laboratories, M. I. T. Laboratory
for Computer Science, version 1.0.
56. M. Salleh, S. Ibrahim, and I. F. Isnin. 2003. Enhanced chaotic image
encryption algorithm based on Baker’s map. Proceedings of 2003
International Symposium on Circuits and Systems (ISCAS ‘03), 2:
508–511.
57. D. Chen. 2009. A feasible chaotic encryption scheme for image.
International Workshop on Chaos-Fractals Theories and Applications
(IWCFTA’09), 172–176.
58. A. Palacios and H. Juarez. 2002. Cryptography with cycling chaos. Physics
Letters A 303 (5–6): 345–351.
Ref eren c e s 2 73
72. Zahid Rashid, Abdul Basit, and Zahid Anwar. 2010. TRDBAC: Temporal
reflective database access control. Proceedings of 6th International
Conference on Emerging Technologies (ICET), 337–342.
73. Vinti M. Doshi, William R. Hemdon, Sushil Jajodia, and Catherine
D. McCollum. 1996. Benchmarking multilevel secure database systems
using the MITRE benchmark. Proceedings of IEEE Transactions on
Knowledge and Data Engineering 8 (1): 46–55.
74. Leon Pan. 2008. Using criterion-based access control for multilevel
database security. Proceedings of International Symposium on Electronic
Commerce and Security, 518–522.
75. Ravi S. Sandhu and Sushil Jajodia. 1993. Referential integrity in multi-
level secure databases. Proceedings of 16th NIST-NCSC National Computer
Security Conference, Baltimore, MD, 39–52.
76. Marco Vieira and Henrique Madeira. 2005. Towards a security benchmark
for database management systems. Proceedings of the 2005 International
Conference on Dependable Systems and Networks, 1–10.
77. Gunther Pernul, A. Min Tjoa, and Werner Winiwarter. 1998. Modeling
data secrecy and integrity. Data & Knowledge Engineering Journal
26 (3): 291–308.
78. Zhu Hong, Zhu Yi, Li Chenyang, Shi Jie, Fu Ge,and Wang Yuanzhen.
2008. Formal specification and verification of an extended security
policy model for database systems. Proceedings of Third Asia–Pacific
Trusted Infrastructure Technologies Conference, 132–141.
79. Xiaolei Qian and Teresa F. Lunt. 1997. A semantic framework of the
multilevel secure relational model. IEEE Transactions on Knowledge and
Data Engineering 9 (2): 292–301.
80. Leon Pan. 2009. A unified network security and fine-grained database
access control model. Proceedings of the Second International Symposium on
Electronic Commerce and Security, 265–269.
81. Kamel Barkaoui, Rahma Ben Ayed, Hanifa Boucheneb, and Awatef
Hicheur. 2008. Verification of workflow processes under multilevel secu-
rity considerations. Proceedings of Third International Conference on Risks
and Security of Internet and Systems, 77–84.
82. Baohua Wang, M. A. Xinqiang, and L. I. Danning. 2008. A formal mul-
tilevel database security model. Proceedings of International Conference on
Computational Intelligence and Security, 252–256.
83. Yongzhong He, Zhen Han, Huirong Fu, and Guangzhi Qu. 2010. The
formal model of DBMS enforcing multiple security policies. Journal of
Software 5 (5): 514–521.
84. Veluchandhar Vadivelu, R. V. Jayakumar, M. Muthuvel,
K. Balasubramanian, A. Karthi, Karthikesan, G. Ramaiyan, Alagarsamy
Deepa, and S. Albert Rabara. 2008. A backup mechanism with con-
currency control for multilevel secure distributed database systems.
Proceedings of Third IEEE International Conference on Digital Information
Management (ICDIM), 57–62.
85. Aidong Zhang and Ahmed Elmagarmid. 1993. A theory of global concur-
rency control in multidatabase systems. Journal of VLDB 2 (3): 331–359.
Ref eren c e s 275
100. Nenad Jukic, Svetlozar Nestorov, Susan V. Vrbsky, and Allen Parrish.
2005. Enhancing database access control by facilitating non-key related
cover stories. Journal of Database Management 16 (10): 1–22.
101. Vijayalakshmi Atluri, Sushil Jajodia, and Elisa Bertino. 1997. Transaction
processing in multilevel secure databases with kernelized architecture:
Challenges and solutions. IEEE Transactions on Knowledge and Data
Engineering 9 (5): 697–708.
102. Jonathan Millen and Teresa Lunt. 1992. Security for object-oriented
database systems. Proceedings of the IEEE Symposium on Research in
Security and Privacy, Oakland, CA, 260–272.
103. Thomas Keefe and Wei-Tek Tsai. 1996. A multiversion transaction sched-
uler for centralized multilevel secure database systems. Proceedings of the
1st High-Assurance Systems Engineering Workshop (HASE ‘96), Niagara,
Canada, 206–213.
104. Eduardo Fernandez, Ehud Gudes, and H. Song. 1989. A security model
for object-oriented databases. Proceedings of the IEEE Symposium on
Security and Privacy, 110–115.
105. Eduardo Fernandez, Ehud Gudes, and H. Song. 1994. A model for
evaluation and administration of security in object-oriented databases.
International Journal of IEEE Transactions on Knowledge and Data
Engineering 6 (2): 275–292.
106. Jeffrey Parsons and Jianmin Su. 2006. Analysis of data structures to sup-
port the instance-based database model. Proceedings of Design Science
Research in Information Systems and Technology (DESRIST), Claremont,
CA, 107–130.
107. Jeffrey Parsons and Jianmin Su. 2010. The instance-based multilevel secu-
rity model. Proceedings of International Conference DESRIST, 365–380.
Information Technology / Database
K21447
6000 Broken Sound Parkway, NW
Suite 300, Boca Raton, FL 33487 ISBN: 978-1-4822-0539-8
711 Third Avenue 90000
an informa business New York, NY 10017
2 Park Square, Milton Park
www.crcpress.com Abingdon, Oxon OX14 4RN, UK
9 781482 205398
www.auerbach-publications.com