home *** CD-ROM | disk | FTP | other *** search
- #
- # Default Access SetUp for Default four Phase schema
- #
-
- # Check if it is a redefinition of the access rights or a
- # new definition of users, roles and access rights
- set redef ""
- if { [string trim $ucgargv] == "-r" } {
- set redef "True"
- puts "Using -r flag: redefine Access Rights for current roles"
- }
-
- # source TCL what will readin the setup files into global variables
- # userlist - List of User
- # roleinfo - Array of Role Access Information indexed on RoleName
- # userroleinfo - Array of UserLists indexed on RoleName
- # projectconf - Arry of Project configurations indexed on ProjectName
-
- source readsetup.tcl
-
- # Build the actionsMaps for allowed, prohibited and undefined access rights
- # This interface offers a simple CRUD access scheme:
- #
- # C = Create maps to Insert, ModifyStatus Actions
- # R = Read maps to Read Action
- # U = Update maps to Modify, Freeze, Unfreeze and ModifyStatus Actions
- # D = Delete maps to Remove, Destroy Actions
- # M = Manage maps to Control Action
- #
- # see page 86 for the explantion of the bitmap built here
-
- set AllowedMap(C) [expr 2|8|32|512]
- set AllowedMap(R) 8
- set AllowedMap(U) [expr 16|128|256|512]
- set AllowedMap(D) [expr 4|64]
- set AllowedMap(M) 1
-
-
- # At securityLevel level active the SuperUser Role in order to undefinedmap
- # control actions. This can only done by the corporate owner (ot4omt?)
- # Note: this seems also possible by setting the M4 variable(s)
- # M4_corproles_<corpname> (and/or M4_projroles_<projname>)
- proc setSuperUser { securityLevel } {
- $securityLevel activate "SuperUser"
- }
-
- #
- # Add the users from the global userlist to the Corporate Level
- #
- proc addUsers { corp } {
- global userlist
- foreach user $userlist {
- puts "Addding User Name $user to the Corporate Level"
- $corp createUser $user
- }
- }
-
- #
- # Add Roles on Corporate Level and connect listed users to the roles
- #
- proc addRolesAndUsers { securityLevel corp } {
- # Users list per role are listed in the userroleinfo Array
- # All Roles are listed as index in the roleinfo list
- global userroleinfo
- global roleinfo
- set createdroles {}
- foreach roleline $roleinfo {
- set role [string trim [lindex $roleline 0]]
- # Check if the role was not created yet, and skip to next role if so.
- if { [lsearch $createdroles $role] != -1 } {
- continue
- }
- lappend createdroles $role
- puts "Adding role '$role' to Corporate level ..."
- set rolehnd [$corp createRole $role]
- # Now add the Users for this role
- # It can be that there where no users defined for the Role..
- if { [info exists userroleinfo($role)] == 1 } {
- foreach user $userroleinfo($role) {
- set tmp [split $user ':']
- set user [string trim [lindex $tmp 0]]
- set def [string trim [lindex $tmp 1]]
- puts " Adding user '$user' for Role '$role' ..."
- if { "$def" == "N" } {
- set use "defaultOff"
- }
- if { "$def" == "Y" } {
- set use "defaultOn"
- }
- set urhnd [$securityLevel createUserRoleLink $user $rolehnd $use]
- }
- }
- }
- }
-
- #
- # Define the access rights on the controlled (list) objects
- # maskout invalid actions if needed
- #
- proc ModifyAccess { obj role am pm um { islist 0 } } {
-
- # In case of a List Childright all the actions are valid
- if { $islist } {
- # Take care of the childrights of the list
- $obj modifyNewChildRights $role $am $pm $um
- }
-
- # Mask-out possible unvalid access rights for the (list) object
- set validactions [$obj controlledActions]
- set am [expr $validactions & $am]
- set pm [expr $validactions & $pm]
- set um [expr $validactions & $um]
- $obj modifyPermission $role $am $pm $um
- }
-
- proc setAccessRights { client project config role phasevers crudlist } {
-
- global AllowedMap
- global ProhibitMap
-
- # Derive the allowed/prohibited/undefined maps from the crudlist
-
- # UNRESOLVED 24/02/95 alru/keru
- # There are two ways to do this
- #
- # 1: allow the actions as specified and prohibit the inverse allowed map
- # 2: undefine the actions as specified and prohibit the inverse undef map
- #
- # Some expirimenting is needed to see and check which option provides
- # the best access scheme.
- # One of the problems is that the default role always exists, and
- # could lead to a prohibit, since the right was allowed to another role
- set allowedmap 0
- foreach access $crudlist {
- set allowedmap [expr $allowedmap|$AllowedMap($access)]
- }
- set prohibitmap [expr 1023 - $allowedmap]
- set undefinedmap 0
-
-
- # Now we are ready to modify the Permission for this selected PhaseVersion
- puts "\t\t\t>PhaseVersion"
- ModifyAccess $phasevers $role $allowedmap $prohibitmap $undefinedmap
-
- # Besides protecting the phaseverion itself, we need to protect
- # the 'versionable' object Phase
- set phasehdl [$phasevers phase]
- puts "\t\t\t>Phase"
- ModifyAccess $phasehdl $role $allowedmap $prohibitmap $undefinedmap
-
- # Besides modifying access rights on the version itself, we need
- # to modify the access rights for all new versions of the phase
- puts "\t\t\t>phaseVersionList"
- set pvlhdl [$phasehdl phaseVersionList]
- ModifyAccess $pvlhdl $role $allowedmap $prohibitmap $undefinedmap 1
-
- # The Other Controlled Lists (PhaseSystemLinkList & SystemList) are
- # located in the class PhaseVersion.
-
- # Modify Access on the Controlled List PhaseSystemLinkList
- puts "\t\t\t>PhaseSystemLinkList"
- set psllhdl [$phasevers systemVersionLinkList]
- ModifyAccess $psllhdl $role $allowedmap $prohibitmap $undefinedmap 1
-
- # Modify Access on the Controlled List systemList
- puts "\t\t\t>systemList"
- set systemlist [$phasehdl systemList]
- ModifyAccess $systemlist $role $allowedmap $prohibitmap $undefinedmap 1
- }
-
- # Main Program
-
- # Access via the ClientContext Class
- set client [ClientContext::global]
-
- # Get the current security level from the client contect
- # used to activate/list the effective roles.
- set securityLevel [$client currentSecurityLevel]
-
- # Get the Corporate handle from the ClientContext
- set corp [$client currentCorporate]
- set cname [$corp name]
- setSuperUser $securityLevel
-
- # Add the Indicated Users to the Corporate Level
- if { "$redef" == "" } {
- addUsers $corp
- }
-
- # Connect the Users to the defined Roles according the setupfile
- if { "$redef" == "" } {
- addRolesAndUsers $securityLevel $corp
- }
-
- # Define the Access Rights for the defined Roles
-
- # Need to get thes from somewhere
-
- foreach projconf $projectconf {
-
- set tmp [split $projconf ',']
- set project [lindex $tmp 0]
- set config [lindex $tmp 1]
-
- # Now locate the current Phases of the Indicated project & configuration
- # Go down to the Configuration Level to see the Phases
- $client downLevel $project
- set projhnd [$client currentProject]
-
- # In order to have access control rights to the Phase
- # setSuperUser also on the project security Level
- set projectSecurityLevel [$client currentSecurityLevel]
- setSuperUser $projectSecurityLevel
-
- # No go down to the Configuration Level (where the Phases are)
- $client downLevel $config
- set confhnd [$client currentConfig]
- puts ""
- puts "Project : [$projhnd name]"
- puts "Configuration : [$confhnd text]"
- puts ""
-
- # Wildcards used in phase names, need to loop trough phase names
- # of the current configuration, and expand the wildcard
- foreach phasevers [$confhnd phaseVersions] {
- set phasehdl [$phasevers phase]
- set phasename [$phasehdl name]
- puts "\tPhase $phasename"
- foreach roleline $roleinfo {
- set roleline [split $roleline '|']
- set role [string trim [lindex $roleline 0]]
- set phasepat [string trim [lindex $roleline 1]]
- # Check for string match
- if { [string match "$phasepat" $phasename] } {
- set tmpcrud [string trim [lindex $roleline 2]]
- set crudlist [split $tmpcrud '-']
- puts "\t\tSet AccessRights for role '$role' to $crudlist"
- setAccessRights $client $project $config $role $phasevers $crudlist
- }
- }
- }
-
- # go back to the Corporate Level for the next pass in this loop
- $client upLevel
- $client upLevel
- }
-