How to get authenticated remote user in java server side code

795 views
Skip to first unread message

Ilan Schwarts

unread,
Feb 8, 2016, 9:02:57 AM2/8/16
to waffle
Hi, So i have integrated waffle in my tomcat 7, in the JSP file sample I get the delegated user via request.GetRemoteUser() when request is HttpServletRequest.
The client (from another machine) with a different username then the user that runs the tomcat invoke http get to index.jsp and i see the user is as expected (its the client user and not the server user)
But, When using server-side code, how can i get that username ?
I tried this 

But the class WindowsSecurityContextImpl has no .initialize() method that takes not parameters.. I tried earlier versions of waffle, maybe the function was deprecated. nothing helped
This is not a good solution since its not working - i dont know how it ever worked - if it does not compile.

How can i get the delegated user (impersonated/remote user ?) in a plain java code.
in C# it would be Thread.CurrentPrincipal.Identity

Daniel Doubrovkine

unread,
Feb 8, 2016, 10:37:59 AM2/8/16
to waffle...@googlegroups.com
If you're impersonating (that's a filter option) the current user server-side would be a Win32 call to GetUserNameW, you can check out http://code.dblock.org/2010/02/19/win32-pinvoke-with-jna.html, eg. Advapi32Util.getUserName().

If you're not impersonating, then you have to get it via the request, so request.getUserPrincipal().getName()

Does this help? 

--
You received this message because you are subscribed to the Google Groups "waffle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to waffle-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages