Hi
I would like to mix @Aspect with spring security.
In my job the security is managed by project so I have methods like these :
Instead of adding an annotation for permission in each method, I would like to use an aspect :Code:public void addUser(Project project, User user) public void addTask(Project project, Task task) public void addDocument(Project project, Document document) ...
Is it even a good idea ?Code:@Before("within(*.service..*)") public void secure(JoinPoint joinPoint) { if (!ArrayUtils.isEmpty(joinPoint.getArgs()) && joinPoint.getSignature() instanceof MethodSignature) { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); if ("project".equals(signature.getParameterNames()[0]) && joinPoint.getArgs()[0] instanceof Project) { Project project = (Project)joinPoint.getArgs()[0]; User user = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); //handle security break; } } }
Is there a clean why to add interceptor or filter to acheive this ?
Regards


Reply With Quote
