Subversion Repositories DevTools

Rev

Rev 4617 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4617 Rev 5061
Line 1... Line 1...
1
<%
1
<%
2
'=============================================================
2
'=============================================================
3
'//
3
'//
4
'//                  Access Control
4
'//                  Access Control
-
 
5
'//     This class is agnostic of the appliaction and could be common
-
 
6
'//     to all Manager Suite tools
5
'//
7
'//
6
'=============================================================
8
'=============================================================
7
%>
9
%>
-
 
10
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="../common/DictDump.vbs"></SCRIPT> 
8
<%
11
<%
9
'--------------- Global Constants ----------------
12
'--------------- Global Constants ----------------
10
Const enumSESSION_TIMEOUT = 600      ' Minutes
13
Const enumSESSION_TIMEOUT = 600      ' Minutes
11
Const enumSESSION_LAST_REQUEST = "AM_SESSION_LAST_REQUEST"
14
Const enumSESSION_LAST_REQUEST = "AM_SESSION_LAST_REQUEST"
12
Const enumLOGIN_TOKEN_SESSION = "AM_LOGIN_TOKEN"
15
Const enumLOGIN_TOKEN_SESSION = "AM_LOGIN_TOKEN"
Line 28... Line 31...
28
   Private mobjStaticControl
31
   Private mobjStaticControl
29
   Private mobjRowPermissions
32
   Private mobjRowPermissions
30
   Private mobjTablePermissions
33
   Private mobjTablePermissions
31
   Private sSEPARATOR
34
   Private sSEPARATOR
32
   Private mbIsApplicationRunning
35
   Private mbIsApplicationRunning
-
 
36
   Public  bDebug
33
 
37
 
34
   Public Property Let objOraDatabase ( ByRef oOraDatabase )
38
   Public Property Let objOraDatabase ( ByRef oOraDatabase )
35
      Set moOraDatabase = oOraDatabase
39
      Set moOraDatabase = oOraDatabase
36
   End Property
40
   End Property
37
 
41
 
Line 95... Line 99...
95
         UserApplication = TRUE
99
         UserApplication = TRUE
96
      End If
100
      End If
97
 
101
 
98
   End Function
102
   End Function
99
   '-----------------------------------------------------------------------------------------------------------------
103
   '-----------------------------------------------------------------------------------------------------------------
-
 
104
   Public Sub dumpAll()
-
 
105
    Response.Write "<br>Pretty Dictionary mobjStaticControl<pre>"
-
 
106
    Response.Write DICToutput(mobjStaticControl)
-
 
107
    Response.Write "</pre><br>Pretty Dictionary mobjRowPermissions<pre>"
-
 
108
    Response.Write DICToutput(mobjRowPermissions)
-
 
109
    Response.Write "</pre><br>Pretty Dictionary mobjTablePermissions<pre>"
-
 
110
    Response.Write DICToutput(mobjTablePermissions)
-
 
111
    Response.Write "</pre><br>End"
-
 
112
   End Sub
-
 
113
 
-
 
114
   Private Sub RR(txt)
-
 
115
      If  bDebug Then
-
 
116
        Response.Write "<br>" & txt
-
 
117
      End If
-
 
118
   End Sub
-
 
119
   '-----------------------------------------------------------------------------------------------------------------
100
   Public Function BeginRegion ( sControlObjName )
120
   Public Function BeginRegion ( sControlObjName )
101
      Response.write "<table width='100%'  border='0' cellspacing='0' cellpadding='1'>"
121
      Response.write "<table width='100%'  border='0' cellspacing='0' cellpadding='1'>"
102
      Response.write "  <tr>"
122
      Response.write "  <tr>"
103
      Response.write "    <td bgcolor='#FF0000'>&nbsp;<a href='#' class='body_linkw'><b>"& sControlObjName &"</b></a>&nbsp;</td>"
123
      Response.write "    <td bgcolor='#FF0000'>&nbsp;<a href='#' class='body_linkw'><b>"& sControlObjName &"</b></a>&nbsp;</td>"
104
      Response.write "  </tr>"
124
      Response.write "  </tr>"
Line 125... Line 145...
125
        Extract = ""
145
        Extract = ""
126
      End If
146
      End If
127
 
147
 
128
   End Function
148
   End Function
129
   '-----------------------------------------------------------------------------------------------------------------
149
   '-----------------------------------------------------------------------------------------------------------------
130
   Private Function GetDataPermission ( sTableName, nRowId, nPermissionType )
150
   Private Function GetDataPermission ( sTableName, nRowId, nPermissionType, sControlObjName )
131
      Dim cPermissionValue
151
      Dim cPermissionValue
-
 
152
      Dim key : key = Cstr( sTableName &"_"& nRowId &"_"& sControlObjName &"_"& nPermissionType )
132
 
153
 
