applicationContext-spring-security-jdbc.xml 2.5 KB
<?xml version="1.0" encoding="UTF-8"?>
<!--+
	| Application context containing JDBC AuthenticationProvider
	| implementation.
	+-->

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:security="http://www.springframework.org/schema/security"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="
              http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
              http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2.xsd
			   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
			   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

	<security:authentication-manager alias="authenticationManager">
		<security:authentication-provider ref="daoAuthenticationProvider" />
 	</security:authentication-manager>

	<bean id="daoAuthenticationProvider"
		class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
		<property name="userDetailsService">
			<ref bean="userDetailsService" />
		</property>
		<property name="passwordEncoder">
			<ref bean="passwordEncoder" />
		</property>
	</bean>

	<bean id="userDetailsService"
		class="org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl">
		<property name="dataSource">
			<ref local="dataSource" />
		</property>
		<property name="authoritiesByUsernameQuery">
			<value>
				<![CDATA[SELECT username, authority FROM GRANTED_AUTHORITIES WHERE username = ? ORDER BY authority]]>
			</value>
		</property>
		<property name="usersByUsernameQuery">
			<value>
				<![CDATA[SELECT username, password, enabled FROM USERS WHERE username = ? ORDER BY username]]>
			</value>
		</property>
	</bean>
	<bean id="dataSource"
		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
		<property name="url"
			value="jdbc:hsqldb:hsql://localhost:9001/hibernate" />
		<property name="username" value="hibuser" />
		<property name="password" value="password" />
	</bean>

  <bean id="passwordEncoder"
    class="org.springframework.security.authentication.encoding.PlaintextPasswordEncoder" />
 

</beans>