简体   繁体   English

带有jdbc的Spring Security 3.0

[英]Spring Security 3.0 with jdbc

I read the "Spring Security 3 database authentication with Hibernate"! 我阅读了“使用Hibernate进行Spring Security 3数据库身份验证”! 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? 我必须在哪个文档中设置数据库的密码/用户名/驱动程序/ URL?
  • I have different column titles like OPERATOR_ID/USR_ID/PASSWORD 我有不同的列标题,例如OPERATOR_ID / USR_ID / PASSWORD

OPERATOR_ID should be the login name, USR_ID the role and the password for the login OPERATOR_ID应该是登录名,USR_ID是登录的角色和密码

Please, maybe you could post an example which implements my questions? 拜托,也许您可​​以发布一个实现我的问题的示例? Maybe for a checkout or a *.war file? 也许要结帐或* .war文件?

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. 您必须实现UserDetailsService ,该方法只有一种方法loadUserByUsername才能加载用户,还必须实现该方法才能使用hibernate从数据库中加载用户信息。

See here 这里

You would need to configure a JDBCDaoImpl bean which takes a Datasource as a parameter. 您将需要配置一个JDBCDaoImpl bean,它以数据源作为参数。 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 数据源的获取方式由您决定,您可以从应用服务器中获取数据源,或使用类似Spring的DriverManagerDatasource之类的东西。这是一些(伪)配置

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM