Class UseTablePermissionCustomPermissionChecker
java.lang.Object
com.kingsrook.qqq.backend.core.actions.permissions.UseTablePermissionCustomPermissionChecker
- All Implemented Interfaces:
CustomPermissionChecker
,InitializableViaCodeReference
public class UseTablePermissionCustomPermissionChecker
extends Object
implements CustomPermissionChecker, InitializableViaCodeReference
Simple implementation of a Custom Permission Checker, that takes tableName
and TablePermissionSubType name properties, and checks if the session has
that table-permission-sub-type for the specified table name.
Should handle correctly the permission rules applied to the table in question,
e.g., NOT_PROTECTED (effectively making the object checked by this class
NOT_PROTECTED), HAS_ACCESS - to tie this object to ${tableName}.hasAccess,
READ_WRITE, or READ_INSERT_UPDATE_DELETE, which then bases the permission name
on the tablePermissionSubType.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic QCodeReferenceWithProperties
build
(String tableName, TablePermissionSubType tablePermissionSubType) Factory method to build a code reference to this class, with the given table name and tablePermissionSubType.buildAvailablePermission
(QPermissionRules rules, PermissionSubType permissionSubType, String baseName, MetaDataWithName metaDataWithName, String objectType) To assist withPermissionsHelper.getAllAvailablePermissions(QInstance)
this method lets the application return a specializedAvailablePermission
object, e.g., with the name that the permission name that the custom checker will use.void
checkPermissionsThrowing
(AbstractActionInput actionInput, MetaDataWithPermissionRules metaDataWithPermissionRules) PerCustomPermissionChecker
, check if the active session has the permission specified as this class's permissionName property.Getter for tableNameGetter for tablePermissionSubTypeboolean
To assist withPermissionsHelper.getAllAvailablePermissions(QInstance)
this method indicates that this implementation of this interface has implementedCustomPermissionChecker.buildAvailablePermission(QPermissionRules, PermissionSubType, String, MetaDataWithName, String)
void
initialize
(QCodeReference codeReference) As perInitializableViaCodeReference
, initialize an instance of this class using the suppliedQCodeReference
, which is expected to be aQCodeReferenceWithProperties
.void
setTableName
(String tableName) Setter for tableNamevoid
setTablePermissionSubType
(TablePermissionSubType tablePermissionSubType) Setter for tablePermissionSubTypewithTableName
(String tableName) Fluent setter for tableNamewithTablePermissionSubType
(TablePermissionSubType tablePermissionSubType) Fluent setter for tablePermissionSubTypeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.kingsrook.qqq.backend.core.actions.permissions.CustomPermissionChecker
buildBaseAvailablePermission
-
Field Details
-
TABLE_NAME_PROPERTY
- See Also:
-
TABLE_PERMISSION_SUB_TYPE_NAME_PROPERTY
- See Also:
-
-
Constructor Details
-
UseTablePermissionCustomPermissionChecker
public UseTablePermissionCustomPermissionChecker()
-
-
Method Details
-
build
public static QCodeReferenceWithProperties build(String tableName, TablePermissionSubType tablePermissionSubType) Factory method to build a code reference to this class, with the given table name and tablePermissionSubType.- Parameters:
tableName
- Name of the table to be checked by instances of this classtablePermissionSubType
- table-permission type to check for.- Returns:
- code reference that can be passed to, e.g.,
QPermissionRules.withCustomPermissionChecker(QCodeReference)
-
initialize
As perInitializableViaCodeReference
, initialize an instance of this class using the suppliedQCodeReference
, which is expected to be aQCodeReferenceWithProperties
.- Specified by:
initialize
in interfaceInitializableViaCodeReference
-
checkPermissionsThrowing
public void checkPermissionsThrowing(AbstractActionInput actionInput, MetaDataWithPermissionRules metaDataWithPermissionRules) throws QPermissionDeniedException PerCustomPermissionChecker
, check if the active session has the permission specified as this class's permissionName property.- Specified by:
checkPermissionsThrowing
in interfaceCustomPermissionChecker
- Parameters:
actionInput
- generally the input data container for the action being performed - e.g., an InsertInput or RunProcessInputmetaDataWithPermissionRules
- the table/process/etc that is being requested by a user.- Throws:
QPermissionDeniedException
- to indicate the user does not have permission. The method should return without exception to indicate permission granted,
-
handlesBuildAvailablePermission
public boolean handlesBuildAvailablePermission()Description copied from interface:CustomPermissionChecker
To assist withPermissionsHelper.getAllAvailablePermissions(QInstance)
this method indicates that this implementation of this interface has implementedCustomPermissionChecker.buildAvailablePermission(QPermissionRules, PermissionSubType, String, MetaDataWithName, String)
- Specified by:
handlesBuildAvailablePermission
in interfaceCustomPermissionChecker
- Returns:
- in the default implementation, false is returned.
-
buildAvailablePermission
public AvailablePermission buildAvailablePermission(QPermissionRules rules, PermissionSubType permissionSubType, String baseName, MetaDataWithName metaDataWithName, String objectType) Description copied from interface:CustomPermissionChecker
To assist withPermissionsHelper.getAllAvailablePermissions(QInstance)
this method lets the application return a specializedAvailablePermission
object, e.g., with the name that the permission name that the custom checker will use.- Specified by:
buildAvailablePermission
in interfaceCustomPermissionChecker
- Returns:
- an
AvailablePermission
object to add to the set of all available permissions. If null, then no permission is added to that result. - See Also:
-
getTableName
-
setTableName
-
withTableName
Fluent setter for tableName- Parameters:
tableName
- The name of the table that is checked by this checker. Note that this value is not expected to be directly set via this setter - but rather, via the initialization of this class through aQCodeReferenceWithProperties
.- Returns:
- this
-
getTablePermissionSubType
Getter for tablePermissionSubType- See Also:
-
setTablePermissionSubType
Setter for tablePermissionSubType- See Also:
-
withTablePermissionSubType
public UseTablePermissionCustomPermissionChecker withTablePermissionSubType(TablePermissionSubType tablePermissionSubType) Fluent setter for tablePermissionSubType- Parameters:
tablePermissionSubType
- The table permission sub type that is checked by this checker. Note that this value is not expected to be directly set via this setter - but rather, via the initialization of this class through aQCodeReferenceWithProperties
.- Returns:
- this
-