I need to read a property value in my UserDetailsDaoImpl. I'm using Spring Security.
It succesfully reads inside of a @Controller
but not in this class maybe because it's a @Repository
.
What can i do to read the property value?
UserDetailsDaoImpl:
@Repository
public class UserDetailsDaoImpl extends JdbcDaoSupport implements UserDetailsDao {
@Value("${emails_blocked}")
private String emails_blocked;
Beans:
<context:property-placeholder location="classpath:config.properties"/>
edit:
this is how i call UserDetailsDaoImpl:
@Autowired
UserDetailsDao userDetailsDao;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
try {
Authentication auth = super.authenticate(authentication);
// if reach here, means login success, else exception will be thrown
// reset the user_attempts
userDetailsDao.resetFailAttempts(authentication.getName());
return auth;
} catch (BadCredentialsException e) {
userDetailsDao.updateFailAttempts(authentication.getName());
throw e;
}
my beans updated:
<beans:bean id="userDetailsDao" class="com.setelog.spring.dao.UserDetailsDaoImpl" >
<beans:property name="dataSource" ref="dataSource" />
</beans:bean>
<beans:bean id="encoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/>
<beans:bean id="authenticationProvider"
class="com.setelog.spring.handler.LimitLoginAuthenticationProvider">
<beans:property name="userDetailsService" ref="customUserDetailsService" />
<beans:property name="userDetailsDao" ref="userDetailsDao" />
<beans:property name="passwordEncoder" ref="encoder" />
</beans:bean>