You might wonder why all this concentration on (boring) database access/control where there are all of these interesting user experience things that we could cover instead? Over the years web-development techniques have undergone several phases of change. Nowadays a lot less of the processing for an application is done on the server. Much of it is pushed to the client browser and is executed on your machine. The server must still maintain security on the data however so this is just a good place to start.
There are three classes in the example (bottom of the page for the link): GenericResource, DataAccessor, and a UserAccess class. The DataAccessor and UserAccess classes are meant to emulate a lock and key respectively. A UserAccess object explicitly asks for access to a resource on behalf of a user account to the DataAccessor object which would grant or deny the request.
All of the actual database calls have been removed from this example for clarity's sake but there are comments above where they would normally go. The GenericResource will be discussed more in the next section but it is meant to represent a record in a table. Here we are using it to access an equipment record.
You might be asking, 'Why not just create an Equipment class?'
In a LIMS there are two general types of data: so-called 'Master Data' (MD for sort here) also known by other names like 'setup data' or 'static data'; and that which is dependent upon it which we will call dynamic data. Developers unfamiliar with the different types of data in a LIMS frequently code all of the data access the same way, irrespective of type. We wind up with a separate class for 'Equipment' and another for 'Products' and so on. Perusal of the code reveals nothing surprising in this case -- all the MD classes are really just wrappers for the underlying database access classes provided by the programming language.
Our objective with a LIMS should not only be to save development time but also to make administration tasks easy. If adding a field to the Equipment table means having to edit a class to add getters and setters the entire process will seem (rightly) tedious. It should be possible to simply change some definition and have the system automatically detect the new field and allow for generic access to it. The GenericResource class is meant to start you thinking about this type of manipulation of Master Data.
The GenericResource example fetches a list of groups and puts them into an array. In practice you would probably want to assign only a single group to a record instead. Why? If you look at the userHasAccess() method of the DataAccessor class you will find the answer. More than one group assigned to a resource means you will have to exhaustively compare groups on the resource with the user's groups until you find one that matches. Worst-case scenario means you'll run through all of them which can be wasteful if you are trying to fetch more than one record. If the resource was assigned to only one group then this check could be easily done using a single operation like checking to see if a key exists in an associative array.
Gracefully Saying No
This example easily gives up the requested data when we try to access the equipment information directly but refuses in the second instance. This is what we are after. Every request for information from the LIMS must undergo some type of verification. Some would argue that there is no graceful way to deny access. They might even be tempted to throw an error in such a case.
Handling access refusal issues like this should be intrinsic to your overall LIMS design. You might want to move your data access control code to an earlier phase -- right where the record data is being fetched from the database itself. Whatever method you choose, try to be consistent and avoid keeping the access violation a secret. Make it apparent that the user has attempted to perform an operation with some information he/she/it is not privileged to access.
Here's where to find the sample code. Hint:The simplest test is to change the groups in the UserAccess class to match the ones in the GenericResource class and re-run it.Go Back
Citation: Data Access Control. (2015). Retrieved Mon May 1 02:03:53 2017, from http://www.limsexpert.com/cgi-bin/bixchange/bixchange.cgi?pom=limsexpert3;iid=readMore;go=1439132611