I have been having a problem that has troubled me for a while. Searching on this site and google hasn't yielded much help. I have already posted the problem on the spring source forum here but nobody has answered yet so I thought I might try here. You always get an answer on stackoverflow :-)
I have a custom UserDetailsService with autowired users dao bean. When I run the application in dev mode I get the login page. On login, nothing happens. Strange enough the app doesn't break or throw an error. I used some println statements to find out the farthest point the login service gets to my UserDaoImpl class on this line,
List<User> temp = getHibernateTemplate().find("select h from users h where username='" + username + "'");
it stops there, any println messages after that don't show on the console. In brief this are my configurations. If you need more details kindly look at detailed explanation I posted on spring source forum.
<http auto-config="true">
<intercept-url pattern="/gwtsecurity/**" access="ROLE_USER"/>
<intercept-url pattern="/gwt/**" access="ROLE_USER"/>
<intercept-url pattern="/**/*.html" access="ROLE_USER"/>
<intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<intercept-url pattern="/login.jsp*" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<form-login login-page="/login.jsp"/>
</http>
<beans:bean id="userDetailsService" class="com.kibyegn.server.auth.UserDetailsServiceImpl">
</beans:bean>
<beans:bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<beans:property name="userDetailsService" ref="userDetailsService"/>
</beans:bean>
<beans:bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager">
<beans:property name="providers">
<beans:list>
<beans:ref local="daoAuthenticationProvider" />
</beans:list>
</beans:property>
</beans:bean>
<authentication-manager>
<authentication-provider user-service-ref="userDetailsService">
</authentication-provider>
</authentication-manager>
and my hibernate config file
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://127.0.0.1:5432/GwtApp" />
<property name="username" value="postgres" />
<property name="password" value="password" />
</bean>
<!-- HIBERNATE CONFIGURATION -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.kibyegn.client.model.User</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="userDao"
class="com.kibyegn.client.dao.UserDaoImpl"
scope="singleton">
<property name="hibernateTemplate" ref="hibernateTemplate" />
</bean>
<bean id="userDetailsService"
class="com.kibyegn.server.auth.UserDetailsServiceImpl">
</bean>
Could someone please save me from my misery. Help is highly appreciated. Kibet.
find("select h from users h where username=?", username)log4j.logger.org.springframework.security=DEBUG<listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener>(AbstractUserDetailsAuthenticationProvider.java:authenticate:131) User 'kibet' not found (AbstractAuthenticationProcessingFilter.java:unsuccessfulAuthentication:318) Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Bad credentials. I don't know why the login fails because I have the user 'kibet' in the database.