133
      '--- Get Row Permission ---
154
      '--- Get Row Permission ---
-
 
155
      cPermissionValue = ""
134
      cPermissionValue = mobjRowPermissions.Item ( Cstr( sTableName &"_"& nRowId &"_"& nPermissionType ) )
156
      If mobjRowPermissions.Exists( key ) Then
135
 
-
 
136
 
-
 
137
      'Response.write " VALUE="& cPermissionValue &" for "& sTableName &" "& nRowId &" "& nPermissionType &", "
157
        cPermissionValue = mobjRowPermissions.Item ( key )
138
 
158
      End If
139
 
159
 
140
      If IsNull( cPermissionValue )  OR  ( cPermissionValue = "" ) Then
160
      If IsNull( cPermissionValue )  OR  ( cPermissionValue = "" ) Then
141
 
-
 
142
         '--- Get Default Table Permission ---
161
         '--- Get Default Table Permission ---
143
         cPermissionValue = mobjTablePermissions.Item ( Cstr( sTableName &"_"& nPermissionType ) )
162
          Dim pkey : pkey = Cstr( sTableName &"_"& sControlObjName &"_"& nPermissionType )
144
 
-
 
145
         '--- Raise Exception if Table Default is not found ---
163
          cPermissionValue = ""
146
         'If IsNull( cPermissionValue )  OR  ( cPermissionValue = "" ) Then
164
          If mobjTablePermissions.Exists( pkey ) Then
147
         '   Err.Raise 8, "Default Table Permission is Not Found.", "sTableName="& sTableName &", nPermissionType="& nPermissionType
165
            cPermissionValue = mobjTablePermissions.Item ( pkey )
148
         '   Exit Function
-
 
149
         'End If
166
          End If
150
 
-
 
151
 
-
 
152
         'Response.write " VALUE="& cPermissionValue &" for "& sTableName &" "& nRowId &" "& nPermissionType &", "
-
 
153
 
-
 
154
      End If
167
      End If
155
 
168
 
156
 
-
 
157
      '--- Return TRUE / FALSE ---
169
      '--- Return TRUE / FALSE ---
158
      GetDataPermission = FALSE
170
      GetDataPermission = FALSE
159
      If cPermissionValue = enumDB_YES Then
171
      If cPermissionValue = enumDB_YES Then
160
         GetDataPermission = TRUE
172
         GetDataPermission = TRUE
161
      End If
173
      End If
162
 
174
 
163
   End Function
175
   End Function
164
   '-----------------------------------------------------------------------------------------------------------------
176
   '-----------------------------------------------------------------------------------------------------------------
165
   Public Function IsDataVisible ( sTableName, nRowId, sControlObjName )
177
   Public Function IsDataVisible ( sTableName, nRowId, sControlObjName )
166
      IsDataVisible = FALSE
178
      IsDataVisible = FALSE
167
 
-
 
168
      If IsVisible ( sControlObjName ) Then
-
 
169
         IsDataVisible = GetDataPermission ( sTableName, nRowId, enumDB_PERMISSION_TYPE_VISIBLE )
179
      If IsVisible ( sControlObjName ) OR GetDataPermission ( sTableName, nRowId, enumDB_PERMISSION_TYPE_VISIBLE, sControlObjName ) Then
-
 
180
          IsDataVisible = TRUE
170
      End If
181
      End If
171
 
-
 
172
   End Function
182
   End Function
173
   '-----------------------------------------------------------------------------------------------------------------
183
   '-----------------------------------------------------------------------------------------------------------------
174
   Public Function IsDataActive ( sTableName, nRowId, sControlObjName )
184
   Public Function IsDataActive ( sTableName, nRowId, sControlObjName )
175
      IsDataActive = FALSE
185
      IsDataActive = FALSE
176
 
-
 
177
      If IsActive ( sControlObjName ) Then
186
      If IsActive ( sControlObjName ) OR GetDataPermission ( sTableName, nRowId, enumDB_PERMISSION_TYPE_ACTIVE, sControlObjName ) Then
178
         IsDataActive = TRUE
187
          IsDataActive = TRUE
179
      Else
-
 
180
         IsDataActive = GetDataPermission ( sTableName, nRowId, enumDB_PERMISSION_TYPE_ACTIVE )
-
 
181
      End If
188
      End If
182
 
-
 
183
   End Function
189
   End Function
184
   '-----------------------------------------------------------------------------------------------------------------
190
   '-----------------------------------------------------------------------------------------------------------------
185
   Public Function IsActive ( sControlObjName )
191
   Public Function IsActive ( sControlObjName )
186
      If ( mobjStaticControl.Item (Cstr( sControlObjName &"_"&  enumDB_PERMISSION_TYPE_ACTIVE )) = enumDB_YES )   OR   ( IsNull(sControlObjName) )Then
