Announcement Announcement Module
Collapse
No announcement yet.
DigestAuthenticationFilter with database users, possible?? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • DigestAuthenticationFilter with database users, possible??

    Hello,

    My Spring-Security implementation for http-digest:
    Code:
    <bean id="digestFilter" class="org.springframework.security.web.authentication.www.DigestAuthenticationFilter">
    	  <property name="userDetailsService" ref="userService"/>
    	  <property name="authenticationEntryPoint" ref="digestEntryPoint"/>
    	</bean>
    
    ========================================================================
    
    <security:authentication-manager alias="authenticationManager">
          <security:authentication-provider ref="inMemoryAuthenticationProvider"/>
       </security:authentication-manager>
    
    ========================================================================
    
    
    <bean id="inMemoryAuthenticationProvider"
             class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
          <property name="hideUserNotFoundExceptions" value="false"/>
         <property name="userDetailsService" ref="inMemoryUserService"/> 
          <property name="messageSource" ref="messageSource"/>
       </bean>
    
    ========================================================================
    
    
    <security:user-service id="inMemoryUserService">
    		<security:user name="user" password="user" authorities="ROLE_USER"/>				
    		<security:user name="admin" password="admin" authorities="ROLE_ADMIN"/>
    		<security:user name="invitado" password="invitado" authorities="ROLE_INVITADO"/>
    	</security:user-service>
    I'm trying to customize it to obtain user data from a database. I tried to access from the Interface class UserDetailsService.
    Code:
    public class CustomUserDetailsService implements UserDetailsService {
    
    	@Override
    	public UserDetails loadUserByUsername(String arg0)
    			throws UsernameNotFoundException {
    		
    		List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
    		
    		authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
    		
    		return new User(
    				"pepe", 
    				"psw",
    				true,
    				true,
    				true,
    				true,
    				authorities);
    	}
    
    }
    This does not work because the label when implementing security: user-service, no class attributes.

    Any ideas?, How to access a database of users?
Working...
X