Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Security: Authentication user manually

I trying authenticate user in Spring Security application via oAuth. I'm already received token and user's data.

How can I authenticate user manually without password and classic login form? Thank you.

like image 666
Taras Sheremeta Avatar asked Mar 30 '12 11:03

Taras Sheremeta


1 Answers

Something like this:

Authentication authentication =  new UsernamePasswordAuthenticationToken(person, null, person.getAuthorities());
log.debug("Logging in with {}", authentication.getPrincipal());
SecurityContextHolder.getContext().setAuthentication(authentication);

Where person is your UserDetailsBean object.

like image 196
vacuum Avatar answered Sep 28 '22 10:09

vacuum