192
      Dim key : key = Cstr( sControlObjName &"_"&  enumDB_PERMISSION_TYPE_ACTIVE )
187
         IsActive = TRUE
193
      IsActive = FALSE
188
      Else
194
      If mobjStaticControl.Exists(key) Then
-
 
195
          If ( mobjStaticControl.Item (key) = enumDB_YES )   OR   ( IsNull(sControlObjName) )Then
189
         IsActive = FALSE
196
             IsActive = TRUE
-
 
197
          End If
190
      End If
198
      End If
191
 
199
 
192
   End Function
200
   End Function
193
   '-----------------------------------------------------------------------------------------------------------------
201
   '-----------------------------------------------------------------------------------------------------------------
194
   Public Function IsVisible ( sControlObjName )
202
   Public Function IsVisible ( sControlObjName )
195
      If mobjStaticControl.Item (Cstr( sControlObjName &"_"& enumDB_PERMISSION_TYPE_VISIBLE )) = enumDB_YES Then
203
      Dim key : key = Cstr( sControlObjName &"_"& enumDB_PERMISSION_TYPE_VISIBLE )
196
         IsVisible = TRUE
-
 
197
      Else
-
 
198
         IsVisible = FALSE
204
         IsVisible = FALSE
-
 
205
      If mobjStaticControl.Exists(key) Then
-
 
206
          If mobjStaticControl.Item (key) = enumDB_YES Then
-
 
207
             IsVisible = TRUE
-
 
208
        End If
199
      End If
209
      End If
200
   End Function
210
   End Function
201
   '-----------------------------------------------------------------------------------------------------------------
211
   '-----------------------------------------------------------------------------------------------------------------
202
   ' This function is used for HTML conponents that support attribute "disabled". i.e. Button, dropdown, etc.
212
   ' This function is used for HTML conponents that support attribute "disabled". i.e. Button, dropdown, etc.
203
   Public Function IsComponentDisabled ( sControlObjName )
213
   Public Function IsComponentDisabled ( sControlObjName )
Line 208... Line 218...
208
      End If
218
      End If
209
   End Function
219
   End Function
210
   '-----------------------------------------------------------------------------------------------------------------
220
   '-----------------------------------------------------------------------------------------------------------------
211
   Public Sub LoadDataPermissions ( aRows )
221
   Public Sub LoadDataPermissions ( aRows )
212
      Dim numOfRows, rowNum
222
      Dim numOfRows, rowNum
213
      Dim InxTableName, InxRefColumnVal, InxPermissionType, InxPermission
223
      Dim InxTableName, InxRefColumnVal, InxPermissionType, InxPermission, InxControl
-
 
224
      Dim TableName, RefColumnVal, PermissionType, Permission, Control
-
 
225
      Dim key
214
 
226
 
215
      InxTableName      = 0
227
      InxTableName      = 0
216
      InxRefColumnVal      = 1
228
      InxRefColumnVal   = 1
217
      InxPermissionType   = 2
229
      InxPermissionType = 2
218
      InxPermission      = 3
230
      InxPermission     = 3
-
 
231
      InxControl        = 4
219
 
232
 
220
      numOfRows = UBound( aRows, 2 )
233
      numOfRows = UBound( aRows, 2 )
221
 
234
 
222
      For rowNum = 0 To numOfRows
235
      For rowNum = 0 To numOfRows
223
 
236
 
-
 
237
          TableName         =  aRows( InxTableName, rowNum )
-
 
238
          RefColumnVal      =  aRows( InxRefColumnVal, rowNum )
-
 
239
          PermissionType    =  aRows( InxPermissionType, rowNum )
-
 
240
          Permission        =  aRows( InxPermission, rowNum )
-
 
241
          Control           =  aRows( InxControl, rowNum )
224
 
242
 
225
         If aRows( InxRefColumnVal, rowNum ) = 0 Then
243
         If RefColumnVal = 0 Then
226
            '--- Set Table Default Permission (i.e. "0" wildcard for "all records") ---
244
            '--- Set Table Default Permission (i.e. "0" wildcard for "all records") ---
-
 
245
            key = TableName  & "_" & Control & "_" & PermissionType 
-
 
246
            '
-
 
247
            ' Data appears to be wrong and useless
-
 
248
            ' Don't populate this table
227
            mobjTablePermissions.Item ( aRows( InxTableName, rowNum ) &"_"& aRows( InxPermissionType, rowNum ) ) = aRows( InxPermission, rowNum )
249
            'mobjTablePermissions.Item ( key ) = Permission
228
 
250
 
229
         Else
251
         Else
230
            '--- Set Row Permission ---
252
            '--- Set Row Permission ---
231
            mobjRowPermissions.Item ( aRows( InxTableName, rowNum ) &"_"& aRows( InxRefColumnVal, rowNum ) &"_"& aRows( InxPermissionType, rowNum ) ) = aRows( InxPermission, rowNum )
