com.gisgraphy.service
Class UserSecurityAdvice

java.lang.Object
  extended by com.gisgraphy.service.UserSecurityAdvice
All Implemented Interfaces:
org.aopalliance.aop.Advice, org.springframework.aop.AfterAdvice, org.springframework.aop.AfterReturningAdvice, org.springframework.aop.BeforeAdvice, org.springframework.aop.MethodBeforeAdvice

public class UserSecurityAdvice
extends Object
implements org.springframework.aop.MethodBeforeAdvice, org.springframework.aop.AfterReturningAdvice

This advice is responsible for enforcing security and only allowing administrators to modify users. Users are allowed to modify themselves.

Author:
mraible

Field Summary
static String ACCESS_DENIED
          Default "Access Denied" error message (not i18n-ized).
 
Constructor Summary
UserSecurityAdvice()
           
 
Method Summary
 void afterReturning(Object returnValue, Method method, Object[] args, Object target)
          After returning, grab the user, check if they've been modified and reset the SecurityContext if they have.
 void before(Method method, Object[] args, Object target)
          Method to enforce security and only allow administrators to modify users.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACCESS_DENIED

public static final String ACCESS_DENIED
Default "Access Denied" error message (not i18n-ized).

See Also:
Constant Field Values
Constructor Detail

UserSecurityAdvice

public UserSecurityAdvice()
Method Detail

before

public void before(Method method,
                   Object[] args,
                   Object target)
            throws Throwable
Method to enforce security and only allow administrators to modify users. Regular users are allowed to modify themselves.

Specified by:
before in interface org.springframework.aop.MethodBeforeAdvice
Parameters:
method - the name of the method executed
args - the arguments to the method
target - the target class
Throws:
Throwable - thrown when args[0] is null or not a User object

afterReturning

public void afterReturning(Object returnValue,
                           Method method,
                           Object[] args,
                           Object target)
                    throws Throwable
After returning, grab the user, check if they've been modified and reset the SecurityContext if they have.

Specified by:
afterReturning in interface org.springframework.aop.AfterReturningAdvice
Parameters:
returnValue - the user object
method - the name of the method executed
args - the arguments to the method
target - the target class
Throws:
Throwable - thrown when args[0] is null or not a User object


Copyright © 2012. All Rights Reserved.