title: How to login user from java code in Spring Security?
body: <p>I am trying to write some script in my java code, where i need to login users, do some stuff like real user could do from web client and logout for each of them.</p>
  
  <p>How does this work in spring security?
  What should i do?
  I mean how to imitate user authentication like in real, with session, roles and authorities?</p>
  
  <p>Thanks a lot!</p>