Creating a custom UserDetailsService object
While we can link our domain model (CalendarUser
) with Spring Security’s domain model (UserDetails
), we have to maintain multiple representations of the user. To resolve this dual maintenance, we can implement a custom UserDetailsService
object to translate our existing CalendarUser
domain model into an implementation of Spring Security’s UserDetails
interface. By translating our CalendarUser
object into UserDetails
, Spring Security can make security decisions using our custom domain model. This means that we will no longer need to manage two different representations of a user.
The CalendarUserDetailsService class
Up to this point, we have needed two different representations of users: one for Spring Security to make security decisions, and one for our application to associate our domain objects to. Create a new class named CalendarUserDetailsService
that will make Spring Security aware of our CalendarUser
object. This...