_AN APPLICATION ACCESS SECURITY MODEL_ by Mark Robinson Listing One Boolean f_Set(sObject, sMethod, sAttributeValue) Parameters Description sObject A string identifying the object that is to be modified. sMethod A string identifying the name of the method to be used to modify and attribute of sObject. sAttributeValue A string representation of the new value to set by sMethod. Script CHOOSE CASE sMethod CASE 'SHOW' CHOOSE CASE sObject CASE 'CB_SAVE' cbSave.Visible = TRUE CASE 'CB_DETAIL' cbDetail.Visible = TRUE END CHOOSE CASE 'HIDE' CHOOSE CASE sObject CASE 'CB_SAVE' cbSave.Visible = FALSE CASE 'CB_DETAIL' cbDetail.Visible = FALSE END CHOOSE CASE 'TEXT' CHOOSE CASE sObject CASE 'CB_SAVE' cbSave.Text = sAttributeValue CASE 'CB_DETAIL' cbDetail.Text = sAttributeValue END CHOOSE END CHOOSE RETURN TRUE Listing Two String f_Get(sObject, sAttributeName) Parameters Description sObject A string identifying the object that has the desired attribute. sAttributeName A string identifying the attribute whose value is requested. Script string sAttributeValue CHOOSE CASE sAttributeName CASE 'VISIBLE' CHOOSE CASE sObject CASE 'CB_SAVE' IF cbSave.Visible = TRUE THEN sAttributeValue = 'TRUE' ELSE sAttributeValue = 'FALSE' END IF END CHOOSE CASE 'TEXT' CHOOSE CASE sObject CASE 'CB_SAVE' sAttributeValue = cbSave.Text CASE 'CB_DETAIL' sAttributeValue = cbDetail.Text END CHOOSE END CHOOSE RETURN sAttributeValue Listing Three Boolean f_Register(wRegistrant, bParent) Parameters Description wRegistrant A window inherited from base window class, w_base. This window is to be registered by the security handler. bParent A boolean flag indicating if this window is a top level window. Script MaxWindows ++ Registered[MaxWindows].Window = wRegistrant Registered[MaxWindows].bParent = bParent RETURN TRUE Listing Four Boolean f_DeRegister(wRegistrant) Parameters Description wRegistrant A window inherited from base window class, w_base. This window is to be de-registered by the security handler. Script int i FOR i = 1 to MaxWindows IF Registered[i].Window = wRegistrant THEN IF i = MaxWindows THEN MaxWindows -- ELSE Registered[i].Window = Registered[MaxWindows].Window Registered[i].bParent = Registered[MaxWindows].bParent MaxWindows -- END IF EXIT END IF NEXT RETURN TRUE Listing Five Boolean f_Direct(wTarget) Parameters Description wTarget A window inherited from base window class, w_base. This window defines the target for the security handler. In most cases, a window will request security information about itself. Script int i FOR i = 1 TO MaxEntries IF ClassName(wTarget) = Security[i].sWindowName THEN wTarget.f_Set(Security[i].sControlName, Security[i].sMethodName,& Security[i].sAttributeValue) END IF NEXT RETURN TRUE Notes: MaxEntries is an instance variable in the security handler identifying how many entries were loaded from the security database. The Security array is a structure containing the window names, control names, method names, and attribute values that were loaded from the security database. Listing Six Boolean f_Broadcast(sMessageId, sMessageValue) Parameters Description sMessageId A string identifying a pre-defined message to be broadcast. sMessageValue A string containing a value (if necessary) to elaborate on the message. This parameter is used if there is a variable component to the broadcast message. Script int i FOR i = 1 to MaxWindows IF Registered[i].bParent = TRUE THEN Registered[i].Window.f_Set("BROADCAST", sMessageId, sMessageValue) END IF NEXT RETURN TRUE Notes: MaxWindows is an instance variable containing the number of windows that are currently registered. The Registered array is a structure containing a reference to each registered window and a boolean flag that is TRUE if the window is a parent level window. Example 1: (a) // The window (this) registers itself as a parent SecurityHandler.f_Register(This, True) // The window requests the security handler to provide access information SecurityHandler.f_Direct(This) (b) // The window (this) informs the security handler that it is closing SecurityHandler.f_DeRegister(This)