REST API call as a user from the server

Hi, I want to be able to call a REST API from Java in the Server as a particular user. The REST API call is easy enough but how do I make it come from a particular user. This is being called from within a new Thread. I have tried adding:

authenticationContext = com.atlassian.jira.component.ComponentAccessor.getJiraAuthenticationContext();
authenticationContext.setLoggedInUser(user);

but it doesn’t make any difference

Any ideas?

Thanks
Paul