[英]jdbc spring security, apache commons dbcp
In a Spring Security, I defined a jdbc auth manager:在 Spring Security 中,我定义了 jdbc 身份验证管理器:
<security:authentication-manager>
<security:authentication-provider>
<security:jdbc-user-service data-source-ref="securityDataSource"/>
</security:authentication-provider>
</security:authentication-manager>
<bean id="securityDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://127.0.0.1:5432/mydb"/>
... user and password props ...
</bean>
At this point I've discovered that I need Jakarta Commons DBCP.在这一点上,我发现我需要 Jakarta Commons DBCP。 I've added commons-dbcp-1.4, i get the following exception:我添加了 commons-dbcp-1.4,我得到以下异常:
...java.lang.NoClassDefFoundError: org/apache/commons/pool/KeyedObjectPoolFactory
This path actually isn't included in commons dbcp 1.4.此路径实际上不包含在 commons dbcp 1.4 中。
What am I missing again?我又错过了什么?
EDITED已编辑
Ok, added the dependency to common pool, it works because with the right credentials I no more get the "bad credentials" page.好的,将依赖项添加到公共池,它可以工作,因为使用正确的凭据我不再获得“错误凭据”页面。 But I get an HTTP Status 403 - Access is denied.但我得到一个 HTTP 状态 403 - 访问被拒绝。
Seems like my user is authenticated, but isn't authorized.似乎我的用户已通过身份验证,但未经授权。
Any idea...?任何想法...? :-) :-)
My http element is:我的 http 元素是:
<security:http auto-config="true" >
<security:intercept-url pattern="/**" access="ROLE_USER"/>
</security:http>
and I have a "test" user that is bind to the "USER" role in the "authorities" table.我有一个“测试”用户,它绑定到“权限”表中的“用户”角色。
thanks谢谢
Commons DBCP relies on the Commons Pools libraries, because of this, you actually need to download the commons-pool jar files, and include them in your path. Commons DBCP 依赖于 Commons Pools 库,因此,您实际上需要下载 commons-pool jar 文件,并将它们包含在您的路径中。
You may also need to download the commons-collections package, too.您可能还需要下载 commons-collections package。
The jar file commons-dbcp-1.4 does not contain the class org.apache.commons.pool.keyedobjectpoolfactory
jar 文件 commons-dbcp-1.4 不包含 class org.apache.commons.pool.keyedobjectpoolfactory
You need to add another jar to your project classpath - commons-pool-1.4.您需要将另一个 jar 添加到您的项目类路径 - commons-pool-1.4。
You can download commons-pool-1.4 from here http://commons.apache.org/pool/download_pool.cgi您可以从这里下载 commons-pool-1.4 http://commons.apache.org/pool/download_pool.cgi
Try changing your test user's authority to ROLE_USER.尝试将您的测试用户的权限更改为 ROLE_USER。
Don't forget you'll also need the Postgre JDBC drivers, just in case you hadn't included those already.不要忘记您还需要 Postgre JDBC 驱动程序,以防万一您还没有包含这些驱动程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.