Spring uses a default scheme for database authorization (see below), therefore you have to map your scheme...
For spring security try something like this (but modifiy the SQL statement concerning your needs):
Add e.g. to web.xml
Code:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext*.xml
</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
applicationContext-security.xml
Code:
?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.2.xsd">
<http auto-config="true" access-denied-page="/error403.html">
<intercept-url pattern="/login.html*" filters="none"/>
<form-login login-page='/login.html' authentication-failure-url="/login.html?login_error=1" default-target-url="/index.jsp" />
</http>
<authentication-provider user-service-ref="userService" />
<jdbc-user-service id="userService" data-source-ref="securityDataSource"
users-by-username-query="SELECT Login AS 'username', Password AS 'password', Enabled AS 'enabled' FROM User WHERE Login = ?"
authorities-by-username-query="SELECT u.Login as 'username', ua.Authority as 'authority' FROM Authority ua, User u WHERE ua.id = u.authority_id AND u.Login = ?"
/>
<beans:bean id="securityDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassName" value="${db.driverClass}" />
<beans:property name="url" value="${db.jdbcUrl}" />
<beans:property name="username" value="${db.user}" />
<beans:property name="password" value="${db.password}" />
</beans:bean>
</beans:beans>
maybe you also need to change the jdbc implementation concerning your database requirements.
The libs you need are:
Code:
spring-security-acl-2.0.3.jar
spring-security-core-2.0.3.jar
spring-security-core-tiger-2.0.3.jar
spring-security-taglibs-2.0.3.jar
Spring itself uses by default this scheme:
Code:
CREATE TABLE users (
username VARCHAR(50) NOT NULL PRIMARY KEY,
password VARCHAR(50) NOT NULL,
enabled BIT NOT NULL
);
CREATE TABLE authorities (
username VARCHAR(50) NOT NULL,
authority VARCHAR(50) NOT NULL
);
you have to map your own implementation to it.
A different way might be, instead of using the userService, to create a view which matches the correct scheme.
:-)