2

I read the "Spring Security 3 database authentication with Hibernate"! But I don't know how I should implementate it into my project!

  • In which document I have to set the password/username/drivers/url for the database?
  • I have different column titles like OPERATOR_ID/USR_ID/PASSWORD

OPERATOR_ID should be the login name, USR_ID the role and the password for the login

Please, maybe you could post an example which implements my questions? Maybe for a checkout or a *.war file?

рüффп
  • 5,172
  • 34
  • 67
  • 113
Prog-X-
  • 21
  • 2
  • [Here is a nice post for this problem][1] [1]: http://stackoverflow.com/questions/20068593/spring-security-java-config-does-not-work – zment Oct 27 '14 at 08:21

2 Answers2

0

I dont think there is any configuration as such for doing this. You have to implement the UserDetailsService which has only one method loadUserByUsername to load the user and you have to implement the same to load your user information from your database using hibernate.

See here

Gopi
  • 10,073
  • 4
  • 31
  • 45
0

You would need to configure a JDBCDaoImpl bean which takes a Datasource as a parameter. How you retrieve the Datasource is up to you, you may grab it from the app server or use something like Spring's DriverManagerDatasource Here is some (pseudo) config

<bean id="datasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  <property name="driverClassName"><value>your.driver.classname</value></property>
  <property name="url"><value>yourDatabaseUrl</value></property>
  <property name="username"><value>yourUsername</value></property>
  <property name="password"><value>yourPassword</value></property>
</bean>

<bean id="dao" class="org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl">
  <property name="DataSource" ref="datasource" />
 ...
</bean>