Introduced DummyUserDetailsService for easier testing

This commit is contained in:
Mike Wiesner
2009-08-31 14:29:22 +00:00
parent 8131173a96
commit bbc4348f22
2 changed files with 59 additions and 16 deletions

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.security.extensions.kerberos.sample;
import org.springframework.dao.DataAccessException;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
/**
*
* @author Mike Wiesner
* @since 1.0
* @version $Id$
*/
public class DummyUserDetailsService implements UserDetailsService {
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
return new User(username, "notUsed", true, true,true,true, AuthorityUtils.createAuthorityList("ROLE_USER"));
}
}

View File

@@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<sec:http entry-point-ref="spnegoEntryPoint" >
<sec:http entry-point-ref="spnegoEntryPoint">
<sec:intercept-url pattern="/secure/**" access="IS_AUTHENTICATED_FULLY" />
<sec:custom-filter ref="spnegoAuthenticationProcessingFilter"
position="BASIC_PROCESSING_FILTER" />
@@ -17,12 +17,12 @@
class="org.springframework.security.extensions.kerberos.web.SpnegoAuthenticationProcessingFilter" />
<bean id="spnegoAuthenticationProcessingFilter"
class="org.springframework.security.extensions.kerberos.web.SpnegoAuthenticationProcessingFilter" >
<property name="authenticationManager" ref="authenticationManager"/>
</bean>
class="org.springframework.security.extensions.kerberos.web.SpnegoAuthenticationProcessingFilter">
<property name="authenticationManager" ref="authenticationManager" />
</bean>
<sec:authentication-manager alias="authenticationManager" >
<sec:authentication-provider ref="kerberosServiceAuthenticationProvider"/>
<sec:authentication-manager alias="authenticationManager">
<sec:authentication-provider ref="kerberosServiceAuthenticationProvider" />
</sec:authentication-manager>
<bean id="kerberosServiceAuthenticationProvider"
@@ -30,19 +30,22 @@
<property name="ticketValidator">
<bean
class="org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator">
<property name="servicePrincipal" value="HTTP/mbpmike.secpod.de" />
<property name="keyTabLocation" value="classpath:java-test.keytab" />
<property name="servicePrincipal" value="HTTP/add-your-hostname-here" />
<property name="keyTabLocation" value="classpath:spring-security.keytab" />
</bean>
</property>
<property name="userDetailsService">
<bean
class="org.springframework.security.core.userdetails.memory.InMemoryDaoImpl">
<property name="userProperties">
<value>
mike@SECPOD.DE=notUsed,ROLE_ADMIN
<property name="userDetailsService" ref="dummyUserDetailsService" />
</bean>
<!-- Just returns the User authenticated by Kerberos and gives him the ROLE_USER -->
<bean id="dummyUserDetailsService" class="org.springframework.security.extensions.kerberos.sample.DummyUserDetailsService"/>
<bean id="inMemoryUserDetailsService"
class="org.springframework.security.core.userdetails.memory.InMemoryDaoImpl">
<property name="userProperties">
<value>
mike@SECPOD.DE=notUsed,ROLE_ADMIN
</value>
</property>
</bean>
</property>
</bean>
</beans>