0

I have a page for user to type in username/password and choose user role. User may or may not exist at the moment but I have to custom code to register the user from controller by information from the page.

The question is, how can I put the user role into the Security context after register or validate the user so that spring framework can identify user role across the application, like in SecurityContextHolder?

Thanks.

Dreamer
  • 7,333
  • 24
  • 99
  • 179
  • 1
    This might help: http://stackoverflow.com/questions/4664893/how-to-manually-set-an-authenticated-user-in-spring-security-springmvc – Joshua Moore Jan 20 '14 at 16:16

1 Answers1

0

To get the role assigned for user that want's to log in you need to implement UserDetailsService or write a custom AuthenticationProvider class that handles the authentication. Both of them have an authenticate method that needs 3 parameters: username, password and collection of authorities. Read up on google how to implement custom UserDetailsService or AuthenticationProvider.

Vaelyr
  • 2,841
  • 2
  • 21
  • 34