Annotation Interface AccessCheck
Place this annotation on a method to indicate it requires access control.
The AbstractAccessCheckInterceptor will intercept the method call
and verify the caller's permissions before allowing execution.
Access rights can be granted in two ways:
- Declarative (InMemory): Specify
allowedRoles()directly in the annotation. TheInMemorySecuredResourceScannerreads these at deploy time and stores them together with the secured resource. The pairedInMemoryAccessCheckInterceptorenforces access based on these declared roles. This is the default approach provided by the DynTabs library — zero configuration, everything is in the code.@AccessCheck(resourceDisplayName = "Generate PDF Report", allowedRoles = {"ADMIN", "MANAGER"}) public void generatePdfReport() { ... } - DB-based: The developer creates a custom
DBSecuredResourceScanner(extendingAbstractSecuredResourceScanner) that registers secured resources in a database table, ignoring theallowedRolesattribute. Access rules are managed through an Admin UI where roles are granted permissions on resources. A pairedDBAccessCheckInterceptorreads allowed roles from the database at runtime.
NOTE: @Nonbinding is required on all attributes, otherwise CDI
would treat different attribute values as different interceptor bindings, and the
interceptor would not fire for methods with non-default values.
- Author:
- DynTabs
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionString[]Roles allowed to invoke this method (declarative access control).Human-readable display name for this secured resource.
-
Element Details
-
resourceDisplayName
String resourceDisplayNameHuman-readable display name for this secured resource.Shown in admin UIs for security management. Can be a literal string (e.g. "Generate PDF Report") or a resource bundle key for i18n.
- Default:
""
-
allowedRoles
String[] allowedRolesRoles allowed to invoke this method (declarative access control).Used by the
InMemorySecuredResourceScanner/InMemoryAccessCheckInterceptorpair. Comma-separated role names, e.g.{"ADMIN", "MANAGER"}.Ignored by DB-based implementations, where access rules are managed through an Admin UI and stored in the database.
- Default:
{}
-