Hi,
I use acegi security's simple daoauthenticationprovider which basically just interface with a dao that returns username/password.
However, it is not a good idea to store plain text password and acegi does provide encoder which would be run against the user input then compared with the stored(thus must be encoded too) password.
So the problem becomes, how can I be sure that my stored password is encoded the same way acegi expected.
This I thought is a perfect example where AOP can solve. I can just intercept either my model class' "setPassword" method or at the dao's save method.
and the aop configCode:class User { .... public void setPassword(String password) { this.password = password } } class GenericDao<T, PK> { protected Class<T> modelClass; /** * Constructor that takes in a class to see which type of entity to persist * @param modelClass the class type you'd like to persist */ public GenericDao(final Class<T> modelClass) { this.modelClass = modelClass; } .... }
However, the problem of this approach seems to be that :Code:<aop:config> <aop:advisor id="encodePassword" advice-ref="setPasswordInterceptor" pointcut="execution(* org.crank.crud.GenericDao.*(..))"/> </aop:config> <bean id="setPasswordInterceptor" class="org.gng.jbc.advice.EncodePassword"> <property name="authenticationProvider" ref="daoAuthenticationProvider"/> </bean>
1. There actually is no bean created for the models and spring's AOP facilities only works on beans that is created through it. Thus I cannot intercept at the model level.
2. My generic dao beans are created through the ProxyBeanFactory which again seems to be completely bypass the AOP interception(not sure why though).
I did verify that if instead of using the generic DAO approach but create a wrapper class and create a bean using that wrapper class(where I inject my generic dao bean into it), I can intercept my wrapper class.
any advice or pointers ?


Reply With Quote