SecurityAnnotationBeanPostProcessor¶
-
public class
SecurityAnnotationBeanPostProcessor
implements BeanPostProcessor¶ A
BeanPostProcessor
used by Motech to load permissions from modules. Given a module context, it looks forPreAuthorize
andPostAuthorize
annotations. These annotations are then parsed using anExpressionParser
. The permission names are deduced fromhasRole
andhasAnyRole
in the annotation value. The names of permissions are then saved using theMotechPermissionService
. The bundle name used to construct the permission is retrieved from the application context.
Constructors¶
SecurityAnnotationBeanPostProcessor¶
-
public
SecurityAnnotationBeanPostProcessor
(MotechPermissionService permissionService)¶
Methods¶
postProcessAfterInitialization¶
-
public Object
postProcessAfterInitialization
(Object bean, String beanName)¶ Searches for
org.springframework.security.access.prepost.PreAuthorize
andorg.springframework.security.access.prepost.PostAuthorize
annotations representing permissions and parses them. Parsed annotations are used to find permissions. After that those permissions are added toorg.motechproject.security.service.MotechPermissionService
Parameters: - bean – to be processed
- beanName – name of the bean
Returns: processed bean
postProcessBeforeInitialization¶
processAnnotations¶
-
public void
processAnnotations
(ApplicationContext applicationContext)¶ Processes security annotations from bundles using
postProcessAfterInitialization(Object,String)
methodParameters: - applicationContext – bundle context used to look for annotations