Table of Contents
Security concerns users and their rights to access to details of DO or the whole class. Security is used if parameter generateSecure (attribute of <database>, <table> and <column> tag in doml file) is set to true.
In this case, <table_name>DO.java class extends:
org.webdocwf.dods.access.SecureDO
class. This class is abstract and implements some methods of the class:
com.lutris.dods.builder.generator.dataobject.GenericDO
adding the security (check of user access rights).
They is one more parameter for security used in doml file: generateInsecure (also attribute of <database>, <table> and <column> tag). If generateInsecure is set to true then DODS while generate data access methods without user access check.
Parameters generateSecure and generateInsecure are not mutually exclusive, they can be added independently of each other. In that case both groups of data access methods (with or without users access check) can be generated according to parameters values.
Default value for DODS generator is generateInsecure=true and generateSecure=false.
The method of <tableName>DO that use user access rights are:
createVirgin( org.webdocwf.dods.access.User usr )
createVirgin(DBTransaction dbTrans, org.webdocwf.dods.access.User usr)
createVirgin( String dbName, org.webdocwf.dods.access.User usr )
This method creates new clean DO with user acess concerns.
createExisting( BigDecimal bd, org.webdocwf.dods.access.User usr )
createExisting(BigDecimal bd, DBTransaction dbTrans, org.webdocwf.dods.access.User usr)
createExisting( String dbName, BigDecimal bd, org.webdocwf.dods.access.User usr )
createExisting( String handle,org.webdocwf.dods.access.User usr )
createExisting( String handle, DBTransaction dbTrans, org.webdocwf.dods.access.User usr)
createExisting( String dbName, String handle,org.webdocwf.dods.access.User usr )
This method creates new DO object based on data from existing DO with user access checks.
Other methods of DO object that use security are:
createCopy( <table_name>DO orig, org.webdocwf.dods.access.User usr )
createCopy( <table_name>DO orig, DBTransaction dbTrans, org.webdocwf.dods.access.User usr )
createCopy( String dbName, <table_name>DO orig, org.webdocwf.dods.access.User usr )
Method createCopy creates a DO that has no ObjectId but has a copy of an existing DO's data. Such a DO is used to insert a new database entry that is largely similar to an existing entry.
originalData_get<column_name>([User usr])
Returns the row value of the column <column_name> of the DO's originalData object.
findTransactionCachedObjectByHandle( String cacheHandle,org.webdocwf.dods.access.User usr )
Gets DO with key cacheHandle from the cache.
findCachedObjectByHandle( String cacheHandle,org.webdocwf.dods.access.User usr )
Gets DataStruct object with key cacheHandle from the cache.
get and set methods for table columns
The constructors of <tableName>Query that use user access rights are:
<tableName>Query(org.webdocwf.dods.access.User usr)
<tableName>Query(DBTransaction dbTrans, org.webdocwf.dods.access.User usr)
<tableName>Query( String dbName, org.webdocwf.dods.access.User usr )
<tableName>Query(org.webdocwf.dods.access.User usr)
These constructors craete new <tableName>Query object with user acess checks.
Other methods of <tableName>Query class that use security are setQuery<column_name> methods, setUserMatch<column_name> method and setDBMatch<column_name> method.
The methods of SecureDO class that check user access rights are:
public void assertDODeleteAccess(User usr)
Ensures that the given user is allowed to delete the DO.
public boolean hasDODeleteAccess(User usr)
Checks if the given user is allowed to delete the DO.
public void assertDOCopyAccess(User usr)
Ensures that the given user is allowed to copy the DO.
public boolean hasDOCopyAccess(User usr)
Checks whether the given user is allowed to copy the DO.
public boolean hasDOGetAttrAccess(String attrName, Object value, User usr)
public boolean hasDOGetAttrAccess(String attrName, boolean value, User usr)
public boolean hasDOGetAttrAccess(String attrName,byte value, User usr)
public boolean hasDOGetAttrAccess(String attrName, short value, User usr)
public boolean hasDOGetAttrAccess(String attrName, int value, User usr)
public boolean hasDOGetAttrAccess(String attrName, long value, User usr)
public boolean hasDOGetAttrAccess(String attrName, float value, User usr)
public boolean hasDOGetAttrAccess(String attrName, double value, User usr)
public boolean hasDOGetAttrAccess(String attrName, byte[] value, User usr)
Checks whether the given user is allowed to read the attribute and the value.
protected boolean hasDOSetAttrAccess(String attrName,Object oldValue, Object newValue, User usr)
protected boolean hasDOSetAttrAccess(String attrName, boolean oldValue, boolean newValue, User usr)
protected boolean hasDOSetAttrAccess(String attrName, byte oldValue, byte newValue, User usr)
protected boolean hasDOSetAttrAccess(String attrName, short oldValue, short newValue, User usr)
protected boolean hasDOSetAttrAccess(String attrName, int oldValue, int newValue, User usr)
protected boolean hasDOSetAttrAccess(String attrName, long oldValue, long newValue, User usr)
protected boolean hasDOSetAttrAccess(String attrName, float oldValue, float newValue, User usr)
protected boolean hasDOSetAttrAccess(String attrName, double oldValue, double newValue, User usr)
protected boolean hasDOSetAttrAccess(String attrName, byte[] oldValue, byte[] newValue, User usr)
Checks whether the given user is allowed to update the attribute and the value.
public void assertDOGetDOValueAccess(String attrName, SecureDO value, User usr )
Ensures that the given user is allowed to read the object in a given pointer.
protected boolean hasDOGetDOValueAccess(SecureDO value, User usr)
Checks whether the given user is allowed to read the object in a given pointer.
public boolean hasQueryFindAccess(User usr)
Checks whether the given user is allowed to find the object using a query.
public void assertDOGetVersionAccess(User usr)
Ensures that the given user is allowed to access the version number.
public boolean hasDOGetVersionAccess(User usr)
Checks whether the given user is allowed to access the version number.
public void assertDOIsReadOnlyAccess(User usr)
Ensures that the given user is allowed to read the read-only flag.
public boolean hasDOIsReadOnlyAccess(User usr)
Checks whether the given user is allowed to read the read-only flag.
public void assertDOGetAccess(User usr)
Ensures that the given user is allowed to read the DO existence.
public boolean hasDOGetAccess(User usr)
Checks whether the given user is allowed to read the DO existence.
public void assertDOMakeReadOnlyAccess(User usr)
Ensures that the given user is allowed to set the object readonly.
public boolean hasDOMakeReadOnlyAccess(User usr)
Checks whether the given user is allowed to set the object readonly.
public void assertDOMakeReadWriteAccess(User usr)
Ensures that the given user is allowed to set the object readwrite.
public boolean hasDOMakeReadWriteAccess(User usr )
Check whether the given user is allowed to set the object readwrite.
The User (org.webdocwf.dods.access.User) mentioned in all these methods is DODS Access User Interface.
org.webdocwf.dods.access.User
It defines user's access rights and its methods are used in previously mentioned methods. Applications that use security should implement this User interface.
The methods of User interface that should be implemented are:
public void restrictQuery (Query query)
Restricts the Query for DODS Query access using SQL.
public boolean hasDOCopyAccess (GenericDO obj)
Decides whether the User is allowed to copy the DO.
public boolean hasDOGetAccess (GenericDO obj)
Decides whether the User is allowed to read the existance of the DO.
public boolean hasDOGetVersionAccess (GenericDO obj)
Decides whether the User is allowed to read the version of the DO.
public boolean hasDOIsReadOnlyAccess (GenericDO obj)
Decides whether the User is allowed to read the readOnly attribute of the DO.
public boolean hasDOMakeReadOnlyAccess (GenericDO obj)
Decides whether the User is allowed to set the readOnly attribute to true of the DO.
public boolean hasDOMakeReadWriteAccess (GenericDO obj)
Decides whether the User is allowed to set the readOnly attribute to false of the DO.
public boolean hasDODeleteAccess (GenericDO obj)
Decides whether the User is allowed to delete the DO.
public boolean hasDOCreateAccess (String className)
Decides whether the User is allowed to create the DO of a certain class.
public boolean hasQueryAccess (String className)
Decides whether the User is allowed to query the DOs of a certain class.
public boolean hasQueryFindAccess (GenericDO obj)
Decides whether the User is allowed to find the DO during a query.
public boolean hasQueryAttrAccess (String className, String attrName, Object queryValue, String cmp_op)
public boolean hasQueryAttrAccess (String className, String attrName, boolean queryValue, String cmp_op)
public boolean hasQueryAttrAccess (String className, String attrName, byte queryValue, String cmp_op)
public boolean hasQueryAttrAccess (String className, String attrName, short queryValue, String cmp_op)
public boolean hasQueryAttrAccess (String className, String attrName, int queryValue, String cmp_op)
public boolean hasQueryAttrAccess (String className, String attrName, long queryValue, String cmp_op)
public boolean hasQueryAttrAccess (String className, String attrName, float queryValue, String cmp_op)
public boolean hasQueryAttrAccess (String className, String attrName, double queryValue, String cmp_op)
public boolean hasQueryAttrAccess (String className, String attrName, byte[] queryValue, String cmp_op)
Decides whether the User is allowed to query DOs for an attribute with a certain query-value and comparison operator.
For every query, in runQuery() method of the <table_name>Query.java class, the User's method restrictQuery(Query query) is called. It restricts the Query for DODS Query access using SQL.
For query by oid (query by oid is query which "where" clause contains request for DO with specified oid), first is checked in the DataStruct cache if there is DataStruct object with desired oid. If DataStruct object is not find in the cache, hitting the database is performed, and the retrieved DataStruct object is added to the DataStruct cache. Queries by oid are not added in the query cache (they are trivial).
For found DO (in the cache or in the database), it is checked if the user has rights to assert this object. For this is used method of SecureDO.java class:
hasQueryFindAccess(User user)
This method calls User's method:
hasQueryFindAccess(GenericDO obj)
for the DO. This method returns true if the User is allowed to find the DO during a query. If user can find this object, it is added in query result.
For full caching also, for query by oid, first is checked in the DataStruct cache if there is DataStruct object with desired oid. If DataStruct object is not find in the cache, hitting the database is not performed (all rows from the table are in the cache, so there is no result of this query). After that, on the way described before, it is checked if the User is allowed to find the DO during a query. If yes, the object is added in query result.
For non-oid queries, for full caching, if the query is simple query, the query's result can be retrieved from the DataStruct cache, so there is no need to retrieve results from the database and for every result, the check of user rights is performed on the same way. In any other case of full caching, everything is done the same as for any other query (this is explained in the next paragraph).
For all other queries, it is checked if the query is already in the Query cache (simple, complex or multi-join). Query object has one attribute called "orderRelevant" which is true if query results must not be modified (no DO can be inserted or updated or deleted from cached query results). With the method isOrderRelevant() is checked whether the results of select can be modified or not.
If query is in the cache and the isOrderRelevant() returns false, result oids are retrieved from QueryCache. If query is in the cache and the isOrderRelevant() returns true, and the result oids are not modified, the result oids are also retrieved from query cache. But, if query is in the cache and the isOrderRelevant() returns true, but the result oids are modified, the result oids from the QueryCache are not used. Instead of that, hitting the database is performed.
If the results are found in the query cache, for every result oid, it is checked whether there is that object is in the DataStruct cache. Then, when is counted number od results that are not in the DataStruct cache, the time needed for performing queries by oid on database for all oids from the result that are not in the cache is compared against the time needed for performing the whole query.
If the time needed for performing queries by oid on database is less or equal to query execution time, results are retrieved from the cache, or, if they are not there, from database (using queries by oid).
If the time is longer, or the query is not in the query cache, or the query supports joins with other tables, or cached query results are modified but for this query is order relevant, the query is performed on the database.
If the results are retrieved from database, the query and its necessary data are put in the Query cache (simple, complex or multi-join).
For every result data object, (from the cache or the database), it is checked if the User is allowed to find the DO during a query. If yes, the object is added in query results.
If there was already that query in the query cache, but the query was executed again (because there were not enough result oids in the result list, or because the old query was modified, and for the new query isOrderRelavant is true), the old query is replaced by the new one (this query is not modified).
If caching is not used, query is executed on the database, and for every result data object, it is checked if the User is allowed to find the DO during a query. If yes, the object is added in query results.