Class AbstractPermissionAnnotationHandler
java.lang.Object
org.craftercms.commons.security.permissions.annotations.AbstractPermissionAnnotationHandler
- Direct Known Subclasses:
HasPermissionAnnotationHandler
Base class for Permission Annotation Handlers.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractPermissionAnnotationHandler(Map<Class<?>, PermissionEvaluator<?, ?>> permissionEvaluators) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckPermissions(Method method, HasPermission hasPermission, Object securedResource) Checks the permissions to perform the action configured in theHasPermissionto the securedResource (if any)protected ObjectgetAnnotatedProtectedResource(Method method, Object[] params) Gets the protected resource (parameter annotated withProtectedResource) from the method parameters.getAnnotatedProtectedResourceIds(Method method, Object[] paramValues) Gets the protected resource ids (e.g.: siteId, path) from the method parameters.protected <T extends Annotation>
TgetHasPermissionAnnotation(Method method, org.aspectj.lang.ProceedingJoinPoint pjp, Class<T> annotationType) Get a permission annotation of the given type from the given method or its containing class if exists
-
Field Details
-
permissionEvaluators
-
-
Constructor Details
-
AbstractPermissionAnnotationHandler
public AbstractPermissionAnnotationHandler(Map<Class<?>, PermissionEvaluator<?, ?>> permissionEvaluators)
-
-
Method Details
-
getHasPermissionAnnotation
protected <T extends Annotation> T getHasPermissionAnnotation(Method method, org.aspectj.lang.ProceedingJoinPoint pjp, Class<T> annotationType) Get a permission annotation of the given type from the given method or its containing class if exists- Type Parameters:
T- the annotation type- Parameters:
method- the method to get the annotation frompjp- the join pointannotationType- the desired annotation type- Returns:
- the annotation, or null if none found
-
getAnnotatedProtectedResource
Gets the protected resource (parameter annotated withProtectedResource) from the method parameters.- Parameters:
method- the method to extract protected resource fromparams- the parameter values- Returns:
- the protected resource, or null if none found
-
getAnnotatedProtectedResourceIds
Gets the protected resource ids (e.g.: siteId, path) from the method parameters.- Parameters:
method- the method to extract parameters fromparamValues- the parameter values- Returns:
- a map with the protected resource ids
-
checkPermissions
protected boolean checkPermissions(Method method, HasPermission hasPermission, Object securedResource) Checks the permissions to perform the action configured in theHasPermissionto the securedResource (if any)- Parameters:
method- theMethodto securehasPermission- theHasPermissionannotationsecuredResource- the securedResource, if any- Returns:
- true if the action is allowed, false otherwise
-