28/07/2013

[Java] Get current user from portlet

To get the user currently authenticated on the portal from a portlet, you may use:

Principal p = request.getUserPrincipal();

you may then call the getName method to get the UID of the user. If the user is not authenticated or the page is not protected, the Principal object is null.

No comments:

Post a Comment

With great power comes great responsibility