How to use both database and LDAP authentication in Spring security?
We have a Sprin开发者_C百科g MVC application. We now have to integrate spring security in it.
The authentication can be done using either database or using LDAP.
We will a have a configuration setting either in a properties file or a database to decide which authentication to use i.e. if the user should be authenticated against a database or a LDAP.
At any given time there will be only one type of authentication.
e.g. A company test1 can have a database authentication and another company test 2 can have ldap authentication.
Some ideas:
- If each client is deployed separately with its own configuration, configure the DAO and LDAP authentication in 2 different XML files. At build time, choose which one you want to use and bundle it in your WAR.
- If there is only 1 WAR, maybe try including both XML files in the WAR, and set a system property using
-Dmyprop=foo
(o some other way) when starting up the app. Then, in your Spring config, include the appropriate config file using${myprop}
so that the correct file is called and used.
精彩评论