Ok I will clean all in relation to post http://forum.springsource.org/showthread.php?t=72255
I want to link Spring Security with Hibernate.
I have dispatcher-servlet.xml with working hibernate
I have securityContext.xmlCode:<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop> <prop key="hibernate.connection.datasource">jdbc/nowoczesne_cc</prop> (...) </bean> <!-- Hibernate Pojo manipulation Layer --> <bean id="hibernateTUserDao" class="org.mysite.cc.hibernatedao.HibernateTUserDao"> <property name="sessionFactory" ref="hibernateSessionFactory"/> </bean> (...)
I implement UserDetails in my TUser Pojo, and in HibernateTUserDao implements UserDetailsService.Code:<s:http auto-config="true"> (...) </s:http> <!-- IN MEMORY PROVIDER --> <!-- <s:authentication-provider> <s:user-service> <s:user name="marcin" password="xxx" authorities="ROLE_USER, ROLE_ADMIN" /> <s:user name="bob" password="yyy" authorities="ROLE_USER" /> </s:user-service> </s:authentication-provider> --> <!-- MY OWN zCC PROVIDER --> <beans:bean id="customUserDetailsService" class="org.zethost.cc.hibernatedao.HibernateTUserDao"> <property name="sessionFactory" ref="[ THIS IS THE MAIN PROBLEM ]"/> </beans:bean> <s:authentication-provider user-service-ref="customUserDetailsService" />
Thing which I cant understand is how could I pass Hibernate session to security context? I supose that I can reDeclare session Factory and all other beans in security context but "my mind say me" that it not good idea. Is any way to declare one shared resource like sessionFactory for dispatcherServlet and securityContext? Maybe someone can give me advice How can I cleanly link Spring security and Hibernate. I read many post and many blogs but in evry place there is only something like
I cant understand where and how this declared?Code:<b:bean id="userDetailsService" class="com.ap.user.HibernateUserDetailsService"> <b:property name="hibernateTemplate" ref="hibernateTemplate" /> </b:bean> OR <property name="sessionFactory" ref="sessionFactoryBean"/>
Please help guys.



