getting currently logged in username in jenkins java plugin

872 views
Skip to first unread message

shruthi ganesh

unread,
Jan 9, 2013, 12:12:35 AM1/9/13
to jenkins...@googlegroups.com
Hi,
        I am writing a plugin to authorize an authenticated user in jenkins. I require the username of the currently logged in user. I have used mysql db for authentication. Is there any possibility of getting the username?. Does jenkins store the user details of the logged in user anywhere?.                                                                                                                                                  



Thanks in advance.

Regards,
 --Shruthi Ganesh


Christopher Orr

unread,
Jan 9, 2013, 1:21:10 PM1/9/13
to jenkins...@googlegroups.com
On 09/01/13 06:12, shruthi ganesh wrote:
> I am writing a plugin to authorize an authenticated user in
> jenkins. I require the username of the currently logged in user. I have
> used mysql db for authentication. Is there any possibility of getting
> the username?. Does jenkins store the user details of the logged in user
> anywhere?.

This is probably a question better suited to the jenkinsci-dev mailing list.

I've used code like this to get the current user's ID:

import hudson.model.User;
import org.acegisecurity.context.SecurityContextHolder;

String userId =
SecurityContextHolder.getContext().getAuthentication().getName();
User u = User.get(userId, false);

Regards,
Chris
Reply all
Reply to author
Forward
0 new messages