253
            key = TableName  & "_" & RefColumnVal & "_" & Control & "_" & PermissionType 
-
 
254
            mobjRowPermissions.Item ( key ) = Permission
232
 
255
 
233
         End If
256
         End If
234
 
257
 
235
 
258
 
236
      Next
259
      Next
237
 
260
 
238
      'Response.write "<br>"
261
    'Response.Write "</pre><br>Pretty Dictionary mobjRowPermissions<pre>"
239
      'Response.write "mobjRowPermissions.Keys="& Join ( mobjRowPermissions.Keys, ", ") &"<br>"
262
    'Response.Write DICToutput(mobjRowPermissions)
240
      'Response.write "mobjRowPermissions.Items="& Join ( mobjRowPermissions.Items, ", ") &"<br>"
263
    'Response.Write "</pre><br>Pretty Dictionary mobjTablePermissions<pre>"
241
      'Response.write "mobjTablePermissions.Keys="& Join ( mobjTablePermissions.Keys, ", ") &"<br>"
264
    'Response.Write DICToutput(mobjTablePermissions)
242
      'Response.write "mobjTablePermissions.Items="& Join ( mobjTablePermissions.Items, ", ") &"<br>"
265
    'Response.write "</pre>"
243
   End Sub
266
   End Sub
244
   '-----------------------------------------------------------------------------------------------------------------
267
   '-----------------------------------------------------------------------------------------------------------------
245
   Public Sub LoadDataPermissionVariations ( aRows )
268
   Public Sub LoadDataPermissionVariations ( aRows )
246
      Dim numOfRows, rowNum
269
      Dim numOfRows, rowNum
247
      Dim InxTableName, InxRefColumnVal, InxPermissionType, InxPermission
270
      Dim InxTableName, InxRefColumnVal, InxPermissionType, InxPermission
Line 279... Line 302...
279
 
302
 
280
      InxObjName          = 0
303
      InxObjName          = 0
281
      InxPermissionType   = 1
304
      InxPermissionType   = 1
282
      InxPermission       = 2
305
      InxPermission       = 2
283
 
306
 
284
'Response.write "<br>"
-
 
285
      numOfRows = UBound( aRows, 2 )
307
      numOfRows = UBound( aRows, 2 )
286
 
308
 
287
      For rowNum = 0 To numOfRows
309
      For rowNum = 0 To numOfRows
288
        dKey = aRows( InxObjName, rowNum ) &"_"&  aRows( InxPermissionType, rowNum )
310
        dKey = aRows( InxObjName, rowNum ) &"_"&  aRows( InxPermissionType, rowNum )
289
        dValue = CStr( aRows( InxPermission, rowNum ) )  
311
        dValue = CStr( aRows( InxPermission, rowNum ) )  
290
        mobjStaticControl.Add ( dKey ), dValue
312
        mobjStaticControl.Add ( dKey ), dValue
291
'Response.write "--"& mobjStaticControl.Count & " "& dKey &" = "& dValue &"<br>"
-
 
292
      Next
313
      Next
293
 
314
 
-
 
315
      'Response.Write "<br>Pretty Dictionary LoadStaticPermissions mobjStaticControl<pre>"
-
 
316
      'Response.Write DICToutput(mobjStaticControl)
-
 
317
      'Response.Write "</pre>"    
294
 
318
 
295
   End Sub
319
   End Sub
296
   '-----------------------------------------------------------------------------------------------------------------
320
   '-----------------------------------------------------------------------------------------------------------------
297
   Private Function AutoLogonUser ( sUserId )
321
   Private Function AutoLogonUser ( sUserId )
298
      Dim rsQry, query, is_Online
322
      Dim rsQry, query, is_Online
Line 690... Line 714...
690
      Set mobjTablePermissions = CreateObject("Scripting.Dictionary")
714
      Set mobjTablePermissions = CreateObject("Scripting.Dictionary")
691
      Set mobjRowPermissions = CreateObject("Scripting.Dictionary")
715
      Set mobjRowPermissions = CreateObject("Scripting.Dictionary")
692
      mbIsApplicationRunning = NULL   ' The state of application
716
      mbIsApplicationRunning = NULL   ' The state of application
693
 
717
 
694
      sSEPARATOR = "||"
718
      sSEPARATOR = "||"
-
 
719
      bDebug = false
695
 
720
 
696
   End Sub
721
   End Sub
697
   '-----------------------------------------------------------------------------------------------------------------
722
   '-----------------------------------------------------------------------------------------------------------------
698
   Private Sub Class_Terminate()
723
   Private Sub Class_Terminate()
699
      '// Perform action on object disposal. e.g. Set myObj = Nothing
724
      '// Perform action on object disposal. e.g. Set myObj = Nothing