Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9154653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:27:44+00:00 2026-06-17T12:27:44+00:00

How can we migrate users from one database to another using Spring Security, on-the-fly

  • 0

How can we migrate users from one database to another using Spring Security, on-the-fly and transparent to the user?

Background

We use Spring Security with form based authentication in our web application. Our configuration uses standard Spring JDBC components backed by a user database. However, we also have another user database from an old system, which has roughly ten times the number of users compared to the new one. We want to allow users in the old database to login as well. To the user, this should be totally transparent.

Since most of the users in the old database are not active anymore, we don’t want to migrate all of them into the new database. For performance reasons, we want to keep the new user database as small as possible, while still containing all active users. After a period of time, we would like to disconnect the old user database, effectively deleting all inactive users.

The idea that we have come up with is to migrate users on demand. When a non-existing user (not in the new database) tries to login, we want to check if the user can authenticate against the old user database, and in that case migrate the user to the new database and log them in automatically.

There are many extension points in the Spring Security framework, the question is which ones would suit our purposes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:27:45+00:00Added an answer on June 17, 2026 at 12:27 pm

    I think the best place is org.springframework.security.authentication.AuthenticationManager. You can prepare two different AuthenticationProvider instances (for new and old databases). If you inject them into defult AuthenticationManager (actually it is ProviderManager class) then it will iterate trough both providers and give you first successfull authentication result. Your custom AuthenticationManager will have slightly different logic:

    • it will know the difference between two providers
    • first of all it will check new database
    • in a case of BadCredentialsException it will check old database
    • if user is authenticated via old database then it will copy account records
    • it will be good idea to recall first AuthenticationProvider to be sure that everything is OK
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing code that will migrate some data from one database to another,
I want to migrate the data from one table to another, besides the two
I need to migrate from my old user DB, to a new one.... but
I have migrated from one sever to another. I have restored my database and
How can I view the list of user defined functions in mysql database using
Can I order my users in the database, so I don't have to say
I'm one of those that recently decided to migrate from MySQL to PostgreSQL and
I am trying to migrate an application from OC4J to Weblogic, but I can
I am writing some code that can migrate some device persisted data to a
Since I migrated to Snow Leopard I can't run any Rake command from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.