Friday 27 December 2013

Spring Security : User Details in properties file

In my previous post, a simple example demonstrating Spring Security was presented wherein the user details were provided int the spring-security.xml file. 

In this example, the user details will be stored in an external properties file. Rest of the configuration remains the same. The properties file should look like this -

username=password,grantedAuthority[,grantedAuthority][,enabled|disabled]

Sample properties file
user1=user1password,ROLE_USER,ROLE_ADMIN,enabled
user2=user2password,ROLE_USER,enabled

Configuring spring-servlet.xml



 
  
  
  
  
 

 
  
   
  
 

Notice that in this case we provide users.properties as a value for the attribute 'properties' for the user-service.

You can download the complete source code for this example from here.

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete