java - What's the "principal" in Spring Security? -


i'm new spring , spring security. reading spring security , came out concept of principal, should current logged user. if have more 1 current logged user? so, question is, principal in spring security?

i've read example tutorial:

http://www.mkyong.com/spring-security/get-current-logged-in-username-in-spring-security/

and seem take account there's 1 current logged user, isn't case.

how retrieve specific user? , how differentiate between users doing requests?

the principal is logged in user. however, retrieve through security context bound current thread , such it's bound current request , session.

securitycontextholder.getcontext() internally obtains current securitycontext implementation through threadlocal variable. because request bound single thread context of current request.

to simplify security context in session , contains user/principal , roles/authorities.

how retrieve specific user?

you don't. apis designed allow access user & session of current request. let user 1 of 100 authenticated users. if issues request against server allocate 1 thread process request. if securitycontextholder.getcontext().getauthentication() in context of thread. default within thread don't have access context of user b processed different thread.

and how differentiate between users doing requests?

you don't have to, that's servlet container you.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -